KSPP / linux

Linux kernel source tree (Kernel Self Protection Project)
https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project
Other
81 stars 5 forks source link

Deal with new GCC 12 -Warray-bounds warnings #190

Open kees opened 2 years ago

kees commented 2 years ago

There are a lot of new -Warray-bounds warnings with GCC 12. At least one subset is due to a GCC bug.

kees commented 2 years ago

v5.18, GCC 11 to GCC 12:

All:
$ grep warning: fedora36.log  | wc -l
182

-Warray-bounds:
$ grep warning: fedora36.log  | grep 'Warray-bounds'  | wc -l
153

OpenSSL v3
$ grep warning: fedora36.log  | grep 'Wdeprecated-declarations'  | wc -l
14

Everything else:
$ grep warning: fedora36.log  | grep -Ev 'W(array-bounds|deprecated-declarations)'  | wc -l
15

v5.18, GCC 11 to GCC 12 (without UBSAN_SHIFT):

All:
$ grep warning: f36-no-shift.log  | wc -l
177

-Warray-bounds:
$ grep warning: f36-no-shift.log  | grep 'Warray-bounds'  | wc -l
148

Not actually 5 fewer; 9 fewer, but 4 added:

$ diff -u <(grep warning: fedora36.log | sort) <(grep warning: f36-no-shift.log | sort) | diffstat
 62 |   13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Apparent false positives:

../arch/x86/kvm/emulate.c:254:27: warning: array subscript 32 is above array bounds of 'long unsigned int[17]' [-Warray-bounds]
../arch/x86/kvm/ioapic.c:213:33: warning: array subscript 32 is above array bounds of 'union kvm_ioapic_redirect_entry[24]' [-Warray-bounds]
../drivers/hwmon/lm85.c:1110:26: warning: array subscript [0, 31] is outside array bounds of 'struct lm85_autofan[3]' [-Warray-bounds]
../drivers/net/ipa/ipa_interrupt.c:196:27: warning: array subscript 30 is above array bounds of 'void (*[30])(struct ipa *, enum ipa_irq_id)' [-Warray-bounds]
../drivers/net/wireless/ath/ath9k/mac.c:373:22: warning: array subscript 32 is above array bounds of 'struct ath9k_tx_queue_info[10]' [-Warray-bounds]
../drivers/net/wireless/intel/iwlwifi/mvm/sta.c:1077:37: warning: array subscript -1 is below array bounds of 'struct iwl_mvm_tid_data[9]' [-Warray-bounds]
../kernel/sched/psi.c:730:38: warning: array subscript 32 is above array bounds of 'unsigned int[5]' [-Warray-bounds]
../kernel/sched/psi.c:730:38: warning: array subscript 32 is above array bounds of 'unsigned int[5]' [-Warray-bounds]
../sound/pci/lola/lola_pcm.c:567:64: warning: array subscript [0, 31] is outside array bounds of 'struct lola_stream[16]' [-Warray-bounds]

Masked warnings exposed?

../fs/crypto/fname.c:475:33: warning: array subscript 'struct fscrypt_nokey_name[0]' is partly outside array bounds of 'unsigned char[189]' [-Warray-bounds]
../fs/crypto/fname.c:475:33: warning: array subscript 'struct fscrypt_nokey_name[0]' is partly outside array bounds of 'unsigned char[189]' [-Warray-bounds]
../fs/crypto/fname.c:476:39: warning: array subscript 'struct fscrypt_nokey_name[0]' is partly outside array bounds of 'unsigned char[189]' [-Warray-bounds]
../fs/crypto/fname.c:476:39: warning: array subscript 'struct fscrypt_nokey_name[0]' is partly outside array bounds of 'unsigned char[189]' [-Warray-bounds]