Re: [PATCH v1 2/6] lib: scanf: handle integer overflows in vsscanf

2019-03-11 Thread Konstantin Khlebnikov
On 11.03.2019 0:52, Linus Torvalds wrote: On Sun, Mar 10, 2019 at 2:06 PM Rasmus Villemoes wrote: IIRC, this has been attempted before, causing a userspace regression because some sysfs/procfs file matched with %u or %x, and somebody wrote -1 to get 0x . .. which is correct anyway. T

Re: [PATCH v1 2/6] lib: scanf: handle integer overflows in vsscanf

2019-03-10 Thread Linus Torvalds
On Sun, Mar 10, 2019 at 2:06 PM Rasmus Villemoes wrote: > > IIRC, this has been attempted before, causing a userspace regression > because some sysfs/procfs file matched with %u or %x, and somebody wrote > -1 to get 0x . .. which is correct anyway. That's how scanf is supposed to work. I

Re: [PATCH v1 2/6] lib: scanf: handle integer overflows in vsscanf

2019-03-10 Thread Rasmus Villemoes
On 10/03/2019 17.56, Konstantin Khlebnikov wrote: > Traditional scanf implementations ignore integer overflows because > C language standard allows here undefined behavior (§7.21.6.2 #10). > > So, sane and safe behavior wouldn't harm anything. > > This patch carefully checks integer overflows and

[PATCH v1 2/6] lib: scanf: handle integer overflows in vsscanf

2019-03-10 Thread Konstantin Khlebnikov
Traditional scanf implementations ignore integer overflows because C language standard allows here undefined behavior (§7.21.6.2 #10). So, sane and safe behavior wouldn't harm anything. This patch carefully checks integer overflows and stops matching if result does not fit into appropriate type b