2017-12-13 13:25:04

by Paul Menzel

[permalink] [raw]
Subject: UBSAN: Undefined behaviour in drivers/net/wireless/intel/iwlwifi/mvm/utils.c:838:5

Dear Linux folks,


I enabled the undefined behavior sanitizer, and built Linus’ master
branch under Ubuntu 17.10 with gcc (Ubuntu 7.2.0-8ubuntu3) 7.2.0.

```
$ grep UBSAN /boot/config-4.15.0-rc3+
CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y
# CONFIG_ARCH_WANTS_UBSAN_NO_NULL is not set
CONFIG_UBSAN=y
CONFIG_UBSAN_SANITIZE_ALL=y
# CONFIG_UBSAN_ALIGNMENT is not set
CONFIG_UBSAN_NULL=y
```

Starting the system the messages below are printed.

Starting the system and using the wireless device shows the messages below.

```
$ git describe --tags
v4.15-rc3-37-gd39a01eff9af
$ git log --oneline -1
d39a01eff9af (HEAD -> master, origin/master, origin/HEAD) Merge tag
'platform-drivers-x86-v4.15-3' of
git://git.infradead.org/linux-platform-drivers-x86
$ dmesg
[…]
[ 20.717777] IPv6: ADDRCONF(NETDEV_UP): wlp2s0: link is not ready
[ 23.347354] Could not find key with description: [8ac72712aa32e6df]
[ 23.347359] process_request_key_err: No key
[ 23.347361] Could not find valid key in user session keyring for sig
specified in mount option: [8ac72712aa32e6df]
[ 23.347363] One or more global auth toks could not properly register;
rc = [-2]
[ 23.347366] Error parsing options; rc = [-2]
[ 25.416104] wlp2s0: authenticate with 6c:f3:7f:10:ae:18
[ 25.423402] wlp2s0: send auth to 6c:f3:7f:10:ae:18 (try 1/3)
[ 25.434818] wlp2s0: authenticated
[ 25.436298] wlp2s0: associate with 6c:f3:7f:10:ae:18 (try 1/3)
[ 25.439399] wlp2s0: RX AssocResp from 6c:f3:7f:10:ae:18 (capab=0x411
status=0 aid=1)
[ 25.441283] wlp2s0: associated
[ 25.517382] calling crypto_ccm_module_init+0x0/0x1000 [ccm] @ 8735
[ 25.517425] initcall crypto_ccm_module_init+0x0/0x1000 [ccm] returned
0 after 23 usecs
[ 25.534281] IPv6: ADDRCONF(NETDEV_CHANGE): wlp2s0: link becomes ready
[ 26.788309] calling crypto_cmac_module_init+0x0/0x1000 [cmac] @ 8843
[ 26.788333] initcall crypto_cmac_module_init+0x0/0x1000 [cmac]
returned 0 after 7 usecs
[ 167.148167] wlp2s0: deauthenticating from 6c:f3:7f:10:ae:18 by local
choice (Reason: 3=DEAUTH_LEAVING)
[ 167.157085] wlp2s0: failed to remove key (1, ff:ff:ff:ff:ff:ff) from
hardware (-22)
[ 167.185161]
================================================================================
[ 167.185167] UBSAN: Undefined behaviour in
drivers/net/wireless/intel/iwlwifi/mvm/utils.c:838:5
[ 167.185171] shift exponent 255 is too large for 64-bit type 'long
unsigned int'
[ 167.185175] CPU: 2 PID: 2178 Comm: wpa_supplicant Not tainted
4.15.0-rc3+ #12
[ 167.185176] Hardware name: Notebook
N24_25BU/N24_25BU, BIOS 5.12 07/07/2017
[ 167.185178] Call Trace:
[ 167.185186] dump_stack+0x70/0xae
[ 167.185191] ubsan_epilogue+0x9/0x40
[ 167.185194] __ubsan_handle_shift_out_of_bounds+0x12b/0x170
[ 167.185210] ? iwl_mvm_disable_txq+0x662/0xa00 [iwlmvm]
[ 167.185213] ? _raw_spin_lock_bh+0x5/0x30
[ 167.185220] iwl_mvm_disable_txq+0x662/0xa00 [iwlmvm]
[ 167.185224] ? ftrace_graph_caller+0x68/0x98
[ 167.185238] ? iwl_mvm_send_rm_bcast_sta+0xbe/0x2c0 [iwlmvm]
[ 167.185246] iwl_mvm_send_rm_bcast_sta+0xbe/0x2c0 [iwlmvm]
[ 167.185256] iwl_mvm_rm_p2p_bcast_sta+0x31/0x110 [iwlmvm]
[ 167.185263] ? iwl_mvm_rm_p2p_bcast_sta+0x5/0x110 [iwlmvm]
[ 167.185272] iwl_mvm_mac_remove_interface+0x15d/0x1d0 [iwlmvm]
[ 167.185291] drv_remove_interface+0x5c/0x210 [mac80211]
[ 167.185309] ieee80211_do_stop+0x672/0x1070 [mac80211]
[ 167.185330] cfg80211_stop_p2p_device+0x99/0x340 [cfg80211]
[ 167.185342] ? cfg80211_stop_p2p_device+0x5/0x340 [cfg80211]
[ 167.185357] nl80211_stop_p2p_device+0x48/0xa0 [cfg80211]
[ 167.185361] genl_family_rcv_msg+0x286/0x730
[ 167.185365] ? ftrace_graph_caller+0x68/0x98
[ 167.185372] genl_rcv_msg+0x5d/0xf0
[ 167.185375] ? genl_family_rcv_msg+0x730/0x730
[ 167.185378] netlink_rcv_skb+0xa4/0x190
[ 167.185383] genl_rcv+0x24/0x40
[ 167.185385] netlink_unicast+0x1d0/0x300
[ 167.185390] netlink_sendmsg+0x35a/0x640
[ 167.185396] sock_sendmsg+0x4c/0xa0
[ 167.185400] ___sys_sendmsg+0x2db/0x440
[ 167.185404] ? fget_raw+0x10/0x10
[ 167.185407] ? sockfd_lookup_light+0x1c/0xc0
[ 167.185410] ? trace_graph_entry+0xdc/0x2b0
[ 167.185413] ? copy_msghdr_from_user+0x150/0x150
[ 167.185415] ? __sys_sendmsg+0x51/0x90
[ 167.185418] ? prepare_ftrace_return+0xaa/0x170
[ 167.185422] ? ftrace_graph_caller+0x68/0x98
[ 167.185425] ? trace_graph_entry+0xdc/0x2b0
[ 167.185432] ? __sys_sendmsg+0x51/0x90
[ 167.185434] ? ___sys_sendmsg+0x5/0x440
[ 167.185436] __sys_sendmsg+0x51/0x90
[ 167.185442] entry_SYSCALL_64_fastpath+0x1e/0x81
[ 167.185459] RIP: 0033:0x7f6335800d07
[ 167.185460] RSP: 002b:00007ffdc8c51a98 EFLAGS: 00000246 ORIG_RAX:
000000000000002e
[ 167.185463] RAX: ffffffffffffffda RBX: 0000556ebcc69550 RCX:
00007f6335800d07
[ 167.185465] RDX: 0000000000000000 RSI: 00007ffdc8c51ad0 RDI:
0000000000000007
[ 167.185466] RBP: 0000556ebcc69480 R08: 0000000000000000 R09:
0000556ebccb1e50
[ 167.185468] R10: 0000000000000007 R11: 0000000000000246 R12:
0000556ebcc694a0
[ 167.185469] R13: 0000556ebcc6ad38 R14: 0000000000000001 R15:
0000000000000000
[ 167.185476]
================================================================================
```

Please tell me, if you need anything else to address this.


Kind regards,

Paul


Attachments:
config-4.15.0-rc3+ (207.49 kB)

2017-12-21 10:38:46

by Kalle Valo

[permalink] [raw]
Subject: Re: UBSAN: Undefined behaviour in drivers/net/wireless/intel/iwlwifi/mvm/utils.c:838:5

Paul Menzel <[email protected]> writes:

>> http://pastebin.coelho.fi/7b624f474846da52.txt
>
> Thank you. The warning is gone now. Thank you. For the next time, it=E2=
=80=99d
> be great to provide the output of `git format-patch -1`, which can be
> applied with `git am`. The output of `git show` is with my knowledge
> hard to apply.

'patch -p1 < foo.patch' should work. Of course it omits the commit log
but is usually enough for testing purposes.

--=20
Kalle Valo

2017-12-21 10:57:13

by Luca Coelho

[permalink] [raw]
Subject: Re: UBSAN: Undefined behaviour in drivers/net/wireless/intel/iwlwifi/mvm/utils.c:838:5

On Thu, 2017-12-21 at 11:49 +0100, Paul Menzel wrote:
> Dear Kalle,
>
>
> On 12/21/17 11:38, Kalle Valo wrote:
> > Paul Menzel <[email protected]> writes:
> >
> > > > http://pastebin.coelho.fi/7b624f474846da52.txt
> > >
> > > Thank you. The warning is gone now. Thank you. For the next time,
> > > it’d
> > > be great to provide the output of `git format-patch -1`, which
> > > can be
> > > applied with `git am`. The output of `git show` is with my
> > > knowledge
> > > hard to apply.
> >
> > 'patch -p1 < foo.patch' should work. Of course it omits the commit
> > log
> > but is usually enough for testing purposes.
>
> That’s what I did in the end. And then I have to do `git commit -a`
> to
> get the tree in a clean state.
>
> So `git format-patch -1` and uploading of that, for example with
> some
> CLI tool, for the win. ;-)

The choice here is: more work for me vs. more work for you. :) But I
guess I can easily do "git format-patch -1 --stdout" and pipe it to my
pastebin script...

--
Luca.

2017-12-13 14:32:36

by Luciano Coelho

[permalink] [raw]
Subject: Re: UBSAN: Undefined behaviour in drivers/net/wireless/intel/iwlwifi/mvm/utils.c:838:5

On Wed, 2017-12-13 at 14:25 +0100, Paul Menzel wrote:
> Dear Linux folks,
>
>
> I enabled the undefined behavior sanitizer, and built Linus’ master
> branch under Ubuntu 17.10 with gcc (Ubuntu 7.2.0-8ubuntu3) 7.2.0.
>
> ```
> $ grep UBSAN /boot/config-4.15.0-rc3+
> CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y
> # CONFIG_ARCH_WANTS_UBSAN_NO_NULL is not set
> CONFIG_UBSAN=y
> CONFIG_UBSAN_SANITIZE_ALL=y
> # CONFIG_UBSAN_ALIGNMENT is not set
> CONFIG_UBSAN_NULL=y
> ```
>
> Starting the system the messages below are printed.
>
> Starting the system and using the wireless device shows the messages
> below.

Thanks for reporting! This shouldn't cause any problems, but I'll fix
it by checking that the mac80211_queue is not INVALID_QUEUE (255) which
seems to be the trigger for this warning.

--
Cheers,
Luca.

2017-12-20 11:44:38

by Luca Coelho

[permalink] [raw]
Subject: Re: UBSAN: Undefined behaviour in drivers/net/wireless/intel/iwlwifi/mvm/utils.c:838:5

On Wed, 2017-12-20 at 12:00 +0100, Paul Menzel wrote:
> Dear Luca,
>
>
> Am 18.12.2017 um 19:30 schrieb Luca Coelho:
> > On Wed, 2017-12-13 at 16:32 +0200, Luciano Coelho wrote:
> > > On Wed, 2017-12-13 at 14:25 +0100, Paul Menzel wrote:
> > > > I enabled the undefined behavior sanitizer, and built Linus’
> > > > master branch under Ubuntu 17.10 with gcc (Ubuntu 7.2.0-
> > > > 8ubuntu3)
> > > > 7.2.0.
> > > >
> > > > ``` $ grep UBSAN /boot/config-4.15.0-rc3+
> > > > CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y #
> > > > CONFIG_ARCH_WANTS_UBSAN_NO_NULL is not set CONFIG_UBSAN=y
> > > > CONFIG_UBSAN_SANITIZE_ALL=y # CONFIG_UBSAN_ALIGNMENT is not
> > > > set
> > > > CONFIG_UBSAN_NULL=y ```
> > > >
> > > > Starting the system the messages below are printed.
> > > >
> > > > Starting the system and using the wireless device shows the
> > > > messages below.
> > >
> > > Thanks for reporting! This shouldn't cause any problems, but I'll
> > > fix it by checking that the mac80211_queue is not INVALID_QUEUE
> > > (255) which seems to be the trigger for this warning.
> >
> > Can you try the following patch to see if the problem goes away?
> >
> > http://pastebin.coelho.fi/7b624f474846da52.txt
>
> Thank you. The warning is gone now. Thank you.

Thanks for testing! We are actually improving the fix a bit, because it
seems that we should not have gotten INVALID_QUEUE there. We will have
a two-fold fix (Sari, whom I CCed, is working on the other patch).


> For the next time, it’d
> be great to provide the output of `git format-patch -1`, which can
> be
> applied with `git am`. The output of `git show` is with my knowledge
> hard to apply.

Ah, sorry about that. I didn't want to send a full patch here so that
it wouldn't get picked up by patchworks, so I just pastebinned it.

--
Luca.

2017-12-18 18:30:20

by Luca Coelho

[permalink] [raw]
Subject: Re: UBSAN: Undefined behaviour in drivers/net/wireless/intel/iwlwifi/mvm/utils.c:838:5

On Wed, 2017-12-13 at 16:32 +0200, Luciano Coelho wrote:
> On Wed, 2017-12-13 at 14:25 +0100, Paul Menzel wrote:
> > Dear Linux folks,
> >
> >
> > I enabled the undefined behavior sanitizer, and built Linus’
> > master
> > branch under Ubuntu 17.10 with gcc (Ubuntu 7.2.0-8ubuntu3) 7.2.0.
> >
> > ```
> > $ grep UBSAN /boot/config-4.15.0-rc3+
> > CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y
> > # CONFIG_ARCH_WANTS_UBSAN_NO_NULL is not set
> > CONFIG_UBSAN=y
> > CONFIG_UBSAN_SANITIZE_ALL=y
> > # CONFIG_UBSAN_ALIGNMENT is not set
> > CONFIG_UBSAN_NULL=y
> > ```
> >
> > Starting the system the messages below are printed.
> >
> > Starting the system and using the wireless device shows the
> > messages
> > below.
>
> Thanks for reporting! This shouldn't cause any problems, but I'll fix
> it by checking that the mac80211_queue is not INVALID_QUEUE (255)
> which seems to be the trigger for this warning.

Can you try the following patch to see if the problem goes away?

http://pastebin.coelho.fi/7b624f474846da52.txt

Thanks!

--
Cheers,
Luca.

2017-12-20 11:00:52

by Paul Menzel

[permalink] [raw]
Subject: Re: UBSAN: Undefined behaviour in drivers/net/wireless/intel/iwlwifi/mvm/utils.c:838:5

Dear Luca,


Am 18.12.2017 um 19:30 schrieb Luca Coelho:
> On Wed, 2017-12-13 at 16:32 +0200, Luciano Coelho wrote:
>> On Wed, 2017-12-13 at 14:25 +0100, Paul Menzel wrote:

>>> I enabled the undefined behavior sanitizer, and built Linus’
>>> master branch under Ubuntu 17.10 with gcc (Ubuntu 7.2.0-8ubuntu3)
>>> 7.2.0.
>>>
>>> ``` $ grep UBSAN /boot/config-4.15.0-rc3+
>>> CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y #
>>> CONFIG_ARCH_WANTS_UBSAN_NO_NULL is not set CONFIG_UBSAN=y
>>> CONFIG_UBSAN_SANITIZE_ALL=y # CONFIG_UBSAN_ALIGNMENT is not set
>>> CONFIG_UBSAN_NULL=y ```
>>>
>>> Starting the system the messages below are printed.
>>>
>>> Starting the system and using the wireless device shows the
>>> messages below.
>>
>> Thanks for reporting! This shouldn't cause any problems, but I'll
>> fix it by checking that the mac80211_queue is not INVALID_QUEUE
>> (255) which seems to be the trigger for this warning.
>
> Can you try the following patch to see if the problem goes away?
>
> http://pastebin.coelho.fi/7b624f474846da52.txt

Thank you. The warning is gone now. Thank you. For the next time, it’d
be great to provide the output of `git format-patch -1`, which can be
applied with `git am`. The output of `git show` is with my knowledge
hard to apply.


Kind regards,

Paul

2017-12-21 10:49:15

by Paul Menzel

[permalink] [raw]
Subject: Re: UBSAN: Undefined behaviour in drivers/net/wireless/intel/iwlwifi/mvm/utils.c:838:5

Dear Kalle,


On 12/21/17 11:38, Kalle Valo wrote:
> Paul Menzel <[email protected]> writes:
>
>>> http://pastebin.coelho.fi/7b624f474846da52.txt
>>
>> Thank you. The warning is gone now. Thank you. For the next time, it’d
>> be great to provide the output of `git format-patch -1`, which can be
>> applied with `git am`. The output of `git show` is with my knowledge
>> hard to apply.
>
> 'patch -p1 < foo.patch' should work. Of course it omits the commit log
> but is usually enough for testing purposes.

That’s what I did in the end. And then I have to do `git commit -a` to
get the tree in a clean state.

So `git format-patch -1` and uploading of that, for example with some
CLI tool, for the win. ;-)


Kind regards,

Paul