]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ksmbd: prevent out-of-bounds stream writes by validating *pos
authorNorbert Szetei <norbert@doyensec.com>
Thu, 1 May 2025 23:21:58 +0000 (08:21 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 18 May 2025 06:24:04 +0000 (08:24 +0200)
commit04c8a38c60346bb5a7c49b276de7233f703ce9cb
tree02b9a750e2f66675efd14151449bea06b39f3f80
parent6ee551672c8cf36108b0cfba92ec0c7c28ac3439
ksmbd: prevent out-of-bounds stream writes by validating *pos

commit 0ca6df4f40cf4c32487944aaf48319cb6c25accc upstream.

ksmbd_vfs_stream_write() did not validate whether the write offset
(*pos) was within the bounds of the existing stream data length (v_len).
If *pos was greater than or equal to v_len, this could lead to an
out-of-bounds memory write.

This patch adds a check to ensure *pos is less than v_len before
proceeding. If the condition fails, -EINVAL is returned.

Cc: stable@vger.kernel.org
Signed-off-by: Norbert Szetei <norbert@doyensec.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/smb/server/vfs.c