Re: [PATCH] afs: Replace simple_strtoul with kstrtoul in afs_parse_address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/30/25 7:35 AM, Jeffrey E Altman wrote:
On 5/27/2025 4:49 AM, Su Hui wrote:
kstrtoul() is better because simple_strtoul() ignores overflow which
may lead to unexpected results.

Signed-off-by: Su Hui<suhui@xxxxxxxxxxxx>
---

Su Hui,

Thank you for the contribution but I do not believe this patch is correct.

Oh, really sorry for my stupid mistake. Thanks for your review too :) .
The second block is required even if the simple_stroul() is replaced by kstrtoul() as it protects against an input string which does not contain the optional subnet mask but has some other characters after the address.

afs_parse_address() already has its own overflow checks following the simple_strtoul() call which is specific to the interpretation of the allowed subnet mask values.
Agreed, it's my fault that I only see the pattern about 'simple_strtoxx(....)' and 'if (*p)'.....

Do you see an overflow condition which would not be caught by those checks which would be caught by use of kstrtoul()?
Actually, no example in reality.
If p can equal to '0xffffffffffffffff0000000000000001', simple_strtoul() and kstroul() all transform 'p' to unsigned long value '0x1'. But kstrtoul() return an error and we can know overflow happens.  If 'p' can be a very long string, kstroul() make sense.

Su Hui





[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux