Skip to content

Commit 25cd253

Browse files
committed
Merge: CIFS: Sync with upstream v6.9+ for RHEL 9.6
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5156 JIRA: https://issues.redhat.com/browse/RHEL-57983 Signed-off-by: Paulo Alcantara <[email protected]> Approved-by: Jay Shin <[email protected]> Approved-by: Scott Mayhew <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Rado Vrbovsky <[email protected]>
2 parents 141fc19 + 5025da2 commit 25cd253

31 files changed

+807
-164
lines changed

Documentation/admin-guide/cifs/usage.rst

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -722,40 +722,26 @@ Configuration pseudo-files:
722722
======================= =======================================================
723723
SecurityFlags Flags which control security negotiation and
724724
also packet signing. Authentication (may/must)
725-
flags (e.g. for NTLM and/or NTLMv2) may be combined with
725+
flags (e.g. for NTLMv2) may be combined with
726726
the signing flags. Specifying two different password
727727
hashing mechanisms (as "must use") on the other hand
728728
does not make much sense. Default flags are::
729729

730-
0x07007
731-
732-
(NTLM, NTLMv2 and packet signing allowed). The maximum
733-
allowable flags if you want to allow mounts to servers
734-
using weaker password hashes is 0x37037 (lanman,
735-
plaintext, ntlm, ntlmv2, signing allowed). Some
736-
SecurityFlags require the corresponding menuconfig
737-
options to be enabled. Enabling plaintext
738-
authentication currently requires also enabling
739-
lanman authentication in the security flags
740-
because the cifs module only supports sending
741-
laintext passwords using the older lanman dialect
742-
form of the session setup SMB. (e.g. for authentication
743-
using plain text passwords, set the SecurityFlags
744-
to 0x30030)::
730+
0x00C5
731+
732+
(NTLMv2 and packet signing allowed). Some SecurityFlags
733+
may require enabling a corresponding menuconfig option.
745734

746735
may use packet signing 0x00001
747736
must use packet signing 0x01001
748-
may use NTLM (most common password hash) 0x00002
749-
must use NTLM 0x02002
750737
may use NTLMv2 0x00004
751738
must use NTLMv2 0x04004
752-
may use Kerberos security 0x00008
753-
must use Kerberos 0x08008
754-
may use lanman (weak) password hash 0x00010
755-
must use lanman password hash 0x10010
756-
may use plaintext passwords 0x00020
757-
must use plaintext passwords 0x20020
758-
(reserved for future packet encryption) 0x00040
739+
may use Kerberos security (krb5) 0x00008
740+
must use Kerberos 0x08008
741+
may use NTLMSSP 0x00080
742+
must use NTLMSSP 0x80080
743+
seal (packet encryption) 0x00040
744+
must seal 0x40040
759745

760746
cifsFYI If set to non-zero value, additional debug information
761747
will be logged to the system error log. This field

fs/smb/client/cached_dir.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ smb2_close_cached_fid(struct kref *ref)
417417
{
418418
struct cached_fid *cfid = container_of(ref, struct cached_fid,
419419
refcount);
420+
int rc;
420421

421422
spin_lock(&cfid->cfids->cfid_list_lock);
422423
if (cfid->on_list) {
@@ -430,9 +431,10 @@ smb2_close_cached_fid(struct kref *ref)
430431
cfid->dentry = NULL;
431432

432433
if (cfid->is_open) {
433-
SMB2_close(0, cfid->tcon, cfid->fid.persistent_fid,
434+
rc = SMB2_close(0, cfid->tcon, cfid->fid.persistent_fid,
434435
cfid->fid.volatile_fid);
435-
atomic_dec(&cfid->tcon->num_remote_opens);
436+
if (rc) /* should we retry on -EBUSY or -EAGAIN? */
437+
cifs_dbg(VFS, "close cached dir rc %d\n", rc);
436438
}
437439

438440
free_cached_dir(cfid);

fs/smb/client/cifs_debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ static int cifs_security_flags_proc_open(struct inode *inode, struct file *file)
10721072
static void
10731073
cifs_security_flags_handle_must_flags(unsigned int *flags)
10741074
{
1075-
unsigned int signflags = *flags & CIFSSEC_MUST_SIGN;
1075+
unsigned int signflags = *flags & (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_SEAL);
10761076

10771077
if ((*flags & CIFSSEC_MUST_KRB5) == CIFSSEC_MUST_KRB5)
10781078
*flags = CIFSSEC_MUST_KRB5;

fs/smb/client/cifsfs.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ unsigned int sign_CIFS_PDUs = 1;
7373
/*
7474
* Global transaction id (XID) information
7575
*/
76-
unsigned int GlobalCurrentXid; /* protected by GlobalMid_Sem */
77-
unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */
78-
unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Sem */
76+
unsigned int GlobalCurrentXid; /* protected by GlobalMid_Lock */
77+
unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Lock */
78+
unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Lock */
7979
spinlock_t GlobalMid_Lock; /* protects above & list operations on midQ entries */
8080

8181
/*
@@ -132,7 +132,7 @@ module_param(enable_oplocks, bool, 0644);
132132
MODULE_PARM_DESC(enable_oplocks, "Enable or disable oplocks. Default: y/Y/1");
133133

134134
module_param(enable_gcm_256, bool, 0644);
135-
MODULE_PARM_DESC(enable_gcm_256, "Enable requesting strongest (256 bit) GCM encryption. Default: n/N/0");
135+
MODULE_PARM_DESC(enable_gcm_256, "Enable requesting strongest (256 bit) GCM encryption. Default: y/Y/0");
136136

137137
module_param(require_gcm_256, bool, 0644);
138138
MODULE_PARM_DESC(require_gcm_256, "Require strongest (256 bit) GCM encryption. Default: n/N/0");
@@ -154,6 +154,7 @@ struct workqueue_struct *decrypt_wq;
154154
struct workqueue_struct *fileinfo_put_wq;
155155
struct workqueue_struct *cifsoplockd_wq;
156156
struct workqueue_struct *deferredclose_wq;
157+
struct workqueue_struct *serverclose_wq;
157158
__u32 cifs_lock_secret;
158159

159160
/*
@@ -737,6 +738,8 @@ static void cifs_umount_begin(struct super_block *sb)
737738

738739
spin_lock(&cifs_tcp_ses_lock);
739740
spin_lock(&tcon->tc_lock);
741+
trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
742+
netfs_trace_tcon_ref_see_umount);
740743
if ((tcon->tc_count > 1) || (tcon->status == TID_EXITING)) {
741744
/* we have other mounts to same share or we have
742745
already tried to umount this and woken up
@@ -1399,7 +1402,7 @@ ssize_t cifs_file_copychunk_range(unsigned int xid,
13991402
target_tcon = tlink_tcon(smb_file_target->tlink);
14001403

14011404
if (src_tcon->ses != target_tcon->ses) {
1402-
cifs_dbg(VFS, "source and target of copy not on same server\n");
1405+
cifs_dbg(FYI, "source and target of copy not on same server\n");
14031406
goto out;
14041407
}
14051408

@@ -1876,9 +1879,16 @@ init_cifs(void)
18761879
goto out_destroy_cifsoplockd_wq;
18771880
}
18781881

1882+
serverclose_wq = alloc_workqueue("serverclose",
1883+
WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
1884+
if (!serverclose_wq) {
1885+
rc = -ENOMEM;
1886+
goto out_destroy_deferredclose_wq;
1887+
}
1888+
18791889
rc = cifs_init_inodecache();
18801890
if (rc)
1881-
goto out_destroy_deferredclose_wq;
1891+
goto out_destroy_serverclose_wq;
18821892

18831893
rc = init_mids();
18841894
if (rc)
@@ -1940,6 +1950,8 @@ init_cifs(void)
19401950
destroy_mids();
19411951
out_destroy_inodecache:
19421952
cifs_destroy_inodecache();
1953+
out_destroy_serverclose_wq:
1954+
destroy_workqueue(serverclose_wq);
19431955
out_destroy_deferredclose_wq:
19441956
destroy_workqueue(deferredclose_wq);
19451957
out_destroy_cifsoplockd_wq:
@@ -1979,6 +1991,7 @@ exit_cifs(void)
19791991
destroy_workqueue(cifsoplockd_wq);
19801992
destroy_workqueue(decrypt_wq);
19811993
destroy_workqueue(fileinfo_put_wq);
1994+
destroy_workqueue(serverclose_wq);
19821995
destroy_workqueue(cifsiod_wq);
19831996
cifs_proc_clean();
19841997
}

fs/smb/client/cifsglob.h

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ struct smb_version_operations {
347347
/* connect to a server share */
348348
int (*tree_connect)(const unsigned int, struct cifs_ses *, const char *,
349349
struct cifs_tcon *, const struct nls_table *);
350-
/* close tree connecion */
350+
/* close tree connection */
351351
int (*tree_disconnect)(const unsigned int, struct cifs_tcon *);
352352
/* get DFS referrals */
353353
int (*get_dfs_refer)(const unsigned int, struct cifs_ses *,
@@ -443,10 +443,10 @@ struct smb_version_operations {
443443
/* set fid protocol-specific info */
444444
void (*set_fid)(struct cifsFileInfo *, struct cifs_fid *, __u32);
445445
/* close a file */
446-
void (*close)(const unsigned int, struct cifs_tcon *,
446+
int (*close)(const unsigned int, struct cifs_tcon *,
447447
struct cifs_fid *);
448448
/* close a file, returning file attributes and timestamps */
449-
void (*close_getattr)(const unsigned int xid, struct cifs_tcon *tcon,
449+
int (*close_getattr)(const unsigned int xid, struct cifs_tcon *tcon,
450450
struct cifsFileInfo *pfile_info);
451451
/* send a flush request to the server */
452452
int (*flush)(const unsigned int, struct cifs_tcon *, struct cifs_fid *);
@@ -819,7 +819,7 @@ struct TCP_Server_Info {
819819
* Protected by @refpath_lock and @srv_lock. The @refpath_lock is
820820
* mostly used for not requiring a copy of @leaf_fullpath when getting
821821
* cached or new DFS referrals (which might also sleep during I/O).
822-
* While @srv_lock is held for making string and NULL comparions against
822+
* While @srv_lock is held for making string and NULL comparisons against
823823
* both fields as in mount(2) and cache refresh.
824824
*
825825
* format: \\HOST\SHARE[\OPTIONAL PATH]
@@ -1078,6 +1078,7 @@ struct cifs_ses {
10781078
and after mount option parsing we fill it */
10791079
char *domainName;
10801080
char *password;
1081+
char *password2; /* When key rotation used, new password may be set before it expires */
10811082
char workstation_name[CIFS_MAX_WORKSTATION_LEN];
10821083
struct session_key auth_key;
10831084
struct ntlmssp_auth *ntlmssp; /* ciphertext, flags, server challenge */
@@ -1190,6 +1191,7 @@ struct cifs_fattr {
11901191
*/
11911192
struct cifs_tcon {
11921193
struct list_head tcon_list;
1194+
int debug_id; /* Debugging for tracing */
11931195
int tc_count;
11941196
struct list_head rlist; /* reconnect list */
11951197
spinlock_t tc_lock; /* protect anything here that is not protected */
@@ -1276,7 +1278,9 @@ struct cifs_tcon {
12761278
__u32 max_cached_dirs;
12771279
#ifdef CONFIG_CIFS_FSCACHE
12781280
u64 resource_id; /* server resource id */
1281+
bool fscache_acquired; /* T if we've tried acquiring a cookie */
12791282
struct fscache_volume *fscache; /* cookie for share */
1283+
struct mutex fscache_lock; /* Prevent regetting a cookie */
12801284
#endif
12811285
struct list_head pending_opens; /* list of incomplete opens */
12821286
struct cached_fids *cfids;
@@ -1440,6 +1444,7 @@ struct cifsFileInfo {
14401444
bool swapfile:1;
14411445
bool oplock_break_cancelled:1;
14421446
bool status_file_deleted:1; /* file has been deleted */
1447+
bool offload:1; /* offload final part of _put to a wq */
14431448
unsigned int oplock_epoch; /* epoch from the lease break */
14441449
__u32 oplock_level; /* oplock/lease level from the lease break */
14451450
int count;
@@ -1448,6 +1453,7 @@ struct cifsFileInfo {
14481453
struct cifs_search_info srch_inf;
14491454
struct work_struct oplock_break; /* work for oplock breaks */
14501455
struct work_struct put; /* work for the final part of _put */
1456+
struct work_struct serverclose; /* work for serverclose */
14511457
struct delayed_work deferred;
14521458
bool deferred_close_scheduled; /* Flag to indicate close is scheduled */
14531459
char *symlink_target;
@@ -1929,7 +1935,7 @@ static inline bool is_replayable_error(int error)
19291935
#define CIFSSEC_MAY_SIGN 0x00001
19301936
#define CIFSSEC_MAY_NTLMV2 0x00004
19311937
#define CIFSSEC_MAY_KRB5 0x00008
1932-
#define CIFSSEC_MAY_SEAL 0x00040 /* not supported yet */
1938+
#define CIFSSEC_MAY_SEAL 0x00040
19331939
#define CIFSSEC_MAY_NTLMSSP 0x00080 /* raw ntlmssp with ntlmv2 */
19341940

19351941
#define CIFSSEC_MUST_SIGN 0x01001
@@ -1939,15 +1945,15 @@ require use of the stronger protocol */
19391945
#define CIFSSEC_MUST_NTLMV2 0x04004
19401946
#define CIFSSEC_MUST_KRB5 0x08008
19411947
#ifdef CONFIG_CIFS_UPCALL
1942-
#define CIFSSEC_MASK 0x8F08F /* flags supported if no weak allowed */
1948+
#define CIFSSEC_MASK 0xCF0CF /* flags supported if no weak allowed */
19431949
#else
1944-
#define CIFSSEC_MASK 0x87087 /* flags supported if no weak allowed */
1950+
#define CIFSSEC_MASK 0xC70C7 /* flags supported if no weak allowed */
19451951
#endif /* UPCALL */
1946-
#define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */
1952+
#define CIFSSEC_MUST_SEAL 0x40040
19471953
#define CIFSSEC_MUST_NTLMSSP 0x80080 /* raw ntlmssp with ntlmv2 */
19481954

1949-
#define CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_NTLMSSP)
1950-
#define CIFSSEC_MAX (CIFSSEC_MUST_NTLMV2)
1955+
#define CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_NTLMSSP | CIFSSEC_MAY_SEAL)
1956+
#define CIFSSEC_MAX (CIFSSEC_MAY_SIGN | CIFSSEC_MUST_KRB5 | CIFSSEC_MAY_SEAL)
19511957
#define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP)
19521958
/*
19531959
*****************************************************************
@@ -2065,9 +2071,9 @@ extern spinlock_t cifs_tcp_ses_lock;
20652071
/*
20662072
* Global transaction id (XID) information
20672073
*/
2068-
extern unsigned int GlobalCurrentXid; /* protected by GlobalMid_Sem */
2069-
extern unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */
2070-
extern unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Sem */
2074+
extern unsigned int GlobalCurrentXid; /* protected by GlobalMid_Lock */
2075+
extern unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Lock */
2076+
extern unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Lock */
20712077
extern spinlock_t GlobalMid_Lock; /* protects above & list operations on midQ entries */
20722078

20732079
/*
@@ -2117,6 +2123,7 @@ extern struct workqueue_struct *decrypt_wq;
21172123
extern struct workqueue_struct *fileinfo_put_wq;
21182124
extern struct workqueue_struct *cifsoplockd_wq;
21192125
extern struct workqueue_struct *deferredclose_wq;
2126+
extern struct workqueue_struct *serverclose_wq;
21202127
extern __u32 cifs_lock_secret;
21212128

21222129
extern mempool_t *cifs_sm_req_poolp;

fs/smb/client/cifspdu.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ typedef struct smb_com_open_rsp {
882882
__u8 OplockLevel;
883883
__u16 Fid;
884884
__le32 CreateAction;
885-
struct_group(common_attributes,
885+
struct_group_attr(common_attributes, __packed,
886886
__le64 CreationTime;
887887
__le64 LastAccessTime;
888888
__le64 LastWriteTime;
@@ -2266,7 +2266,7 @@ typedef struct {
22662266
/* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
22672267
/******************************************************************************/
22682268
typedef struct { /* data block encoding of response to level 263 QPathInfo */
2269-
struct_group(common_attributes,
2269+
struct_group_attr(common_attributes, __packed,
22702270
__le64 CreationTime;
22712271
__le64 LastAccessTime;
22722272
__le64 LastWriteTime;
@@ -2574,7 +2574,7 @@ typedef struct {
25742574

25752575

25762576
struct win_dev {
2577-
unsigned char type[8]; /* IntxCHR or IntxBLK or LnxFIFO*/
2577+
unsigned char type[8]; /* IntxCHR or IntxBLK or LnxFIFO or LnxSOCK */
25782578
__le64 major;
25792579
__le64 minor;
25802580
} __attribute__((packed));

fs/smb/client/cifsproto.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx,
296296
struct TCP_Server_Info *primary_server);
297297
extern void cifs_put_tcp_session(struct TCP_Server_Info *server,
298298
int from_reconnect);
299-
extern void cifs_put_tcon(struct cifs_tcon *tcon);
299+
extern void cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace);
300300

301301
extern void cifs_release_automount_timer(void);
302302

@@ -523,8 +523,9 @@ extern int CIFSSMBLogoff(const unsigned int xid, struct cifs_ses *ses);
523523

524524
extern struct cifs_ses *sesInfoAlloc(void);
525525
extern void sesInfoFree(struct cifs_ses *);
526-
extern struct cifs_tcon *tcon_info_alloc(bool dir_leases_enabled);
527-
extern void tconInfoFree(struct cifs_tcon *);
526+
extern struct cifs_tcon *tcon_info_alloc(bool dir_leases_enabled,
527+
enum smb3_tcon_ref_trace trace);
528+
extern void tconInfoFree(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace);
528529

529530
extern int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
530531
__u32 *pexpected_response_sequence_number);
@@ -720,8 +721,6 @@ static inline int cifs_create_options(struct cifs_sb_info *cifs_sb, int options)
720721
return options;
721722
}
722723

723-
struct super_block *cifs_get_tcon_super(struct cifs_tcon *tcon);
724-
void cifs_put_tcon_super(struct super_block *sb);
725724
int cifs_wait_for_server_reconnect(struct TCP_Server_Info *server, bool retry);
726725

727726
/* Put references of @ses and its children */

0 commit comments

Comments
 (0)