Re: [PATCH 3/5] bfq: Check kstrtoul() return value

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

 



On Sat, 2017-09-02 at 01:37 +0800, weiping zhang wrote:
> 2017-09-02 1:14 GMT+08:00 Paolo Valente <paolo.valente@xxxxxxxxxx>:
> > Il giorno 30 ago 2017, alle ore 20:42, Bart Van Assche <bart.vanassche@xxxxxxx> ha scritto:
> > > 
> > > Make sysfs writes fail for invalid numbers instead of storing
> > > uninitialized data copied from the stack. This patch removes
> > > all uninitialized_var() occurrences from the BFQ source code.
> > > 
> > > Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxx>
> > > Cc: Paolo Valente <paolo.valente@xxxxxxxxxx>
> > 
> > Acked-by: Paolo Valente <paolo.valente@xxxxxxxxxx>
> 
> how about using simple_strtoul  which was used in cfq/mq-iosched.c
> *var = simple_strtoul(p, &p, 10);
> 
> if invalid string came from sysfs, this function just return 0,
> and there are validations after every calling bfq_var_store.

Hello Weiping,

Sorry but I do not like this proposal because:
* If invalid input is provided writing into a sysfs attribute should fail
  instead of ignoring the invalid input silently.
* simple_strtoul() is considered obsolete and must not be used in new code.
  From include/linux/kernel.h:

/* Obsolete, do not use.  Use kstrto<foo> instead */

extern unsigned long simple_strtoul(const char *,char **,unsigned int);
extern long simple_strtol(const char *,char **,unsigned int);
extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
extern long long simple_strtoll(const char *,char **,unsigned int);

Bart.




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux