Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH 0/2] smb/client: fix out-of-bounds read
@ 2026-05-02  8:34 Zisen Ye
  2026-05-02  8:34 ` [PATCH 1/2] smb/client: fix out-of-bounds read in smb2_compound_op() Zisen Ye
  2026-05-02  8:34 ` [PATCH 2/2] smb/client: fix out-of-bounds read in symlink_data() Zisen Ye
  0 siblings, 2 replies; 4+ messages in thread
From: Zisen Ye @ 2026-05-02  8:34 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, gregkh
  Cc: linux-cifs, Zisen Ye

Zisen Ye (2):
  smb/client: fix out-of-bounds read in smb2_compound_op()
  smb/client: fix out-of-bounds read in symlink_data()

 fs/smb/client/smb2inode.c | 3 +++
 fs/smb/client/smb2misc.c  | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] smb/client: fix out-of-bounds read in smb2_compound_op()
  2026-05-02  8:34 [PATCH 0/2] smb/client: fix out-of-bounds read Zisen Ye
@ 2026-05-02  8:34 ` Zisen Ye
  2026-05-02  8:45   ` Greg KH
  2026-05-02  8:34 ` [PATCH 2/2] smb/client: fix out-of-bounds read in symlink_data() Zisen Ye
  1 sibling, 1 reply; 4+ messages in thread
From: Zisen Ye @ 2026-05-02  8:34 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, gregkh
  Cc: linux-cifs, Zisen Ye, ChenXiaoSong

If a server sends a truncated response but a large OutputBufferLength, and
terminates the EA list early, check_wsl_eas() returns success without
validating that the entire OutputBufferLength fits within iov_len.

Then smb2_compound_op() does:
    memcpy(idata->wsl.eas, data[0], size[0]);

Where size[0] is OutputBufferLength. If iov_len is smaller than size[0],
memcpy can read beyond the end of the rsp_iov allocation and leak adjacent
kernel heap memory.

Link: https://lore.kernel.org/linux-cifs/d998240c-aca9-420d-9dbd-f5ba24af19e0@chenxiaosong.com/
Signed-off-by: Zisen Ye <zisenye@stu.xidian.edu.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/client/smb2inode.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c
index 286912616c73..a192d70cd29e 100644
--- a/fs/smb/client/smb2inode.c
+++ b/fs/smb/client/smb2inode.c
@@ -121,6 +121,9 @@ static int check_wsl_eas(struct kvec *rsp_iov)
 	ea = (void *)((u8 *)rsp_iov->iov_base +
 		      le16_to_cpu(rsp->OutputBufferOffset));
 	end = (u8 *)rsp_iov->iov_base + rsp_iov->iov_len;
+	if (ea + outlen > end)
+		return -EINVAL;
+
 	for (;;) {
 		if ((u8 *)ea > end - sizeof(*ea))
 			return -EINVAL;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] smb/client: fix out-of-bounds read in symlink_data()
  2026-05-02  8:34 [PATCH 0/2] smb/client: fix out-of-bounds read Zisen Ye
  2026-05-02  8:34 ` [PATCH 1/2] smb/client: fix out-of-bounds read in smb2_compound_op() Zisen Ye
@ 2026-05-02  8:34 ` Zisen Ye
  1 sibling, 0 replies; 4+ messages in thread
From: Zisen Ye @ 2026-05-02  8:34 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, gregkh
  Cc: linux-cifs, Zisen Ye, ChenXiaoSong

Since smb2_check_message() returns success without length validation for
the symlink error response, in symlink_data() it is possible for
iov->iov_len to be smaller than sizeof(struct smb2_err_rsp). If the buffer
only contains the base SMB2 header (64 bytes), accessing
err->ErrorContextCount (at offset 66) or err->ByteCount later in
symlink_data() will cause an out-of-bounds read.

Link: https://lore.kernel.org/linux-cifs/297d8d9b-adf7-42fd-a1c2-5b1f230032bc@chenxiaosong.com/
Signed-off-by: Zisen Ye <zisenye@stu.xidian.edu.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/client/smb2misc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/smb/client/smb2misc.c b/fs/smb/client/smb2misc.c
index 973fce3c959c..2a7355ce1a07 100644
--- a/fs/smb/client/smb2misc.c
+++ b/fs/smb/client/smb2misc.c
@@ -241,7 +241,8 @@ smb2_check_message(char *buf, unsigned int pdu_len, unsigned int len,
 	if (len != calc_len) {
 		/* create failed on symlink */
 		if (command == SMB2_CREATE_HE &&
-		    shdr->Status == STATUS_STOPPED_ON_SYMLINK)
+		    shdr->Status == STATUS_STOPPED_ON_SYMLINK &&
+		    len > calc_len)
 			return 0;
 		/* Windows 7 server returns 24 bytes more */
 		if (calc_len + 24 == len && command == SMB2_OPLOCK_BREAK_HE)
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] smb/client: fix out-of-bounds read in smb2_compound_op()
  2026-05-02  8:34 ` [PATCH 1/2] smb/client: fix out-of-bounds read in smb2_compound_op() Zisen Ye
@ 2026-05-02  8:45   ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2026-05-02  8:45 UTC (permalink / raw)
  To: Zisen Ye
  Cc: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, linux-cifs, ChenXiaoSong

On Sat, May 02, 2026 at 04:34:21PM +0800, Zisen Ye wrote:
> If a server sends a truncated response but a large OutputBufferLength, and
> terminates the EA list early, check_wsl_eas() returns success without
> validating that the entire OutputBufferLength fits within iov_len.
> 
> Then smb2_compound_op() does:
>     memcpy(idata->wsl.eas, data[0], size[0]);
> 
> Where size[0] is OutputBufferLength. If iov_len is smaller than size[0],
> memcpy can read beyond the end of the rsp_iov allocation and leak adjacent
> kernel heap memory.
> 
> Link: https://lore.kernel.org/linux-cifs/d998240c-aca9-420d-9dbd-f5ba24af19e0@chenxiaosong.com/
> Signed-off-by: Zisen Ye <zisenye@stu.xidian.edu.cn>
> Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> ---
>  fs/smb/client/smb2inode.c | 3 +++
>  1 file changed, 3 insertions(+)

No Fixes: tag?  No cc: stable?  Do you not want this backported
anywhere?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-02  8:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-02  8:34 [PATCH 0/2] smb/client: fix out-of-bounds read Zisen Ye
2026-05-02  8:34 ` [PATCH 1/2] smb/client: fix out-of-bounds read in smb2_compound_op() Zisen Ye
2026-05-02  8:45   ` Greg KH
2026-05-02  8:34 ` [PATCH 2/2] smb/client: fix out-of-bounds read in symlink_data() Zisen Ye

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox