Re: [PATCH] sysctl: Avoid open coded arithmetic in memory allocator functions

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

 



On Sat, Oct 16, 2021 at 05:28:28PM +0200, Len Baker wrote:
> +static size_t new_dir_size(size_t namelen)
> +{
> +	size_t bytes;
> +
> +	if (check_add_overflow(sizeof(struct ctl_dir), sizeof(struct ctl_node),
> +			       &bytes))
> +		return SIZE_MAX;
> +	if (check_add_overflow(bytes, array_size(sizeof(struct ctl_table), 2),
> +			       &bytes))
> +		return SIZE_MAX;
> +	if (check_add_overflow(bytes, namelen, &bytes))
> +		return SIZE_MAX;
> +	if (check_add_overflow(bytes, (size_t)1, &bytes))
> +		return SIZE_MAX;
> +
> +	return bytes;
> +}

I think this is overkill.  All these structs are small and namelen is
supplied by the kernel, not specified by userspace.  It really complicates
the code, and I don't see the advantage.




[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