Commit ad6819c
IB/hfi1: Define variables as unsigned long to fix KASAN warning
commit f8659d6 upstream.
Define the working variables to be unsigned long to be compatible with
for_each_set_bit and change types as needed.
While we are at it remove unused variables from a couple of functions.
This was found because of the following KASAN warning:
==================================================================
BUG: KASAN: stack-out-of-bounds in find_first_bit+0x19/0x70
Read of size 8 at addr ffff888362d778d0 by task kworker/u308:2/1889
CPU: 21 PID: 1889 Comm: kworker/u308:2 Tainted: G W 5.3.0-rc2-mm1+ #2
Hardware name: Intel Corporation W2600CR/W2600CR, BIOS SE5C600.86B.02.04.0003.102320141138 10/23/2014
Workqueue: ib-comp-unb-wq ib_cq_poll_work [ib_core]
Call Trace:
dump_stack+0x9a/0xf0
? find_first_bit+0x19/0x70
print_address_description+0x6c/0x332
? find_first_bit+0x19/0x70
? find_first_bit+0x19/0x70
__kasan_report.cold.6+0x1a/0x3b
? find_first_bit+0x19/0x70
kasan_report+0xe/0x12
find_first_bit+0x19/0x70
pma_get_opa_portstatus+0x5cc/0xa80 [hfi1]
? ret_from_fork+0x3a/0x50
? pma_get_opa_port_ectrs+0x200/0x200 [hfi1]
? stack_trace_consume_entry+0x80/0x80
hfi1_process_mad+0x39b/0x26c0 [hfi1]
? __lock_acquire+0x65e/0x21b0
? clear_linkup_counters+0xb0/0xb0 [hfi1]
? check_chain_key+0x1d7/0x2e0
? lock_downgrade+0x3a0/0x3a0
? match_held_lock+0x2e/0x250
ib_mad_recv_done+0x698/0x15e0 [ib_core]
? clear_linkup_counters+0xb0/0xb0 [hfi1]
? ib_mad_send_done+0xc80/0xc80 [ib_core]
? mark_held_locks+0x79/0xa0
? _raw_spin_unlock_irqrestore+0x44/0x60
? rvt_poll_cq+0x1e1/0x340 [rdmavt]
__ib_process_cq+0x97/0x100 [ib_core]
ib_cq_poll_work+0x31/0xb0 [ib_core]
process_one_work+0x4ee/0xa00
? pwq_dec_nr_in_flight+0x110/0x110
? do_raw_spin_lock+0x113/0x1d0
worker_thread+0x57/0x5a0
? process_one_work+0xa00/0xa00
kthread+0x1bb/0x1e0
? kthread_create_on_node+0xc0/0xc0
ret_from_fork+0x3a/0x50
The buggy address belongs to the page:
page:ffffea000d8b5dc0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0x17ffffc0000000()
raw: 0017ffffc0000000 0000000000000000 ffffea000d8b5dc8 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
addr ffff888362d778d0 is located in stack of task kworker/u308:2/1889 at offset 32 in frame:
pma_get_opa_portstatus+0x0/0xa80 [hfi1]
this frame has 1 object:
[32, 36) 'vl_select_mask'
Memory state around the buggy address:
ffff888362d77780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff888362d77800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888362d77880: 00 00 00 00 00 00 f1 f1 f1 f1 04 f2 f2 f2 00 00
^
ffff888362d77900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff888362d77980: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 04 f2 f2 f2
==================================================================
Cc: <stable@vger.kernel.org>
Fixes: 7724105 ("IB/hfi1: add driver files")
Link: https://lore.kernel.org/r/20190911113053.126040.47327.stgit@awfm-01.aw.intel.com
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent a924850 commit ad6819c
1 file changed
+19
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2326 | 2326 | | |
2327 | 2327 | | |
2328 | 2328 | | |
2329 | | - | |
| 2329 | + | |
2330 | 2330 | | |
2331 | 2331 | | |
2332 | 2332 | | |
| |||
2625 | 2625 | | |
2626 | 2626 | | |
2627 | 2627 | | |
2628 | | - | |
| 2628 | + | |
2629 | 2629 | | |
2630 | 2630 | | |
2631 | 2631 | | |
2632 | 2632 | | |
2633 | | - | |
| 2633 | + | |
2634 | 2634 | | |
2635 | | - | |
2636 | | - | |
| 2635 | + | |
2637 | 2636 | | |
2638 | 2637 | | |
2639 | 2638 | | |
| |||
2730 | 2729 | | |
2731 | 2730 | | |
2732 | 2731 | | |
2733 | | - | |
| 2732 | + | |
2734 | 2733 | | |
2735 | 2734 | | |
2736 | 2735 | | |
2737 | 2736 | | |
2738 | | - | |
| 2737 | + | |
2739 | 2738 | | |
2740 | 2739 | | |
2741 | 2740 | | |
| |||
2771 | 2770 | | |
2772 | 2771 | | |
2773 | 2772 | | |
2774 | | - | |
| 2773 | + | |
2775 | 2774 | | |
2776 | 2775 | | |
2777 | 2776 | | |
| |||
2842 | 2841 | | |
2843 | 2842 | | |
2844 | 2843 | | |
2845 | | - | |
2846 | | - | |
| 2844 | + | |
2847 | 2845 | | |
2848 | 2846 | | |
2849 | 2847 | | |
| |||
2884 | 2882 | | |
2885 | 2883 | | |
2886 | 2884 | | |
2887 | | - | |
| 2885 | + | |
2888 | 2886 | | |
2889 | 2887 | | |
2890 | 2888 | | |
| |||
2931 | 2929 | | |
2932 | 2930 | | |
2933 | 2931 | | |
2934 | | - | |
2935 | | - | |
| 2932 | + | |
2936 | 2933 | | |
2937 | 2934 | | |
2938 | 2935 | | |
2939 | 2936 | | |
2940 | | - | |
| 2937 | + | |
2941 | 2938 | | |
2942 | | - | |
2943 | | - | |
| 2939 | + | |
2944 | 2940 | | |
2945 | 2941 | | |
2946 | 2942 | | |
| |||
2995 | 2991 | | |
2996 | 2992 | | |
2997 | 2993 | | |
2998 | | - | |
| 2994 | + | |
2999 | 2995 | | |
3000 | 2996 | | |
3001 | 2997 | | |
| |||
3073 | 3069 | | |
3074 | 3070 | | |
3075 | 3071 | | |
3076 | | - | |
3077 | | - | |
| 3072 | + | |
3078 | 3073 | | |
3079 | 3074 | | |
3080 | 3075 | | |
| |||
3122 | 3117 | | |
3123 | 3118 | | |
3124 | 3119 | | |
3125 | | - | |
| 3120 | + | |
3126 | 3121 | | |
3127 | 3122 | | |
3128 | 3123 | | |
| |||
3217 | 3212 | | |
3218 | 3213 | | |
3219 | 3214 | | |
3220 | | - | |
| 3215 | + | |
3221 | 3216 | | |
3222 | 3217 | | |
3223 | 3218 | | |
| |||
3276 | 3271 | | |
3277 | 3272 | | |
3278 | 3273 | | |
3279 | | - | |
3280 | | - | |
| 3274 | + | |
3281 | 3275 | | |
3282 | 3276 | | |
3283 | 3277 | | |
| |||
3488 | 3482 | | |
3489 | 3483 | | |
3490 | 3484 | | |
3491 | | - | |
| 3485 | + | |
3492 | 3486 | | |
3493 | 3487 | | |
3494 | 3488 | | |
| |||
3582 | 3576 | | |
3583 | 3577 | | |
3584 | 3578 | | |
3585 | | - | |
3586 | | - | |
| 3579 | + | |
3587 | 3580 | | |
3588 | 3581 | | |
3589 | 3582 | | |
| |||
0 commit comments