Skip to contentSkip to conversation

fs/smb/server: fix off-by-one in ksmbd_nl_policy

PATCH In review Kyle Zeng 2 participants 2 messages Jan 23, 2024 – Jan 24, 2024

Subsystems (2)
lore
Share & tools
lore

Kyle Zeng

author
#0 lore raw

PATCH 1/1 fs/smb/server: fix off-by-one in ksmbd_nl_policy

The size of the policy array should be one larger than genl_family.maxattr, or it will lead to an off-by-one read during nlattr parsing because gennl_family.maxattr should be the *largest expected* value

---
 fs/smb/server/transport_ipc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/server/transport_ipc.c +1 -1
index b49d47bdafc..185db4d7f2b 100644
@@ -74,7 +74,7 @@ static int handle_unsupported_event(struct sk_buff *skb, struct genl_info *info)
 static int handle_generic_event(struct sk_buff *skb, struct genl_info *info);
 static int ksmbd_ipc_heartbeat_request(void);
 
-static const struct nla_policy ksmbd_nl_policy[KSMBD_EVENT_MAX] = {
+static const struct nla_policy ksmbd_nl_policy[KSMBD_EVENT_MAX + 1] = {
 	[KSMBD_EVENT_UNSPEC] = {
 		.len = 0,
 	},
Signature · 1 line
2.34.1
maintainer
#1 lore raw

2024-01-24 5:50 GMT+09:00, Kyle Zeng <[email protected]>:

Quoted 15 lines

The size of the policy array should be one larger than genl_family.maxattr, or it
will lead to an off-by-one read during nlattr parsing because gennl_family.maxattr should be the *largest expected* value

---
 fs/smb/server/transport_ipc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/server/transport_ipc.c +0 -0
index b49d47bdafc..185db4d7f2b 100644

fs/smb/server/transport_ipc.c static int handle_unsupported_event(struct sk_buff *skb, · line 79

Quoted 7 lines
fs/smb/server/transport_ipc.c +1 -1
@@ -74,7 +74,7 @@ static int handle_unsupported_event(struct sk_buff *skb,
 struct genl_info *info)
 static int handle_generic_event(struct sk_buff *skb, struct genl_info
 *info);
 static int ksmbd_ipc_heartbeat_request(void);
 
-static const struct nla_policy ksmbd_nl_policy[KSMBD_EVENT_MAX] = {
+static const struct nla_policy ksmbd_nl_policy[KSMBD_EVENT_MAX + 1] = {'

Have you checked the following patch ? And can this patch replace the patch below?

https://lore.kernel.org/lkml/[email protected]/t/

Thanks.

Quoted 7 lines
fs/smb/server/transport_ipc.c +0 -0
 	[KSMBD_EVENT_UNSPEC] = {
fs/smb/server/transport_ipc.c +0 -1
 		.len = 0,
 	},
--

2.34.1