Skip to content

Commit bfdc4aa

Browse files
committed
Merge tag '5.12-rc3-smb3' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs fixes from Steve French: "Five cifs/smb3 fixes - three for stable, including an important ACL fix and security signature fix" * tag '5.12-rc3-smb3' of git://git.samba.org/sfrench/cifs-2.6: cifs: fix allocation size on newly created files cifs: warn and fail if trying to use rootfs without the config option fs/cifs/: fix misspellings using codespell tool cifs: Fix preauth hash corruption cifs: update new ACE pointer after populate_new_aces.
2 parents af97713 + 65af8f0 commit bfdc4aa

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

fs/cifs/cifs_swn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ static int cifs_swn_send_unregister_message(struct cifs_swn_reg *swnreg)
248248

249249
/*
250250
* Try to find a matching registration for the tcon's server name and share name.
251-
* Calls to this funciton must be protected by cifs_swnreg_idr_mutex.
251+
* Calls to this function must be protected by cifs_swnreg_idr_mutex.
252252
* TODO Try to avoid memory allocations
253253
*/
254254
static struct cifs_swn_reg *cifs_find_swn_reg(struct cifs_tcon *tcon)

fs/cifs/cifsacl.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,6 @@ static int set_chmod_dacl(struct cifs_acl *pdacl, struct cifs_acl *pndacl,
11181118
/* Retain old ACEs which we can retain */
11191119
for (i = 0; i < src_num_aces; ++i) {
11201120
pntace = (struct cifs_ace *) (acl_base + size);
1121-
pnntace = (struct cifs_ace *) (nacl_base + nsize);
11221121

11231122
if (!new_aces_set && (pntace->flags & INHERITED_ACE)) {
11241123
/* Place the new ACEs in between existing explicit and inherited */
@@ -1131,14 +1130,18 @@ static int set_chmod_dacl(struct cifs_acl *pdacl, struct cifs_acl *pndacl,
11311130
}
11321131

11331132
/* If it's any one of the ACE we're replacing, skip! */
1134-
if ((compare_sids(&pntace->sid, &sid_unix_NFS_mode) == 0) ||
1133+
if (!mode_from_sid &&
1134+
((compare_sids(&pntace->sid, &sid_unix_NFS_mode) == 0) ||
11351135
(compare_sids(&pntace->sid, pownersid) == 0) ||
11361136
(compare_sids(&pntace->sid, pgrpsid) == 0) ||
11371137
(compare_sids(&pntace->sid, &sid_everyone) == 0) ||
1138-
(compare_sids(&pntace->sid, &sid_authusers) == 0)) {
1138+
(compare_sids(&pntace->sid, &sid_authusers) == 0))) {
11391139
goto next_ace;
11401140
}
11411141

1142+
/* update the pointer to the next ACE to populate*/
1143+
pnntace = (struct cifs_ace *) (nacl_base + nsize);
1144+
11421145
nsize += cifs_copy_ace(pnntace, pntace, NULL);
11431146
num_aces++;
11441147

fs/cifs/fs_context.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,9 +1196,11 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
11961196
pr_warn_once("Witness protocol support is experimental\n");
11971197
break;
11981198
case Opt_rootfs:
1199-
#ifdef CONFIG_CIFS_ROOT
1200-
ctx->rootfs = true;
1199+
#ifndef CONFIG_CIFS_ROOT
1200+
cifs_dbg(VFS, "rootfs support requires CONFIG_CIFS_ROOT config option\n");
1201+
goto cifs_parse_mount_err;
12011202
#endif
1203+
ctx->rootfs = true;
12021204
break;
12031205
case Opt_posixpaths:
12041206
if (result.negated)

fs/cifs/inode.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2395,7 +2395,7 @@ int cifs_getattr(struct user_namespace *mnt_userns, const struct path *path,
23952395
* We need to be sure that all dirty pages are written and the server
23962396
* has actual ctime, mtime and file length.
23972397
*/
2398-
if ((request_mask & (STATX_CTIME | STATX_MTIME | STATX_SIZE)) &&
2398+
if ((request_mask & (STATX_CTIME | STATX_MTIME | STATX_SIZE | STATX_BLOCKS)) &&
23992399
!CIFS_CACHE_READ(CIFS_I(inode)) &&
24002400
inode->i_mapping && inode->i_mapping->nrpages != 0) {
24012401
rc = filemap_fdatawait(inode->i_mapping);
@@ -2585,6 +2585,14 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
25852585
if (rc == 0) {
25862586
cifsInode->server_eof = attrs->ia_size;
25872587
cifs_setsize(inode, attrs->ia_size);
2588+
/*
2589+
* i_blocks is not related to (i_size / i_blksize), but instead
2590+
* 512 byte (2**9) size is required for calculating num blocks.
2591+
* Until we can query the server for actual allocation size,
2592+
* this is best estimate we have for blocks allocated for a file
2593+
* Number of blocks must be rounded up so size 1 is not 0 blocks
2594+
*/
2595+
inode->i_blocks = (512 - 1 + attrs->ia_size) >> 9;
25882596

25892597
/*
25902598
* The man page of truncate says if the size changed,

fs/cifs/transport.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,9 +1196,12 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
11961196
/*
11971197
* Compounding is never used during session establish.
11981198
*/
1199-
if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP) || (optype & CIFS_SESS_OP))
1199+
if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP) || (optype & CIFS_SESS_OP)) {
1200+
mutex_lock(&server->srv_mutex);
12001201
smb311_update_preauth_hash(ses, rqst[0].rq_iov,
12011202
rqst[0].rq_nvec);
1203+
mutex_unlock(&server->srv_mutex);
1204+
}
12021205

12031206
for (i = 0; i < num_rqst; i++) {
12041207
rc = wait_for_response(server, midQ[i]);
@@ -1266,7 +1269,9 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
12661269
.iov_base = resp_iov[0].iov_base,
12671270
.iov_len = resp_iov[0].iov_len
12681271
};
1272+
mutex_lock(&server->srv_mutex);
12691273
smb311_update_preauth_hash(ses, &iov, 1);
1274+
mutex_unlock(&server->srv_mutex);
12701275
}
12711276

12721277
out:

0 commit comments

Comments
 (0)