Commit d4cdc46
wifi: iwlegacy: Fix "field-spanning write" warning in il_enqueue_hcmd()
iwlegacy uses command buffers with a payload size of 320
bytes (default) or 4092 bytes (huge). The struct il_device_cmd type
describes the default buffers and there is no separate type describing
the huge buffers.
The il_enqueue_hcmd() function works with both default and huge
buffers, and has a memcpy() to the buffer payload. The size of
this copy may exceed 320 bytes when using a huge buffer, which
now results in a run-time warning:
memcpy: detected field-spanning write (size 1014) of single field "&out_cmd->cmd.payload" at drivers/net/wireless/intel/iwlegacy/common.c:3170 (size 320)
To fix this:
- Define a new struct type for huge buffers, with a correctly sized
payload field
- When using a huge buffer in il_enqueue_hcmd(), cast the command
buffer pointer to that type when looking up the payload field
Reported-by: Martin-Éric Racine <[email protected]>
References: https://bugs.debian.org/1062421
References: https://bugzilla.kernel.org/show_bug.cgi?id=219124
Signed-off-by: Ben Hutchings <[email protected]>
Fixes: 54d9469 ("fortify: Add run-time WARN for cross-field memcpy()")
Tested-by: Martin-Éric Racine <[email protected]>
Tested-by: Brandon Nielsen <[email protected]>
Acked-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://patch.msgid.link/ZuIhQRi/[email protected]1 parent 34b6954 commit d4cdc46
2 files changed
+24
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3122 | 3122 | | |
3123 | 3123 | | |
3124 | 3124 | | |
| 3125 | + | |
3125 | 3126 | | |
3126 | 3127 | | |
3127 | 3128 | | |
| |||
3157 | 3158 | | |
3158 | 3159 | | |
3159 | 3160 | | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
3160 | 3171 | | |
3161 | 3172 | | |
3162 | 3173 | | |
| |||
3170 | 3181 | | |
3171 | 3182 | | |
3172 | 3183 | | |
3173 | | - | |
| 3184 | + | |
3174 | 3185 | | |
3175 | 3186 | | |
3176 | 3187 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
560 | 560 | | |
561 | 561 | | |
562 | 562 | | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
563 | 575 | | |
564 | 576 | | |
565 | 577 | | |
| |||
0 commit comments