public inbox for linux-cifs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] ksmbd: fix global-out-of-bounds in smb2_find_context_vals
@ 2023-05-05 15:11 Namjae Jeon
  2023-05-05 15:11 ` [PATCH 2/6] ksmbd: fix wrong UserName check in session_user Namjae Jeon
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Namjae Jeon @ 2023-05-05 15:11 UTC (permalink / raw)
  To: linux-cifs
  Cc: smfrench, senozhatsky, tom, atteh.mailbox, Namjae Jeon, Pumpkin

From: Pumpkin <cc85nod@gmail.com>

If the length of CreateContext name is larger than the tag, it will access
the data following the tag and trigger KASAN global-out-of-bounds.

Currently all CreateContext names are defined as string, so we can use
strcmp instead of memcmp to avoid the out-of-bound access.

[    7.995411] ==================================================================
[    7.995866] BUG: KASAN: global-out-of-bounds in memcmp+0x83/0xa0
[    7.996248] Read of size 8 at addr ffffffff8258d940 by task kworker/0:0/7
...
[    7.998191] Call Trace:
[    7.998358]  <TASK>
[    7.998503]  dump_stack_lvl+0x33/0x50
[    7.998743]  print_report+0xcc/0x620
[    7.999458]  kasan_report+0xae/0xe0
[    7.999895]  kasan_check_range+0x35/0x1b0
[    8.000152]  memcmp+0x83/0xa0
[    8.000347]  smb2_find_context_vals+0xf7/0x1e0
[    8.000635]  smb2_open+0x1df2/0x43a0
[    8.006398]  handle_ksmbd_work+0x274/0x810
[    8.006666]  process_one_work+0x419/0x760
[    8.006922]  worker_thread+0x2a2/0x6f0
[    8.007429]  kthread+0x160/0x190
[    8.007946]  ret_from_fork+0x1f/0x30
[    8.008181]  </TASK>

Signed-off-by: Pumpkin <cc85nod@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 fs/ksmbd/oplock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ksmbd/oplock.c b/fs/ksmbd/oplock.c
index 2e54ded4d92c..5e09834016bb 100644
--- a/fs/ksmbd/oplock.c
+++ b/fs/ksmbd/oplock.c
@@ -1492,7 +1492,7 @@ struct create_context *smb2_find_context_vals(void *open_req, const char *tag)
 			return ERR_PTR(-EINVAL);
 
 		name = (char *)cc + name_off;
-		if (memcmp(name, tag, name_len) == 0)
+		if (!strcmp(name, tag))
 			return cc;
 
 		remain_len -= next;
-- 
2.25.1


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

end of thread, other threads:[~2023-05-12 14:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-05 15:11 [PATCH 1/6] ksmbd: fix global-out-of-bounds in smb2_find_context_vals Namjae Jeon
2023-05-05 15:11 ` [PATCH 2/6] ksmbd: fix wrong UserName check in session_user Namjae Jeon
2023-05-06  3:10   ` Sergey Senozhatsky
2023-05-07  0:52     ` Namjae Jeon
2023-05-05 15:11 ` [PATCH 3/6] ksmbd: allocate one more byte for implied bcc[0] Namjae Jeon
2023-05-05 15:11 ` [PATCH 4/6] ksmbd: smb2: Allow messages padded to 8byte boundary Namjae Jeon
2023-05-05 15:11 ` [PATCH 5/6] ksmbd: remove unused ksmbd_tree_conn_share function Namjae Jeon
2023-05-08  1:07   ` Sergey Senozhatsky
2023-05-05 15:11 ` [PATCH 6/6] ksmbd: use kzalloc() instead of __GFP_ZERO Namjae Jeon
2023-05-08  1:06   ` Sergey Senozhatsky
2023-05-08  1:05 ` [PATCH 1/6] ksmbd: fix global-out-of-bounds in smb2_find_context_vals Sergey Senozhatsky
2023-05-08 12:58   ` Namjae Jeon
2023-05-09  3:05     ` Sergey Senozhatsky
     [not found]       ` <CAAn9K_vRCOtYZXRBDKY4GzPA-TyrQ_Zh-qssu51Vr6sTwg5w4w@mail.gmail.com>
2023-05-12 14:14         ` Namjae Jeon

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