* WARNING in nla_get_range_unsigned [not found] <CAO4mrffa_3PhjfA9hxTq_U9GjC++0suGnme9oNcKE=Gn+g1iRg@mail.gmail.com> @ 2022-12-17 9:24 ` Wei Chen 2022-12-17 14:19 ` Ido Schimmel 1 sibling, 0 replies; 6+ messages in thread From: Wei Chen @ 2022-12-17 9:24 UTC (permalink / raw) To: linux-kernel, netdev Dear Linux Developers, Recently, when using our tool to fuzz kernel, the following crash was triggered. Although this crash has been reported by syzbot https://syzkaller.appspot.com/bug?id=32e20c07949c6d6006f26466022469e33ae69108 and fixed in commit netlink: policy: correct validation type check https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c30a3c957c885e618ddffc065f888be4f8d5a9bd, it still happens in the latest kernel version. HEAD commit: 76dcd734eca git tree: linux-next compiler: clang 12.0.0 console output: https://drive.google.com/file/d/1reeOfFkfJp4-GUz_uMTh-uWXPLBJDcA6/view?usp=share_link kernel config: https://drive.google.com/file/d/1jH4qV5XblPADvMDUlvS7DwtW0FroMoVB/view?usp=share_link syz repro: https://drive.google.com/file/d/1Ong8vQn675RFU7R1O5HfiwWxp4UhnaIF/view?usp=share_link IMPORTANT: if you fix the bug, please add the following tag to the commit: Reported-by: Wei Chen <harperchen1110@gmail.com> ------------[ cut here ]------------ WARNING: CPU: 0 PID: 17743 at lib/nlattr.c:118 nla_get_range_unsigned+0x1d8/0x1e0 lib/nlattr.c:117 Modules linked in: CPU: 0 PID: 17743 Comm: syz-executor.0 Not tainted 6.1.0-rc8 #3 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-48-gd9c812dda519-prebuilt.qemu.org 04/01/2014 RIP: 0010:nla_get_range_unsigned+0x1d8/0x1e0 lib/nlattr.c:117 Code: 8d ff 49 8b 75 08 ba 10 00 00 00 4c 89 f7 e8 0f d8 f8 02 5b 41 5c 41 5d 41 5e 41 5f 5d c3 e8 0f 57 7a ff eb 05 e8 08 57 7a ff <0f> 0b e9 a9 fe ff ff 90 55 41 57 41 56 41 54 53 49 89 f6 49 89 fc RSP: 0018:ffffc90002df39b8 EFLAGS: 00010287 RAX: ffffffff81ad2f51 RBX: ffffffff85364d28 RCX: 0000000000040000 RDX: ffffc90000add000 RSI: 0000000000000268 RDI: 0000000000000269 RBP: 000000000000f940 R08: ffffffff81ad2dd8 R09: 0000000000000000 R10: 0001ffffffffffff R11: ffff888045136780 R12: ffff88803e174000 R13: ffffffff85364d20 R14: ffffc90002df3a30 R15: ffffffff85364d21 FS: 00007fab1e5c8700(0000) GS:ffff88807dc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000073f8d0 CR3: 000000004a789000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000600 Call Trace: <TASK> __netlink_policy_dump_write_attr+0x23d/0x990 net/netlink/policy.c:310 netlink_policy_dump_write_attr+0x22/0x30 net/netlink/policy.c:411 netlink_ack_tlv_fill net/netlink/af_netlink.c:2454 [inline] netlink_ack+0x546/0x760 net/netlink/af_netlink.c:2506 netlink_rcv_skb+0x1b7/0x240 net/netlink/af_netlink.c:2546 rtnetlink_rcv+0x18/0x20 net/core/rtnetlink.c:6109 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline] netlink_unicast+0x5e9/0x6b0 net/netlink/af_netlink.c:1345 netlink_sendmsg+0x739/0x860 net/netlink/af_netlink.c:1921 sock_sendmsg_nosec net/socket.c:714 [inline] sock_sendmsg net/socket.c:734 [inline] ____sys_sendmsg+0x38f/0x500 net/socket.c:2482 ___sys_sendmsg net/socket.c:2536 [inline] __sys_sendmsg+0x197/0x230 net/socket.c:2565 __do_sys_sendmsg net/socket.c:2574 [inline] __se_sys_sendmsg net/socket.c:2572 [inline] __x64_sys_sendmsg+0x42/0x50 net/socket.c:2572 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x4697f9 Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fab1e5c7c48 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 000000000077bf80 RCX: 00000000004697f9 RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000003 RBP: 00000000004d29e9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 000000000077bf80 R13: 0000000000000000 R14: 000000000077bf80 R15: 00007ffd7c0e6920 </TASK> ---[ end trace 0000000000000000 ]--- Best, Wei ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: WARNING in nla_get_range_unsigned [not found] <CAO4mrffa_3PhjfA9hxTq_U9GjC++0suGnme9oNcKE=Gn+g1iRg@mail.gmail.com> 2022-12-17 9:24 ` WARNING in nla_get_range_unsigned Wei Chen @ 2022-12-17 14:19 ` Ido Schimmel 1 sibling, 0 replies; 6+ messages in thread From: Ido Schimmel @ 2022-12-17 14:19 UTC (permalink / raw) To: Wei Chen, johannes.berg Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, netdev, Paolo Abeni, linux-kernel, syzkaller-bugs, syzbot On Sat, Dec 17, 2022 at 05:21:24PM +0800, Wei Chen wrote: > Dear Linux Developers, > > Recently, when using our tool to fuzz kernel, the following crash was > triggered. Although this crash has been reported by syzbot > https://syzkaller.appspot.com/bug?id=32e20c07949c6d6006f26466022469e33ae69108 > and fixed in commit netlink: policy: correct validation type check > <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c30a3c957c885e618ddffc065f888be4f8d5a9bd>, > it still happens in the latest kernel version. > > HEAD commit: 76dcd734eca > git tree: linux-next > compiler: clang 12.0.0 > console output: > https://drive.google.com/file/d/1reeOfFkfJp4-GUz_uMTh-uWXPLBJDcA6/view?usp=share_link > kernel config: > https://drive.google.com/file/d/1jH4qV5XblPADvMDUlvS7DwtW0FroMoVB/view?usp=share_link > syz repro: > https://drive.google.com/file/d/1Ong8vQn675RFU7R1O5HfiwWxp4UhnaIF/view?usp=share_link Can be reproduced with: # tc action add mpls push label 3 Assuming you patch iproute2 to encode a wrong label length. For example: diff --git a/tc/m_mpls.c b/tc/m_mpls.c index 9b39d8533c21..2a43ca6c4dd3 100644 --- a/tc/m_mpls.c +++ b/tc/m_mpls.c @@ -191,7 +191,7 @@ static int parse_mpls(struct action_util *a, int *argc_p, char ***argv_p, tail = addattr_nest(n, MAX_MSG, tca_id | NLA_F_NESTED); addattr_l(n, MAX_MSG, TCA_MPLS_PARMS, &parm, sizeof(parm)); if (label != 0xffffffff) - addattr_l(n, MAX_MSG, TCA_MPLS_LABEL, &label, sizeof(label)); + addattr_l(n, MAX_MSG, TCA_MPLS_LABEL, &label, 8); if (proto) addattr_l(n, MAX_MSG, TCA_MPLS_PROTO, &proto, sizeof(proto)); if (tc != 0xff) It does not seem valid to use NLA_POLICY_VALIDATE_FN() without NLA_BINARY. Fixed for me by: diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c index ff47ce4d3968..6b26bdb999d7 100644 --- a/net/sched/act_mpls.c +++ b/net/sched/act_mpls.c @@ -134,6 +134,11 @@ static int valid_label(const struct nlattr *attr, { const u32 *label = nla_data(attr); + if (nla_len(attr) != sizeof(*label)) { + NL_SET_ERR_MSG_MOD(extack, "Invalid MPLS label length"); + return -EINVAL; + } + if (*label & ~MPLS_LABEL_MASK || *label == MPLS_LABEL_IMPLNULL) { NL_SET_ERR_MSG_MOD(extack, "MPLS label out of range"); return -EINVAL; @@ -145,7 +150,8 @@ static int valid_label(const struct nlattr *attr, static const struct nla_policy mpls_policy[TCA_MPLS_MAX + 1] = { [TCA_MPLS_PARMS] = NLA_POLICY_EXACT_LEN(sizeof(struct tc_mpls)), [TCA_MPLS_PROTO] = { .type = NLA_U16 }, - [TCA_MPLS_LABEL] = NLA_POLICY_VALIDATE_FN(NLA_U32, valid_label), + [TCA_MPLS_LABEL] = NLA_POLICY_VALIDATE_FN(NLA_BINARY, + valid_label), [TCA_MPLS_TC] = NLA_POLICY_RANGE(NLA_U8, 0, 7), [TCA_MPLS_TTL] = NLA_POLICY_MIN(NLA_U8, 1), [TCA_MPLS_BOS] = NLA_POLICY_RANGE(NLA_U8, 0, 1), But please test with your reproducer as well. For net-next we can try to remove the first argument from NLA_POLICY_VALIDATE_FN() and set NLA_BINARY which is what everyone is passing anyway. Adding Johannes in case he has a better idea. > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > Reported-by: Wei Chen <harperchen1110@gmail.com> > > ------------[ cut here ]------------ > WARNING: CPU: 0 PID: 17743 at lib/nlattr.c:118 > nla_get_range_unsigned+0x1d8/0x1e0 lib/nlattr.c:117 > Modules linked in: > CPU: 0 PID: 17743 Comm: syz-executor.0 Not tainted 6.1.0-rc8 #3 > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS > rel-1.13.0-48-gd9c812dda519-prebuilt.qemu.org 04/01/2014 > RIP: 0010:nla_get_range_unsigned+0x1d8/0x1e0 lib/nlattr.c:117 > Code: 8d ff 49 8b 75 08 ba 10 00 00 00 4c 89 f7 e8 0f d8 f8 02 5b 41 5c 41 > 5d 41 5e 41 5f 5d c3 e8 0f 57 7a ff eb 05 e8 08 57 7a ff <0f> 0b e9 a9 fe > ff ff 90 55 41 57 41 56 41 54 53 49 89 f6 49 89 fc > RSP: 0018:ffffc90002df39b8 EFLAGS: 00010287 > RAX: ffffffff81ad2f51 RBX: ffffffff85364d28 RCX: 0000000000040000 > RDX: ffffc90000add000 RSI: 0000000000000268 RDI: 0000000000000269 > RBP: 000000000000f940 R08: ffffffff81ad2dd8 R09: 0000000000000000 > R10: 0001ffffffffffff R11: ffff888045136780 R12: ffff88803e174000 > R13: ffffffff85364d20 R14: ffffc90002df3a30 R15: ffffffff85364d21 > FS: 00007fab1e5c8700(0000) GS:ffff88807dc00000(0000) knlGS:0000000000000000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 000000000073f8d0 CR3: 000000004a789000 CR4: 00000000003506f0 > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000600 > Call Trace: > <TASK> > __netlink_policy_dump_write_attr+0x23d/0x990 net/netlink/policy.c:310 > netlink_policy_dump_write_attr+0x22/0x30 net/netlink/policy.c:411 > netlink_ack_tlv_fill net/netlink/af_netlink.c:2454 [inline] > netlink_ack+0x546/0x760 net/netlink/af_netlink.c:2506 > netlink_rcv_skb+0x1b7/0x240 net/netlink/af_netlink.c:2546 > rtnetlink_rcv+0x18/0x20 net/core/rtnetlink.c:6109 > netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline] > netlink_unicast+0x5e9/0x6b0 net/netlink/af_netlink.c:1345 > netlink_sendmsg+0x739/0x860 net/netlink/af_netlink.c:1921 > sock_sendmsg_nosec net/socket.c:714 [inline] > sock_sendmsg net/socket.c:734 [inline] > ____sys_sendmsg+0x38f/0x500 net/socket.c:2482 > ___sys_sendmsg net/socket.c:2536 [inline] > __sys_sendmsg+0x197/0x230 net/socket.c:2565 > __do_sys_sendmsg net/socket.c:2574 [inline] > __se_sys_sendmsg net/socket.c:2572 [inline] > __x64_sys_sendmsg+0x42/0x50 net/socket.c:2572 > do_syscall_x64 arch/x86/entry/common.c:50 [inline] > do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 > entry_SYSCALL_64_after_hwframe+0x63/0xcd > RIP: 0033:0x4697f9 > Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7 > 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff > ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 > RSP: 002b:00007fab1e5c7c48 EFLAGS: 00000246 ORIG_RAX: 000000000000002e > RAX: ffffffffffffffda RBX: 000000000077bf80 RCX: 00000000004697f9 > RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000003 > RBP: 00000000004d29e9 R08: 0000000000000000 R09: 0000000000000000 > R10: 0000000000000000 R11: 0000000000000246 R12: 000000000077bf80 > R13: 0000000000000000 R14: 000000000077bf80 R15: 00007ffd7c0e6920 > </TASK> > ---[ end trace 0000000000000000 ]--- > > Best, > Wei > > -- > You received this message because you are subscribed to the Google Groups "syzkaller" group. > To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller/CAO4mrffa_3PhjfA9hxTq_U9GjC%2B%2B0suGnme9oNcKE%3DGn%2Bg1iRg%40mail.gmail.com. ^ permalink raw reply related [flat|nested] 6+ messages in thread
* WARNING in nla_get_range_unsigned @ 2023-03-04 15:10 Shigeru Yoshida 2023-03-04 16:43 ` Johannes Berg 0 siblings, 1 reply; 6+ messages in thread From: Shigeru Yoshida @ 2023-03-04 15:10 UTC (permalink / raw) To: linux-wireless; +Cc: quic_alokad, quic_msinada, johannes.berg Hi, Recently, when I ran syzkaller, the following warning was detected: [ 37.446619][ T8620] ------------[ cut here ]------------ [ 37.447395][ T8620] WARNING: CPU: 2 PID: 8620 at lib/nlattr.c:118 nla_get_range_unsigned+0x199/0x460 [ 37.448059][ T8620] Modules linked in: [ 37.448350][ T8620] CPU: 2 PID: 8620 Comm: repro Not tainted 6.2.0 #1 [ 37.448817][ T8620] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.1-2.fc37 04/01/2014 [ 37.449485][ T8620] RIP: 0010:nla_get_range_unsigned+0x199/0x460 [ 37.449927][ T8620] Code: 0f 85 34 02 00 00 a9 08 00 08 00 0f 85 35 02 00 00 e8 9b 55 37 fd 0f 0b 5b 41 5c 41 5d 41 5e 5d e9 8c 55 37 fd e8 87 55 37 fd <0f> 0b e9 50 4 [ 37.451445][ T8620] RSP: 0018:ffffc900132873a0 EFLAGS: 00010293 [ 37.451883][ T8620] RAX: 0000000000000000 RBX: ffffffff8b7cff40 RCX: 0000000000000000 [ 37.452443][ T8620] RDX: ffff88801f018000 RSI: ffffffff844dde29 RDI: 0000000000000003 [ 37.452997][ T8620] RBP: ffffc900132873c0 R08: 0000000000000003 R09: 0000000000000000 [ 37.453555][ T8620] R10: 000000000000ffff R11: ffffffff8f9ebb5f R12: ffffc90013287468 [ 37.454114][ T8620] R13: ffffffff8b7cff41 R14: 000000000000ffff R15: ffff888022c24614 [ 37.454671][ T8620] FS: 00007f32f97ff600(0000) GS:ffff88802cb00000(0000) knlGS:0000000000000000 [ 37.455297][ T8620] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 37.455764][ T8620] CR2: 00007f32f95c1585 CR3: 000000004d37e000 CR4: 0000000000750ee0 [ 37.456320][ T8620] PKRU: 55555554 [ 37.456582][ T8620] Call Trace: [ 37.456828][ T8620] <TASK> [ 37.457050][ T8620] __nla_validate_parse+0x164e/0x24d0 [ 37.457461][ T8620] ? nla_get_range_signed+0x370/0x370 [ 37.457851][ T8620] ? kasan_unpoison+0x44/0x70 [ 37.458199][ T8620] __nla_parse+0x40/0x50 [ 37.458512][ T8620] genl_family_rcv_msg_attrs_parse.constprop.0+0x19e/0x280 [ 37.459025][ T8620] genl_family_rcv_msg_doit.isra.0+0xa3/0x2e0 [ 37.459461][ T8620] ? genl_start+0x650/0x650 [ 37.459790][ T8620] ? apparmor_capable+0x1da/0x4e0 [ 37.460158][ T8620] ? bpf_lsm_capable+0x9/0x10 [ 37.460500][ T8620] ? security_capable+0x92/0xc0 [ 37.460884][ T8620] ? ns_capable+0xd5/0x110 [ 37.461221][ T8620] genl_rcv_msg+0x4fe/0x7c0 [ 37.461552][ T8620] ? genl_family_rcv_msg_doit.isra.0+0x2e0/0x2e0 [ 37.462002][ T8620] ? nl80211_post_doit+0x2f0/0x2f0 [ 37.462378][ T8620] ? nl80211_assoc_bss+0x260/0x260 [ 37.462749][ T8620] ? nl80211_parse_sta_wme+0x3c0/0x3c0 [ 37.463156][ T8620] netlink_rcv_skb+0x166/0x440 [ 37.463506][ T8620] ? genl_family_rcv_msg_doit.isra.0+0x2e0/0x2e0 [ 37.463955][ T8620] ? netlink_ack+0x1370/0x1370 [ 37.464317][ T8620] genl_rcv+0x28/0x40 [ 37.464610][ T8620] netlink_unicast+0x530/0x800 [ 37.464963][ T8620] ? netlink_attachskb+0x880/0x880 [ 37.465339][ T8620] ? __sanitizer_cov_trace_switch+0x54/0x90 [ 37.465764][ T8620] ? __phys_addr_symbol+0x30/0x70 [ 37.467377][ T8620] ? __check_object_size+0x333/0x6f0 [ 37.468983][ T8620] netlink_sendmsg+0x90b/0xe10 [ 37.470566][ T8620] ? netlink_unicast+0x800/0x800 [ 37.472194][ T8620] ? bpf_lsm_socket_sendmsg+0x9/0x10 [ 37.473787][ T8620] ? netlink_unicast+0x800/0x800 [ 37.475357][ T8620] sock_sendmsg+0xd9/0x180 [ 37.476862][ T8620] ____sys_sendmsg+0x66d/0x910 [ 37.478373][ T8620] ? kernel_sendmsg+0x50/0x50 [ 37.479854][ T8620] ? __copy_msghdr+0x460/0x460 [ 37.481366][ T8620] ? find_held_lock+0x2d/0x110 [ 37.482806][ T8620] ___sys_sendmsg+0x11d/0x1b0 [ 37.484179][ T8620] ? do_recvmmsg+0x700/0x700 [ 37.485476][ T8620] ? lockdep_hardirqs_on_prepare+0x410/0x410 [ 37.486756][ T8620] ? file_tty_write.constprop.0+0x619/0x9f0 [ 37.488014][ T8620] ? n_tty_close+0x1f0/0x1f0 [ 37.489163][ T8620] ? find_held_lock+0x2d/0x110 [ 37.490296][ T8620] ? __fget_light+0x205/0x270 [ 37.491424][ T8620] __sys_sendmsg+0xfa/0x1d0 [ 37.492506][ T8620] ? __sys_sendmsg_sock+0x30/0x30 [ 37.493572][ T8620] ? __audit_syscall_entry+0x396/0x500 [ 37.494639][ T8620] do_syscall_64+0x38/0xb0 [ 37.495634][ T8620] entry_SYSCALL_64_after_hwframe+0x63/0xcd I investigated this issue and found that the issue relates to the following commit: d7c1a9a0ed18 wifi: nl80211: validate and configure puncturing bitmap This commit sets the maximum value of nla_policy for NL80211_ATTR_PUNCT_BITMAP to 0xffff as below: diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index c82c66c32faa..683adeb3c9e3 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -805,6 +805,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { [NL80211_ATTR_MLD_ADDR] = NLA_POLICY_EXACT_LEN(ETH_ALEN), [NL80211_ATTR_MLO_SUPPORT] = { .type = NLA_FLAG }, [NL80211_ATTR_MAX_NUM_AKM_SUITES] = { .type = NLA_REJECT }, + [NL80211_ATTR_PUNCT_BITMAP] = NLA_POLICY_RANGE(NLA_U8, 0, 0xffff), }; This triggers the warning in nla_get_range_unsigned() below as 0xffff is interpreted to -1: void nla_get_range_unsigned(const struct nla_policy *pt, struct netlink_range_validation *range) { WARN_ON_ONCE(pt->validation_type != NLA_VALIDATE_RANGE_PTR && (pt->min < 0 || pt->max < 0)); I also noticed that checking the value to 0xffff is a bit different in the following original patch: https://lore.kernel.org/all/20230131001227.25014-3-quic_alokad@quicinc.com/ So, I tried to modify the code like below, then the issue disappeared: diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 112b4bb009c8..066061fbeeb3 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -805,7 +805,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { [NL80211_ATTR_MLD_ADDR] = NLA_POLICY_EXACT_LEN(ETH_ALEN), [NL80211_ATTR_MLO_SUPPORT] = { .type = NLA_FLAG }, [NL80211_ATTR_MAX_NUM_AKM_SUITES] = { .type = NLA_REJECT }, - [NL80211_ATTR_PUNCT_BITMAP] = NLA_POLICY_RANGE(NLA_U8, 0, 0xffff), + [NL80211_ATTR_PUNCT_BITMAP] = { .type = NLA_U32 }, }; /* policy for the key attributes */ @@ -3183,9 +3183,15 @@ static int nl80211_parse_punct_bitmap(struct cfg80211_registered_device *rdev, const struct cfg80211_chan_def *chandef, u16 *punct_bitmap) { + u32 bitmap; + if (!wiphy_ext_feature_isset(&rdev->wiphy, NL80211_EXT_FEATURE_PUNCT)) return -EINVAL; + bitmap = nla_get_u32(info->attrs[NL80211_ATTR_PUNCT_BITMAP]); + if (bitmap & 0xFFFF0000) + return -EINVAL; + *punct_bitmap = nla_get_u32(info->attrs[NL80211_ATTR_PUNCT_BITMAP]); if (!cfg80211_valid_disable_subchannel_bitmap(punct_bitmap, chandef)) return -EINVAL; Is there any special reason to move checking the value to 0xffff in nla_policy? Otherwise, is this a bug of the warning in nla_get_range_unsigned()? Thanks, Shigeru ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: WARNING in nla_get_range_unsigned 2023-03-04 15:10 Shigeru Yoshida @ 2023-03-04 16:43 ` Johannes Berg 2023-03-04 17:32 ` Shigeru Yoshida 0 siblings, 1 reply; 6+ messages in thread From: Johannes Berg @ 2023-03-04 16:43 UTC (permalink / raw) To: Shigeru Yoshida, linux-wireless; +Cc: quic_alokad, quic_msinada > > I investigated this issue and found that the issue relates to the > following commit: > > d7c1a9a0ed18 wifi: nl80211: validate and configure puncturing bitmap > There's a fix in the queue for this, I'll get it in soon. https://patchwork.kernel.org/project/linux-wireless/patch/20230224133656.b53b1fea182c.Ifa95124e8851df90e69776bcc3b0e3ebd1cf1687@changeid/ johannes ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: WARNING in nla_get_range_unsigned 2023-03-04 16:43 ` Johannes Berg @ 2023-03-04 17:32 ` Shigeru Yoshida 0 siblings, 0 replies; 6+ messages in thread From: Shigeru Yoshida @ 2023-03-04 17:32 UTC (permalink / raw) To: Johannes Berg; +Cc: linux-wireless, quic_alokad, quic_msinada On Sat, Mar 04, 2023 at 05:43:12PM +0100, Johannes Berg wrote: > > > > I investigated this issue and found that the issue relates to the > > following commit: > > > > d7c1a9a0ed18 wifi: nl80211: validate and configure puncturing bitmap > > > > There's a fix in the queue for this, I'll get it in soon. > > https://patchwork.kernel.org/project/linux-wireless/patch/20230224133656.b53b1fea182c.Ifa95124e8851df90e69776bcc3b0e3ebd1cf1687@changeid/ Thanks for the reply. I got it. Shigeru > > johannes > ^ permalink raw reply [flat|nested] 6+ messages in thread
* WARNING in nla_get_range_unsigned
@ 2020-08-31 16:47 syzbot
0 siblings, 0 replies; 6+ messages in thread
From: syzbot @ 2020-08-31 16:47 UTC (permalink / raw)
To: davem, johannes.berg, kuba, linux-kernel, netdev, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: 0f091e43 netlabel: remove unused param from audit_log_form..
git tree: net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=14865df2900000
kernel config: https://syzkaller.appspot.com/x/.config?x=61025c6fd3261bb1
dashboard link: https://syzkaller.appspot.com/bug?extid=353df1490da781637624
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12d7b769900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14e7aa56900000
The issue was bisected to:
commit 8aa26c575fb343ebde810b30dad0cba7d8121efb
Author: Johannes Berg <johannes.berg@intel.com>
Date: Tue Aug 18 08:17:33 2020 +0000
netlink: make NLA_BINARY validation more flexible
bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=104486c1900000
final oops: https://syzkaller.appspot.com/x/report.txt?x=124486c1900000
console output: https://syzkaller.appspot.com/x/log.txt?x=144486c1900000
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+353df1490da781637624@syzkaller.appspotmail.com
Fixes: 8aa26c575fb3 ("netlink: make NLA_BINARY validation more flexible")
------------[ cut here ]------------
WARNING: CPU: 0 PID: 6854 at lib/nlattr.c:117 nla_get_range_unsigned+0x157/0x530 lib/nlattr.c:117
Kernel panic - not syncing: panic_on_warn set ...
CPU: 0 PID: 6854 Comm: syz-executor416 Not tainted 5.9.0-rc1-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x18f/0x20d lib/dump_stack.c:118
panic+0x2e3/0x75c kernel/panic.c:231
__warn.cold+0x20/0x4a kernel/panic.c:600
report_bug+0x1bd/0x210 lib/bug.c:198
handle_bug+0x38/0x90 arch/x86/kernel/traps.c:234
exc_invalid_op+0x14/0x40 arch/x86/kernel/traps.c:254
asm_exc_invalid_op+0x12/0x20 arch/x86/include/asm/idtentry.h:536
RIP: 0010:nla_get_range_unsigned+0x157/0x530 lib/nlattr.c:117
Code: 2a 03 00 00 44 0f b6 3b 48 c7 c6 40 9f 96 88 4c 89 ff e8 3c 34 c4 fd 41 80 ff 0b 77 11 42 ff 24 fd 60 99 96 88 e8 69 37 c4 fd <0f> 0b eb 8f e8 60 37 c4 fd 0f 0b 5b 41 5c 41 5d 41 5e 41 5f 5d e9
RSP: 0018:ffffc90000f17190 EFLAGS: 00010293
RAX: 0000000000000000 RBX: ffffffff89180640 RCX: ffffffff83b006e8
RDX: ffff8880a79a8300 RSI: ffffffff83b007a7 RDI: 0000000000000003
RBP: ffffc90000f171b8 R08: 0000000000000000 R09: ffff8880972a4370
R10: 0000000000000000 R11: 0000000000000000 R12: ffffc90000f17278
R13: ffffffff89180641 R14: 0000000000008c60 R15: ffffffff89180640
netlink_policy_dump_write+0x2ae/0xea0 net/netlink/policy.c:270
ctrl_dumppolicy+0x4a8/0x900 net/netlink/genetlink.c:1099
genl_lock_dumpit+0x7f/0xb0 net/netlink/genetlink.c:553
netlink_dump+0x4cd/0xf60 net/netlink/af_netlink.c:2246
__netlink_dump_start+0x643/0x900 net/netlink/af_netlink.c:2354
genl_family_rcv_msg_dumpit+0x2ac/0x310 net/netlink/genetlink.c:616
genl_family_rcv_msg net/netlink/genetlink.c:711 [inline]
genl_rcv_msg+0x75f/0x980 net/netlink/genetlink.c:731
netlink_rcv_skb+0x15a/0x430 net/netlink/af_netlink.c:2470
genl_rcv+0x24/0x40 net/netlink/genetlink.c:742
netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline]
netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1330
netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1919
sock_sendmsg_nosec net/socket.c:651 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:671
____sys_sendmsg+0x6e8/0x810 net/socket.c:2353
___sys_sendmsg+0xf3/0x170 net/socket.c:2407
__sys_sendmsg+0xe5/0x1b0 net/socket.c:2440
do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x4402a9
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 7b 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffd2f689438 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004402a9
RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000003
RBP: 00000000006ca018 R08: 0000000000000000 R09: 00000000004002c8
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000401ab0
R13: 0000000000401b40 R14: 0000000000000000 R15: 0000000000000000
Kernel Offset: disabled
Rebooting in 86400 seconds..
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches
^ permalink raw reply [flat|nested] 6+ messages in threadend of thread, other threads:[~2023-03-04 17:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAO4mrffa_3PhjfA9hxTq_U9GjC++0suGnme9oNcKE=Gn+g1iRg@mail.gmail.com>
2022-12-17 9:24 ` WARNING in nla_get_range_unsigned Wei Chen
2022-12-17 14:19 ` Ido Schimmel
2023-03-04 15:10 Shigeru Yoshida
2023-03-04 16:43 ` Johannes Berg
2023-03-04 17:32 ` Shigeru Yoshida
-- strict thread matches above, loose matches on Subject: below --
2020-08-31 16:47 syzbot
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.