KASSERT(val != 0) not triggering in linux_errno.c reading outside of array
Hans Petter Selasky
hps at selasky.org
Tue Nov 3 10:27:25 UTC 2020
On 2020-11-03 11:17, xtouqh at hotmail.com wrote:
> Hans Petter Selasky wrote:
>> Hi,
>>
>> Should:
>>
>> for (i = 1; i < sizeof(linux_errtbl); i++) {
>>
>> Be:
>>
>> for (i = 1; i < sizeof(linux_errtbl)/sizeof(linux_errtbl[0]);
>> i++) {
>>
>>
>> Or:
>>
>> for (i = 1; i < (int)nitems(linux_errtbl); i++) {
>
> That's right, and I added the same comment in the review. My question
> is different though -- with the issue present, KASSERT() should have
> triggered (there are 0 values with incorrect indexes, added printf()
> confirms that) exposing the bug, but it does not -- WHY? -- I just want
> to understand what's going on.
Hi,
You would need to run kgdb to dump the content of linux_errtbl and
beyond to see what data is there.
If the linux_errtbl is in the .text section then likely some other table
follows after it, likely with non-zero data, so the KASSERT() doesn't
trigger :-(
--HPS
More information about the freebsd-hackers
mailing list