Message ID | 20230404171658.917361-1-edumazet@google.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Johannes Berg |
Headers | show |
Series | [v2,net-next] mac80211_hwsim: fix potential NULL deref in hwsim_pmsr_report_nl() | expand |
On Tue, Apr 04, 2023 at 05:16:58PM +0000, Eric Dumazet wrote: > syzbot reported a NULL dereference caused by a missing check > in hwsim_pmsr_report_nl(), and bisected the issue to cited commit. > > v2: test the nlattr before using nla_data() on it (Simon Horman) > > general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN > KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] > CPU: 0 PID: 5084 Comm: syz-executor104 Not tainted 6.3.0-rc4-next-20230331-syzkaller #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023 > RIP: 0010:jhash+0x339/0x610 include/linux/jhash.h:95 > Code: 83 fd 01 0f 84 5f ff ff ff eb de 83 fd 05 74 3a e8 ac f5 71 fd 48 8d 7b 05 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 48 89 fa 83 e2 07 38 d0 7f 08 84 c0 0f 85 96 02 00 00 > RSP: 0018:ffffc90003abf298 EFLAGS: 00010202 > RAX: dffffc0000000000 RBX: 0000000000000004 RCX: 0000000000000000 > RDX: 0000000000000001 RSI: ffffffff84111ba4 RDI: 0000000000000009 > RBP: 0000000000000006 R08: 0000000000000005 R09: 000000000000000c > R10: 0000000000000006 R11: 0000000000000000 R12: 000000004d2c27cd > R13: 000000002bd9e6c2 R14: 000000002bd9e6c2 R15: 000000002bd9e6c2 > FS: 0000555556847300(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 000000000045ad50 CR3: 0000000078aa6000 CR4: 00000000003506f0 > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > Call Trace: > <TASK> > rht_key_hashfn include/linux/rhashtable.h:159 [inline] > __rhashtable_lookup include/linux/rhashtable.h:604 [inline] > rhashtable_lookup include/linux/rhashtable.h:646 [inline] > rhashtable_lookup_fast include/linux/rhashtable.h:672 [inline] > get_hwsim_data_ref_from_addr+0xb9/0x600 drivers/net/wireless/virtual/mac80211_hwsim.c:757 > hwsim_pmsr_report_nl+0xe7/0xd50 drivers/net/wireless/virtual/mac80211_hwsim.c:3764 > genl_family_rcv_msg_doit.isra.0+0x1e6/0x2d0 net/netlink/genetlink.c:968 > genl_family_rcv_msg net/netlink/genetlink.c:1048 [inline] > genl_rcv_msg+0x4ff/0x7e0 net/netlink/genetlink.c:1065 > netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2572 > genl_rcv+0x28/0x40 net/netlink/genetlink.c:1076 > netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline] > netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1365 > netlink_sendmsg+0x925/0xe30 net/netlink/af_netlink.c:1942 > sock_sendmsg_nosec net/socket.c:724 [inline] > sock_sendmsg+0xde/0x190 net/socket.c:747 > ____sys_sendmsg+0x71c/0x900 net/socket.c:2501 > ___sys_sendmsg+0x110/0x1b0 net/socket.c:2555 > __sys_sendmsg+0xf7/0x1c0 net/socket.c:2584 > do_syscall_x64 arch/x86/entry/common.c:50 [inline] > do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 > entry_SYSCALL_64_after_hwframe+0x63/0xcd > > Fixes: 2af3b2a631b1 ("mac80211_hwsim: add PMSR report support via virtio") > Reported-by: syzbot <syzkaller@googlegroups.com> > Signed-off-by: Eric Dumazet <edumazet@google.com> > Cc: Jaewan Kim <jaewan@google.com> > Cc: Johannes Berg <johannes.berg@intel.com> Thanks Eric, Reviewed-by: Simon Horman <simon.horman@corigine.com>
On Wed, Apr 5, 2023 at 2:39 AM Simon Horman <simon.horman@corigine.com> wrote: > > On Tue, Apr 04, 2023 at 05:16:58PM +0000, Eric Dumazet wrote: > > syzbot reported a NULL dereference caused by a missing check > > in hwsim_pmsr_report_nl(), and bisected the issue to cited commit. > > > > v2: test the nlattr before using nla_data() on it (Simon Horman) > > > > general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN > > KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] > > CPU: 0 PID: 5084 Comm: syz-executor104 Not tainted 6.3.0-rc4-next-20230331-syzkaller #0 > > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023 > > RIP: 0010:jhash+0x339/0x610 include/linux/jhash.h:95 > > Code: 83 fd 01 0f 84 5f ff ff ff eb de 83 fd 05 74 3a e8 ac f5 71 fd 48 8d 7b 05 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 48 89 fa 83 e2 07 38 d0 7f 08 84 c0 0f 85 96 02 00 00 > > RSP: 0018:ffffc90003abf298 EFLAGS: 00010202 > > RAX: dffffc0000000000 RBX: 0000000000000004 RCX: 0000000000000000 > > RDX: 0000000000000001 RSI: ffffffff84111ba4 RDI: 0000000000000009 > > RBP: 0000000000000006 R08: 0000000000000005 R09: 000000000000000c > > R10: 0000000000000006 R11: 0000000000000000 R12: 000000004d2c27cd > > R13: 000000002bd9e6c2 R14: 000000002bd9e6c2 R15: 000000002bd9e6c2 > > FS: 0000555556847300(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000 > > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > > CR2: 000000000045ad50 CR3: 0000000078aa6000 CR4: 00000000003506f0 > > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > > Call Trace: > > <TASK> > > rht_key_hashfn include/linux/rhashtable.h:159 [inline] > > __rhashtable_lookup include/linux/rhashtable.h:604 [inline] > > rhashtable_lookup include/linux/rhashtable.h:646 [inline] > > rhashtable_lookup_fast include/linux/rhashtable.h:672 [inline] > > get_hwsim_data_ref_from_addr+0xb9/0x600 drivers/net/wireless/virtual/mac80211_hwsim.c:757 > > hwsim_pmsr_report_nl+0xe7/0xd50 drivers/net/wireless/virtual/mac80211_hwsim.c:3764 > > genl_family_rcv_msg_doit.isra.0+0x1e6/0x2d0 net/netlink/genetlink.c:968 > > genl_family_rcv_msg net/netlink/genetlink.c:1048 [inline] > > genl_rcv_msg+0x4ff/0x7e0 net/netlink/genetlink.c:1065 > > netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2572 > > genl_rcv+0x28/0x40 net/netlink/genetlink.c:1076 > > netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline] > > netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1365 > > netlink_sendmsg+0x925/0xe30 net/netlink/af_netlink.c:1942 > > sock_sendmsg_nosec net/socket.c:724 [inline] > > sock_sendmsg+0xde/0x190 net/socket.c:747 > > ____sys_sendmsg+0x71c/0x900 net/socket.c:2501 > > ___sys_sendmsg+0x110/0x1b0 net/socket.c:2555 > > __sys_sendmsg+0xf7/0x1c0 net/socket.c:2584 > > do_syscall_x64 arch/x86/entry/common.c:50 [inline] > > do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 > > entry_SYSCALL_64_after_hwframe+0x63/0xcd > > > > Fixes: 2af3b2a631b1 ("mac80211_hwsim: add PMSR report support via virtio") > > Reported-by: syzbot <syzkaller@googlegroups.com> > > Signed-off-by: Eric Dumazet <edumazet@google.com> > > Cc: Jaewan Kim <jaewan@google.com> > > Cc: Johannes Berg <johannes.berg@intel.com> > > Thanks Eric, > > Reviewed-by: Simon Horman <simon.horman@corigine.com> Reviewed-by: Jaewan Kim <jaewan@google.com>
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim.c index f446d8f6e1f6e1df108db00e898fa02970162585..2211fa58fe4140177d53232f4ceafee57185d057 100644 --- a/drivers/net/wireless/virtual/mac80211_hwsim.c +++ b/drivers/net/wireless/virtual/mac80211_hwsim.c @@ -3760,6 +3760,9 @@ static int hwsim_pmsr_report_nl(struct sk_buff *msg, struct genl_info *info) int err; int rem; + if (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]) + return -EINVAL; + src = nla_data(info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]); data = get_hwsim_data_ref_from_addr(src); if (!data)
syzbot reported a NULL dereference caused by a missing check in hwsim_pmsr_report_nl(), and bisected the issue to cited commit. v2: test the nlattr before using nla_data() on it (Simon Horman) general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] CPU: 0 PID: 5084 Comm: syz-executor104 Not tainted 6.3.0-rc4-next-20230331-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023 RIP: 0010:jhash+0x339/0x610 include/linux/jhash.h:95 Code: 83 fd 01 0f 84 5f ff ff ff eb de 83 fd 05 74 3a e8 ac f5 71 fd 48 8d 7b 05 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 48 89 fa 83 e2 07 38 d0 7f 08 84 c0 0f 85 96 02 00 00 RSP: 0018:ffffc90003abf298 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: 0000000000000004 RCX: 0000000000000000 RDX: 0000000000000001 RSI: ffffffff84111ba4 RDI: 0000000000000009 RBP: 0000000000000006 R08: 0000000000000005 R09: 000000000000000c R10: 0000000000000006 R11: 0000000000000000 R12: 000000004d2c27cd R13: 000000002bd9e6c2 R14: 000000002bd9e6c2 R15: 000000002bd9e6c2 FS: 0000555556847300(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000045ad50 CR3: 0000000078aa6000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> rht_key_hashfn include/linux/rhashtable.h:159 [inline] __rhashtable_lookup include/linux/rhashtable.h:604 [inline] rhashtable_lookup include/linux/rhashtable.h:646 [inline] rhashtable_lookup_fast include/linux/rhashtable.h:672 [inline] get_hwsim_data_ref_from_addr+0xb9/0x600 drivers/net/wireless/virtual/mac80211_hwsim.c:757 hwsim_pmsr_report_nl+0xe7/0xd50 drivers/net/wireless/virtual/mac80211_hwsim.c:3764 genl_family_rcv_msg_doit.isra.0+0x1e6/0x2d0 net/netlink/genetlink.c:968 genl_family_rcv_msg net/netlink/genetlink.c:1048 [inline] genl_rcv_msg+0x4ff/0x7e0 net/netlink/genetlink.c:1065 netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2572 genl_rcv+0x28/0x40 net/netlink/genetlink.c:1076 netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline] netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1365 netlink_sendmsg+0x925/0xe30 net/netlink/af_netlink.c:1942 sock_sendmsg_nosec net/socket.c:724 [inline] sock_sendmsg+0xde/0x190 net/socket.c:747 ____sys_sendmsg+0x71c/0x900 net/socket.c:2501 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2555 __sys_sendmsg+0xf7/0x1c0 net/socket.c:2584 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Fixes: 2af3b2a631b1 ("mac80211_hwsim: add PMSR report support via virtio") Reported-by: syzbot <syzkaller@googlegroups.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Jaewan Kim <jaewan@google.com> Cc: Johannes Berg <johannes.berg@intel.com> --- drivers/net/wireless/virtual/mac80211_hwsim.c | 3 +++ 1 file changed, 3 insertions(+)