Bug 206525
Summary: | BUG: KASAN: stack-out-of-bounds in test_bit+0x30/0x44 (kernel 5.6-rc1) | ||
---|---|---|---|
Product: | Networking | Reporter: | Erhard F. (erhard_f) |
Component: | Other | Assignee: | platform_ppc-32 |
Status: | RESOLVED CODE_FIX | ||
Severity: | normal | CC: | christophe.leroy, davem, nikolay |
Priority: | P1 | ||
Hardware: | All | ||
OS: | Linux | ||
Kernel Version: | 5.6.0-rc1 | Subsystem: | |
Regression: | No | Bisected commit-id: | |
Attachments: |
dmesg (5.6.0-rc1 + v2 Fix DSI and ISI... patch, PowerMac G4 DP)
kernel .config (5.6.0-rc1, PowerMac G4 DP) |
Description
Erhard F.
2020-02-13 20:07:46 UTC
Created attachment 287359 [details]
kernel .config (5.6.0-rc1, PowerMac G4 DP)
Probably a bug in or around netlink_bind() in net/netlink/af_netlink.c https://elixir.bootlin.com/linux/v5.6-rc1/source/net/netlink/af_netlink.c#L1017 Could you print the value of nlk->ngroups just before the loop which does the test_bit() ? It shall be 32 or less. Bug introduced by commit ("cf5bddb95cbe net: bridge: vlan: add rtnetlink group and notify support") RTNLGRP_MAX is now 33. 'unsigned long groups' is 32 bits long on PPC32 Following loop in netlink_bind() overflows. for (group = 0; group < nlk->ngroups; group++) { if (!test_bit(group, &groups)) continue; err = nlk->netlink_bind(net, group + 1); if (!err) continue; netlink_undo_bind(group, groups, sk); goto unlock; } Should 'groups' be changes to 'unsigned long long' ? Feedback from Nikolay: I think we can just cap these at min(BITS_PER_TYPE(u32), nlk->ngroups) since "groups" is coming from sockaddr_nl's "nl_groups" which is a u32, for any groups beyond u32 one has to use setsockopt(). That's not a PPC32 bug but a Network bug affecting all 32 bits architectures. Note that the bug wasn't introduced by my commit, but instead has been there since: commit 4f520900522f Author: Richard Guy Briggs <rgb@redhat.com> Date: Tue Apr 22 21:31:54 2014 -0400 netlink: have netlink per-protocol bind function return an error code. which moved the ngroups test_bit() to a local variable. My commit only exposed the bug since it added the 33rd group. I'm currently preparing a fix and will post it to netdev after verifying and testing it. Fix landed in 5.6-rc3, works now as expected. Thanks! |