linux/fs/smb/client
Gustavo A. R. Silva e48b4d77fc smb: client: Fix -Wstringop-overflow issues
commit f1f047bd7c upstream.

pSMB->hdr.Protocol is an array of size 4 bytes, hence when the compiler
analyzes this line of code

	parm_data = ((char *) &pSMB->hdr.Protocol) + offset;

it legitimately complains about the fact that offset points outside the
bounds of the array. Notice that the compiler gives priority to the object
as an array, rather than merely the address of one more byte in a structure
to wich offset should be added (which seems to be the actual intention of
the original implementation).

Fix this by explicitly instructing the compiler to treat the code as a
sequence of bytes in struct smb_com_transaction2_spi_req, and not as an
array accessed through pointer notation.

Notice that ((char *)pSMB) + sizeof(pSMB->hdr.smb_buf_length) points to
the same address as ((char *) &pSMB->hdr.Protocol), therefore this results
in no differences in binary output.

Fixes the following -Wstringop-overflow warnings when built s390
architecture with defconfig (GCC 13):
  CC [M]  fs/smb/client/cifssmb.o
In function 'cifs_init_ace',
    inlined from 'posix_acl_to_cifs' at fs/smb/client/cifssmb.c:3046:3,
    inlined from 'cifs_do_set_acl' at fs/smb/client/cifssmb.c:3191:15:
fs/smb/client/cifssmb.c:2987:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 2987 |         cifs_ace->cifs_e_perm = local_ace->e_perm;
      |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from fs/smb/client/cifssmb.c:27:
fs/smb/client/cifspdu.h: In function 'cifs_do_set_acl':
fs/smb/client/cifspdu.h:384:14: note: at offset [7, 11] into destination object 'Protocol' of size 4
  384 |         __u8 Protocol[4];
      |              ^~~~~~~~
In function 'cifs_init_ace',
    inlined from 'posix_acl_to_cifs' at fs/smb/client/cifssmb.c:3046:3,
    inlined from 'cifs_do_set_acl' at fs/smb/client/cifssmb.c:3191:15:
fs/smb/client/cifssmb.c:2988:30: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 2988 |         cifs_ace->cifs_e_tag =  local_ace->e_tag;
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
fs/smb/client/cifspdu.h: In function 'cifs_do_set_acl':
fs/smb/client/cifspdu.h:384:14: note: at offset [6, 10] into destination object 'Protocol' of size 4
  384 |         __u8 Protocol[4];
      |              ^~~~~~~~

This helps with the ongoing efforts to globally enable
-Wstringop-overflow.

Link: https://github.com/KSPP/linux/issues/310
Fixes: dc1af4c4b4 ("cifs: implement set acl method")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2023-07-23 13:54:13 +02:00
..
asn1.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cached_dir.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cached_dir.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifs_debug.c smb: client: fix shared DFS root mounts with different prefixes 2023-07-19 16:36:24 +02:00
cifs_debug.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifs_dfs_ref.c smb: client: fix parsing of source mount option 2023-07-23 13:53:50 +02:00
cifs_fs_sb.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifs_ioctl.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifs_spnego.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifs_spnego.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifs_spnego_negtokeninit.asn1 smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifs_swn.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifs_swn.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifs_unicode.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifs_unicode.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifs_uniupr.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifsacl.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifsacl.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifsencrypt.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifsfs.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifsfs.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifsglob.h smb: client: fix shared DFS root mounts with different prefixes 2023-07-19 16:36:24 +02:00
cifspdu.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifsproto.h smb: client: fix parsing of source mount option 2023-07-23 13:53:50 +02:00
cifsroot.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
cifssmb.c smb: client: Fix -Wstringop-overflow issues 2023-07-23 13:54:13 +02:00
connect.c smb: client: fix shared DFS root mounts with different prefixes 2023-07-19 16:36:24 +02:00
dfs.c smb: client: fix parsing of source mount option 2023-07-23 13:53:50 +02:00
dfs.h smb: client: fix shared DFS root mounts with different prefixes 2023-07-19 16:36:24 +02:00
dfs_cache.c smb: client: fix shared DFS root mounts with different prefixes 2023-07-19 16:36:24 +02:00
dfs_cache.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
dir.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
dns_resolve.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
dns_resolve.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
export.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
file.c cifs: if deferred close is disabled then close files immediately 2023-07-23 13:54:10 +02:00
fs_context.c smb: client: fix parsing of source mount option 2023-07-23 13:53:50 +02:00
fs_context.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
fscache.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
fscache.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
inode.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
ioctl.c cifs: address unused variable warning 2023-05-27 03:33:23 -05:00
Kconfig smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
link.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
Makefile smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
misc.c smb: client: fix parsing of source mount option 2023-07-23 13:53:50 +02:00
netlink.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
netlink.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
netmisc.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
nterr.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
nterr.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
ntlmssp.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
readdir.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
rfc1002pdu.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
sess.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
smb1ops.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
smb2file.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
smb2glob.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
smb2inode.c smb: client: fix broken file attrs with nodfs mounts 2023-07-19 16:36:24 +02:00
smb2maperror.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
smb2misc.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
smb2ops.c cifs: do all necessary checks for credits within or before locking 2023-07-19 16:36:24 +02:00
smb2pdu.c cifs: fix max_credits implementation 2023-06-11 20:52:49 -05:00
smb2pdu.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
smb2proto.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
smb2status.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
smb2transport.c cifs: fix session state check in smb2_find_smb_ses 2023-07-23 13:53:50 +02:00
smbdirect.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
smbdirect.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
smbencrypt.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
smberr.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
trace.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
trace.h smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
transport.c cifs: do all necessary checks for credits within or before locking 2023-07-19 16:36:24 +02:00
unc.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
winucase.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00
xattr.c smb: move client and server files to common directory fs/smb 2023-05-24 16:29:21 -05:00