Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[not a bug] Undefined behavior warnings by UBSAN #80

Closed
spcharc opened this issue Sep 19, 2022 · 3 comments
Closed

[not a bug] Undefined behavior warnings by UBSAN #80

spcharc opened this issue Sep 19, 2022 · 3 comments

Comments

@spcharc
Copy link
Collaborator

spcharc commented Sep 19, 2022

The driver works fine but there are some call stack dump in my dmesg. So I think I should share them.

The commit I'm using is:

commit 95a17181003c2d777cfc0fc70ef729af6f6a5ed8 (HEAD -> main, origin/main, origin/HEAD)
Author: morrownr <[email protected]>
Date:   Sun Jul 10 15:36:10 2022 -0500

    update README.md

I have two kernel modules from this repo. 88x2bu1 and 88x2bu2. They are from the same commit.

I think I did not see this kind of logs on Ubuntu 20.04. Recently I upgraded to 22.04, so perhaps these logs started to show up because of the kernel version change?

[   11.787959] UBSAN: invalid-load in /var/lib/dkms/rtl88x2bu1/5.13.1/build/hal/phydm/phydm_ccx.c:696:17
[   11.672305] load of value 255 is not a valid value for type '_Bool'
[   11.672308] CPU: 3 PID: 926 Comm: RTW_CMD_THREAD Tainted: P           OE     5.15.0-47-generic #51-Ubuntu
[   11.672311] Hardware name: AAEON MIX-EHLD1/MIX-EHLD1, BIOS 0006 01/07/2022
[   11.672313] Call Trace:
[   11.672316]  <TASK>
[   11.672320]  show_stack+0x52/0x5c
[   11.672327]  dump_stack_lvl+0x4a/0x63
[   11.672334]  dump_stack+0x10/0x16
[   11.672336]  ubsan_epilogue+0x9/0x49
[   11.672338]  __ubsan_handle_load_invalid_value.cold+0x44/0x49
[   11.672341]  ? rtw_hal_mgnt_xmit+0x7d/0xa2 [88x2bu1]
[   11.672440]  phydm_nhm_mntr_set+0x121/0x123 [88x2bu1]
[   11.672513]  phydm_env_mntr_trigger+0x3c/0x160 [88x2bu1]
[   11.672594]  rtw_acs_trigger+0x90/0xfd [88x2bu1]
[   11.672692]  sitesurvey_cmd_hdl+0xe9c/0x1192 [88x2bu1]
[   11.672770]  ? kfree+0x161/0x250
[   11.672774]  ? up+0x37/0x70
[   11.672778]  ? _rtw_up_sema+0xe/0x14 [88x2bu1]
[   11.672865]  ? init_mlme_ext_priv+0x217/0x217 [88x2bu1]
[   11.672950]  rtw_cmd_thread+0x41c/0x76b [88x2bu1]
[   11.673013]  ? rtw_stop_cmd_thread+0x49/0x49 [88x2bu1]
[   11.673077]  kthread+0x127/0x150
[   11.673081]  ? set_kthread_struct+0x50/0x50
[   11.673084]  ret_from_fork+0x1f/0x30
[   11.673088]  </TASK>
[   11.787959] UBSAN: array-index-out-of-bounds in /var/lib/dkms/rtl88x2bu2/5.13.1/build/hal/phydm/phydm_dfs.c:1286:51
[   11.787962] index 6 is out of range for type 'u8 [6]'
[   11.787965] CPU: 3 PID: 881 Comm: RTW_CMD_THREAD Tainted: P           OE     5.15.0-47-generic #51-Ubuntu
[   11.787968] Hardware name: AAEON MIX-EHLD1/MIX-EHLD1, BIOS 0006 01/07/2022
[   11.787970] Call Trace:
[   11.787973]  <TASK>
[   11.787977]  show_stack+0x52/0x5c
[   11.787983]  dump_stack_lvl+0x4a/0x63
[   11.787989]  dump_stack+0x10/0x16
[   11.787992]  ubsan_epilogue+0x9/0x49
[   11.787994]  __ubsan_handle_out_of_bounds.cold+0x44/0x49
[   11.787997]  ? rtw_hal_write_bbreg+0x17/0x25 [88x2bu2]
[   11.788093]  ? odm_set_bb_reg+0x24/0x73 [88x2bu2]
[   11.788169]  phydm_dfs_histogram_radar_distinguish+0x4d4/0x1d80 [88x2bu2]
[   11.788241]  phydm_radar_detect+0x1ce/0x249 [88x2bu2]
[   11.788311]  rtw_odm_radar_detect+0x17/0x1d [88x2bu2]
[   11.788382]  rtw_dfs_rd_hdl+0x1d0/0x3e1 [88x2bu2]
[   11.788431]  rtw_drvextra_cmd_hdl+0x202/0x580 [88x2bu2]
[   11.788478]  ? _rtw_up_sema+0xe/0x14 [88x2bu2]
[   11.788553]  ? rtw_ac_parm_cmd_hdl+0x19b/0x19b [88x2bu2]
[   11.788599]  rtw_cmd_thread+0x41c/0x76b [88x2bu2]
[   11.788645]  ? rtw_stop_cmd_thread+0x49/0x49 [88x2bu2]
[   11.788690]  kthread+0x127/0x150
[   11.788693]  ? set_kthread_struct+0x50/0x50
[   11.788696]  ret_from_fork+0x1f/0x30
[   11.788700]  </TASK>

Here are some warnings similar to the previous one (call stack removed):

[   11.788712] UBSAN: array-index-out-of-bounds in /var/lib/dkms/rtl88x2bu2/5.13.1/build/hal/phydm/phydm_dfs.c:1287:46
[   11.788714] index 6 is out of range for type 'u8 [6]'
[   11.789460] UBSAN: array-index-out-of-bounds in /var/lib/dkms/rtl88x2bu2/5.13.1/build/hal/phydm/phydm_dfs.c:1286:24
[   11.789462] index 6 is out of range for type 'u8 [6]'
[   11.790185] UBSAN: array-index-out-of-bounds in /var/lib/dkms/rtl88x2bu2/5.13.1/build/hal/phydm/phydm_dfs.c:1288:53
[   11.790187] index 6 is out of range for type 'u8 [6]'
[   11.790919] UBSAN: array-index-out-of-bounds in /var/lib/dkms/rtl88x2bu2/5.13.1/build/hal/phydm/phydm_dfs.c:1289:47
[   11.790922] index 6 is out of range for type 'u8 [6]'
[   11.791672] UBSAN: array-index-out-of-bounds in /var/lib/dkms/rtl88x2bu2/5.13.1/build/hal/phydm/phydm_dfs.c:1288:25
[   11.791674] index 6 is out of range for type 'u8 [6]
@morrownr
Copy link
Owner

Thanks for the report. I'll add it to my list.

@spcharc
Copy link
Collaborator Author

spcharc commented Sep 19, 2022

Thanks for the report. I'll add it to my list.

tbh I am surprised that this kernel enabled UBSAN. I thought this should be some debug feature for kernel developers and should never be turned on in these linux distributions.
Also I am surprised that undefined behavior can be detected at runtime.

@spcharc
Copy link
Collaborator Author

spcharc commented Sep 29, 2024

track with #233

@spcharc spcharc closed this as completed Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants