ksmbd: fix slab-out-of-bounds in smb_strndup_from_utf16()
authorNamjae Jeon <linkinjeon@kernel.org>
Wed, 20 Dec 2023 06:52:11 +0000 (15:52 +0900)
committerSteve French <stfrench@microsoft.com>
Thu, 28 Dec 2023 04:55:36 +0000 (22:55 -0600)
commitd10c77873ba1e9e6b91905018e29e196fd5f863d
treea12180e41c83d8a43e1e1ea4ff7ab02208c5856e
parentceb6a6f023fd3e8b07761ed900352ef574010bcb
ksmbd: fix slab-out-of-bounds in smb_strndup_from_utf16()

If ->NameOffset/Length is bigger than ->CreateContextsOffset/Length,
ksmbd_check_message doesn't validate request buffer it correctly.
So slab-out-of-bounds warning from calling smb_strndup_from_utf16()
in smb2_open() could happen. If ->NameLength is non-zero, Set the larger
of the two sums (Name and CreateContext size) as the offset and length of
the data area.

Reported-by: Yang Chaoming <lometsj@live.com>
Cc: stable@vger.kernel.org
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/smb2misc.c