cifs: Fix oops due to uninitialised variable
Subsystems (4)
PATCH 1/1 cifs: Fix oops due to uninitialised variable
Fix smb3_init_transform_rq() to initialise buffer to NULL before calling netfs_alloc_folioq_buffer() as netfs assumes it can append to the buffer it is given. Setting it to NULL means it should start a fresh buffer, but the value is currently undefined.
--- fs/smb/client/smb2ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/smb2ops.c +1 -1
@@ -4487,7 +4487,7 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst,for (int i =1 ; i < num_rqst; i++) {struct smb_rqst *old = &old_rq[i -1 ];struct smb_rqst *new = &new_rq[i]; -struct folio_queue *buffer; +struct folio_queue *buffer =NULL ;size_t size =iov_iter_count (&old->rq_iter); orig_len +=smb_rqst_len (server, old);
kernel test robot
build botFYI: kernel test robot notices the stable kernel rule is not satisfied.
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH] cifs: Fix oops due to uninitialised variable
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Steve French
Appliedmerged into cifs-2.6.git for-next
Quoted 31 lines · David Howells
Fix
smb3_init_transform_rq()to initialise buffer to NULL before callingnetfs_alloc_folioq_buffer()as netfs assumes it can append to the buffer it is given. Setting it to NULL means it should start a fresh buffer, but the value is currently undefined.Fixes a2906d3316fc ("cifs: Switch crypto buffer to use a folio_queue rather than an xarray")Signed-off-by David Howells <[email protected]>cc Steve French <[email protected]>cc Paulo Alcantara <[email protected]>--- fs/smb/client/smb2ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/smb/client/smb2ops.c +1
-1@@ -4487,7 +4487,7 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst,for (int i =1 ; i < num_rqst; i++) {struct smb_rqst *old = &old_rq[i -1 ];struct smb_rqst *new = &new_rq[i]; -struct folio_queue *buffer; +struct folio_queue *buffer =NULL ;size_t size =iov_iter_count (&old->rq_iter); orig_len +=smb_rqst_len (server, old);
Signature · 3 lines
Thanks, Steve
Hi David, Steve,
Quoted 4 lines · David Howells
Fix
smb3_init_transform_rq()to initialise buffer to NULL before callingnetfs_alloc_folioq_buffer()as netfs assumes it can append to the buffer it is given. Setting it to NULL means it should start a fresh buffer, but the value is currently undefined.
This patch was based on David's RFC series
"netfs: [WIP] Allow the use of MSG_SPLICE_PAGES and use netmem allocator", specifically patch 15/31 "cifs: Use netfs_alloc/free_folioq_buffer()", which were never merged.
Current code in smb3_init_transform_rq() initializes buffer with cifs_alloc_folioq_buffer() and NULL-checked right after:
Quoted 12 lines
...
struct folio_queue *buffer; size_t size = iov_iter_count(&old->rq_iter); orig_len += smb_rqst_len(server, old); new->rq_iov = old->rq_iov; new->rq_nvec = old->rq_nvec; if (size > 0) { buffer = cifs_alloc_folioq_buffer(size); if (!buffer) goto err_free;
Quoted 1 line
...
Sorry not catching this earlier, but this just got my attention because there's now a CVE for this non-bug/vulnerability
https://nvd.nist.gov/vuln/detail/CVE-2025-38737
I don't know what exactly can/should be done, but I thought I'd let you know.
Cheers,
Enzo
Quoted 25 lines
Fixes a2906d3316fc ("cifs: Switch crypto buffer to use a folio_queue rather than an xarray")Signed-off-by David Howells <[email protected]>cc Steve French <[email protected]>cc Paulo Alcantara <[email protected]>---
fs/smb/client/smb2ops.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)fs/smb/client/smb2ops.c +1
-1@@ -4487,7 +4487,7 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst,for (int i =1 ; i < num_rqst; i++) {struct smb_rqst *old = &old_rq[i -1 ];struct smb_rqst *new = &new_rq[i]; -struct folio_queue *buffer; +struct folio_queue *buffer =NULL ;size_t size =iov_iter_count (&old->rq_iter); orig_len +=smb_rqst_len (server, old);