Re: [PATCH] sysctl: handle table->maxlen properly for proc_dobool

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

 



On Thu, May 19, 2022 at 08:55:05PM +0800, Muchun Song wrote:
> @@ -428,6 +428,8 @@ static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp,
>  				int write, void *data)
>  {
>  	if (write) {
> +		if (*negp || (*lvalp != 0 && *lvalp != 1))
> +			return -EINVAL;
>  		*(bool *)valp = *lvalp;
>  	} else {
>  		int val = *(bool *)valp;

Is this the right approach?  Or should we do as C does and interpret
writing non-zero as true?  ie:

		*(bool *)valp = (bool)*lvalp;

(is that cast needed?  It wouldn't be if it were an int, but bool is a
bit weird)




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux