diff options
author | Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> | 2022-04-13 04:42:51 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-04-20 09:08:31 +0200 |
commit | 1316c28569a80ab3596eeab05bf5e01991e7e739 (patch) | |
tree | 8a3425a702ccb0a8a0ac7586c2f57a5336b8b8ef /fs/cifs | |
parent | 9d243aff5f7e6b04e907c617426bbdf26e996ac8 (diff) | |
download | linux-rt-1316c28569a80ab3596eeab05bf5e01991e7e739.tar.gz |
cifs: potential buffer overflow in handling symlinks
[ Upstream commit 64c4a37ac04eeb43c42d272f6e6c8c12bfcf4304 ]
Smatch printed a warning:
arch/x86/crypto/poly1305_glue.c:198 poly1305_update_arch() error:
__memcpy() 'dctx->buf' too small (16 vs u32max)
It's caused because Smatch marks 'link_len' as untrusted since it comes
from sscanf(). Add a check to ensure that 'link_len' is not larger than
the size of the 'link_str' buffer.
Fixes: c69c1b6eaea1 ("cifs: implement CIFSParseMFSymlink()")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/link.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/cifs/link.c b/fs/cifs/link.c index 9451a7f6893d..a89b8ff82040 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c @@ -97,6 +97,9 @@ parse_mf_symlink(const u8 *buf, unsigned int buf_len, unsigned int *_link_len, if (rc != 1) return -EINVAL; + if (link_len > CIFS_MF_SYMLINK_LINK_MAXLEN) + return -EINVAL; + rc = symlink_hash(link_len, link_str, md5_hash); if (rc) { cifs_dbg(FYI, "%s: MD5 hash failure: %d\n", __func__, rc); |