diff mbox series

Add string check in netlink_ack_tlv_fill

Message ID 20241114-fix-netlink_ack_tlv_fill-v1-1-47798af4ac96@iiitd.ac.in (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Add string check in netlink_ack_tlv_fill | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch warning WARNING: The commit message has 'syzkaller', perhaps it also needs a 'Fixes:' tag?
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 7 this patch: 7
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-11-15--21-00 (tests: 789)

Commit Message

Manas via B4 Relay Nov. 13, 2024, 10:44 p.m. UTC
From: Manas <manas18244@iiitd.ac.in>

netlink_ack_tlv_fill crashes when in_skb->data is an empty string. This
adds a check to prevent it.

Reported-by: syzbot+d4373fa8042c06cefa84@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d4373fa8042c06cefa84
Signed-off-by: Manas <manas18244@iiitd.ac.in>
---
netlink_ack_tlv_fill crashes when in_skb->data is an empty string. This
adds a check to prevent it.
---
 net/netlink/af_netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
base-commit: 2d5404caa8c7bb5c4e0435f94b28834ae5456623
change-id: 20241114-fix-netlink_ack_tlv_fill-14db336fd515

Best regards,

Comments

Kuniyuki Iwashima Nov. 14, 2024, 12:02 a.m. UTC | #1
> [PATCH] Add string check in netlink_ack_tlv_fill

Please specify the target tree and add prefix like

  [PATCH net v2] netlink: Add string...

We use net.git for fixes and net-next.git for others.
https://www.kernel.org/doc/html/v6.11-rc6/process/maintainer-netdev.html


From: Manas via B4 Relay <devnull+manas18244.iiitd.ac.in@kernel.org>
Date: Thu, 14 Nov 2024 04:14:25 +0530
> From: Manas <manas18244@iiitd.ac.in>
> 
> netlink_ack_tlv_fill crashes when in_skb->data is an empty string. This
> adds a check to prevent it.
>


Fixes: tag is needed here.

> Reported-by: syzbot+d4373fa8042c06cefa84@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=d4373fa8042c06cefa84
> Signed-off-by: Manas <manas18244@iiitd.ac.in>
> ---
> netlink_ack_tlv_fill crashes when in_skb->data is an empty string. This
> adds a check to prevent it.

You need not duplicate commit message here.

under --- you can add extra info that will not be included in the
actual commit, e.g. changes between each version of patches.


> ---
>  net/netlink/af_netlink.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> index 0a9287fadb47a2afaf0babe675738bc43051c5a7..ea205a4f81e9755a229d46a7e617ce0c090fe5e3 100644
> --- a/net/netlink/af_netlink.c
> +++ b/net/netlink/af_netlink.c
> @@ -2205,7 +2205,7 @@ netlink_ack_tlv_fill(struct sk_buff *in_skb, struct sk_buff *skb,
>  	if (!err)
>  		return;
>  
> -	if (extack->bad_attr &&
> +	if (extack->bad_attr && strlen(in_skb->data) &&
>  	    !WARN_ON((u8 *)extack->bad_attr < in_skb->data ||
>  		     (u8 *)extack->bad_attr >= in_skb->data + in_skb->len))
>  		WARN_ON(nla_put_u32(skb, NLMSGERR_ATTR_OFFS,
> 
> ---
> base-commit: 2d5404caa8c7bb5c4e0435f94b28834ae5456623
> change-id: 20241114-fix-netlink_ack_tlv_fill-14db336fd515
> 
> Best regards,
> -- 
> Manas <manas18244@iiitd.ac.in>
>
diff mbox series

Patch

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 0a9287fadb47a2afaf0babe675738bc43051c5a7..ea205a4f81e9755a229d46a7e617ce0c090fe5e3 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2205,7 +2205,7 @@  netlink_ack_tlv_fill(struct sk_buff *in_skb, struct sk_buff *skb,
 	if (!err)
 		return;
 
-	if (extack->bad_attr &&
+	if (extack->bad_attr && strlen(in_skb->data) &&
 	    !WARN_ON((u8 *)extack->bad_attr < in_skb->data ||
 		     (u8 *)extack->bad_attr >= in_skb->data + in_skb->len))
 		WARN_ON(nla_put_u32(skb, NLMSGERR_ATTR_OFFS,