Skip to content

Commit f69b018

Browse files
keessmfrench
authored andcommitted
smb: client: memcpy() with surrounding object base address
Like commit f1f047b ("smb: client: Fix -Wstringop-overflow issues"), adjust the memcpy() destination address to be based off the surrounding object rather than based off the 4-byte "Protocol" member. This avoids a build-time warning when compiling under CONFIG_FORTIFY_SOURCE with GCC 15: In function 'fortify_memcpy_chk', inlined from 'CIFSSMBSetPathInfo' at ../fs/smb/client/cifssmb.c:5358:2: ../include/linux/fortify-string.h:571:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] 571 | __write_overflow_field(p_size_field, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 6c9903c commit f69b018

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/smb/client/cifssmb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5343,7 +5343,7 @@ CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
53435343
param_offset = offsetof(struct smb_com_transaction2_spi_req,
53445344
InformationLevel) - 4;
53455345
offset = param_offset + params;
5346-
data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
5346+
data_offset = (char *)pSMB + offsetof(typeof(*pSMB), hdr.Protocol) + offset;
53475347
pSMB->ParameterOffset = cpu_to_le16(param_offset);
53485348
pSMB->DataOffset = cpu_to_le16(offset);
53495349
pSMB->SetupCount = 1;

0 commit comments

Comments
 (0)