Skip to content

Commit e0fac5f

Browse files
committed
Merge tag 'v6.11-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull smb client fixes from Steve French: - fix for clang warning - additional null check - fix for cached write with posix locks - flexible structure fix * tag 'v6.11-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6: smb: smb2pdu.h: Use static_assert() to check struct sizes smb3: fix lock breakage for cached writes smb/client: avoid possible NULL dereference in cifs_free_subrequest()
2 parents 98a1b2d + 5b4f3af commit e0fac5f

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

fs/smb/client/file.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,16 +316,20 @@ static void cifs_free_subrequest(struct netfs_io_subrequest *subreq)
316316
#endif
317317
}
318318

319-
if (rdata->credits.value != 0)
319+
if (rdata->credits.value != 0) {
320320
trace_smb3_rw_credits(rdata->rreq->debug_id,
321321
rdata->subreq.debug_index,
322322
rdata->credits.value,
323323
rdata->server ? rdata->server->credits : 0,
324324
rdata->server ? rdata->server->in_flight : 0,
325325
-rdata->credits.value,
326326
cifs_trace_rw_credits_free_subreq);
327+
if (rdata->server)
328+
add_credits_and_wake_if(rdata->server, &rdata->credits, 0);
329+
else
330+
rdata->credits.value = 0;
331+
}
327332

328-
add_credits_and_wake_if(rdata->server, &rdata->credits, 0);
329333
if (rdata->have_xid)
330334
free_xid(rdata->xid);
331335
}
@@ -2750,6 +2754,7 @@ cifs_writev(struct kiocb *iocb, struct iov_iter *from)
27502754
struct inode *inode = file->f_mapping->host;
27512755
struct cifsInodeInfo *cinode = CIFS_I(inode);
27522756
struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server;
2757+
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
27532758
ssize_t rc;
27542759

27552760
rc = netfs_start_io_write(inode);
@@ -2766,12 +2771,16 @@ cifs_writev(struct kiocb *iocb, struct iov_iter *from)
27662771
if (rc <= 0)
27672772
goto out;
27682773

2769-
if (!cifs_find_lock_conflict(cfile, iocb->ki_pos, iov_iter_count(from),
2774+
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) &&
2775+
(cifs_find_lock_conflict(cfile, iocb->ki_pos, iov_iter_count(from),
27702776
server->vals->exclusive_lock_type, 0,
2771-
NULL, CIFS_WRITE_OP))
2772-
rc = netfs_buffered_write_iter_locked(iocb, from, NULL);
2773-
else
2777+
NULL, CIFS_WRITE_OP))) {
27742778
rc = -EACCES;
2779+
goto out;
2780+
}
2781+
2782+
rc = netfs_buffered_write_iter_locked(iocb, from, NULL);
2783+
27752784
out:
27762785
up_read(&cinode->lock_sem);
27772786
netfs_end_io_write(inode);

fs/smb/common/smb2pdu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,8 @@ struct create_context {
12161216
);
12171217
__u8 Buffer[];
12181218
} __packed;
1219+
static_assert(offsetof(struct create_context, Buffer) == sizeof(struct create_context_hdr),
1220+
"struct member likely outside of __struct_group()");
12191221

12201222
struct smb2_create_req {
12211223
struct smb2_hdr hdr;

0 commit comments

Comments
 (0)