From: Fredric Cover <fredric.cover.lkernel@gmail.com>
To: Steve French <sfrench@samba.org>, Paulo Alcantara <pc@manguebit.com>
Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org,
Fredric Cover <fredric.cover.lkernel@gmail.com>
Subject: [PATCH RFC] smb: client: fix NULL pointer dereference in smb2_compound_op
Date: Mon, 27 Apr 2026 19:51:10 -0700 [thread overview]
Message-ID: <20260428025110.38825-1-FredTheDude@proton.me> (raw)
From: Fredric Cover <fredric.cover.lkernel@gmail.com>
When a valid cfile is passed to smb2_compound_op, the code uses a
goto to jump to the 'after_open' label. This bypasses the
initialization of rqst[0] by SMB2_open_init().
However, the 'finished' cleanup block unconditionally attempts to
call SMB2_open_free() on rqst[0]. If SMB2_open_init() was skipped,
rqst[0].rq_iov is NULL, leading to a NULL pointer dereference.
Check for a valid rq_iov before attempting to free the request
to prevent the crash in handle-reuse scenarios.
Signed-off-by: Fredric Cover <fredric.cover.lkernel@gmail.com>
---
I am new to writing code for the Linux kernel.
Please be patient with me and feel free to point out any
obvious mistakes I made.
I tested this patch in a user-space skeleton clone using ASan.
I only have access to a shallow clone and cannot find the
original commit for the 'Fixes:' line.
---
fs/smb/client/smb2inode.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c
index c6dd282fc..aed96eeba 100644
--- a/fs/smb/client/smb2inode.c
+++ b/fs/smb/client/smb2inode.c
@@ -552,7 +552,13 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
finished:
num_rqst = 0;
- SMB2_open_free(&rqst[num_rqst++]);
+ /*
+ * If cfile was passed, the open was skipped; check rq_iov
+ * to ensure we don't try to dereference a NULL pointer.
+ */
+ if (rqst[num_rqst].rq_iov)
+ SMB2_open_free(&rqst[num_rqst]);
+ num_rqst++;
if (rc == -EREMCHG) {
pr_warn_once("server share %s deleted\n", tcon->tree_name);
tcon->need_reconnect = true;
--
2.43.0
next reply other threads:[~2026-04-28 2:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 2:51 Fredric Cover [this message]
2026-04-30 0:34 ` [PATCH RFC] smb: client: fix NULL pointer dereference in smb2_compound_op Fredric Cover
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260428025110.38825-1-FredTheDude@proton.me \
--to=fredric.cover.lkernel@gmail.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.com \
--cc=sfrench@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).