Skip to content

Commit 86163b9

Browse files
pcacjrSasha Levin
authored andcommitted
smb: client: fix oops due to uninitialised var in smb2_unlink()
commit 048efe1 upstream. If SMB2_open_init() or SMB2_close_init() fails (e.g. reconnect), the iovs set @Rqst will be left uninitialised, hence calling SMB2_open_free(), SMB2_close_free() or smb2_set_related() on them will oops. Fix this by initialising @close_iov and @open_iov before setting them in @Rqst. Reported-by: Thiago Becker <tbecker@redhat.com> Fixes: 1cf9f2a ("smb: client: handle unlink(2) of files open by different clients") Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org> Cc: David Howells <dhowells@redhat.com> Cc: linux-cifs@vger.kernel.org Cc: stable@vger.kernel.org Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2ef0fc3 commit 86163b9

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

fs/smb/client/smb2inode.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,7 @@ smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
12051205
memset(resp_buftype, 0, sizeof(resp_buftype));
12061206
memset(rsp_iov, 0, sizeof(rsp_iov));
12071207

1208+
memset(open_iov, 0, sizeof(open_iov));
12081209
rqst[0].rq_iov = open_iov;
12091210
rqst[0].rq_nvec = ARRAY_SIZE(open_iov);
12101211

@@ -1229,14 +1230,15 @@ smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
12291230
creq = rqst[0].rq_iov[0].iov_base;
12301231
creq->ShareAccess = FILE_SHARE_DELETE_LE;
12311232

1233+
memset(&close_iov, 0, sizeof(close_iov));
12321234
rqst[1].rq_iov = &close_iov;
12331235
rqst[1].rq_nvec = 1;
12341236

12351237
rc = SMB2_close_init(tcon, server, &rqst[1],
12361238
COMPOUND_FID, COMPOUND_FID, false);
1237-
smb2_set_related(&rqst[1]);
12381239
if (rc)
12391240
goto err_free;
1241+
smb2_set_related(&rqst[1]);
12401242

12411243
if (retries) {
12421244
for (int i = 0; i < ARRAY_SIZE(rqst); i++)

0 commit comments

Comments
 (0)