lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 13 Jan 2011 09:50:14 +0200
From:	Lucian Adrian Grijincu <lucian.grijincu@...il.com>
To:	David Miller <davem@...emloft.net>
Cc:	netdev@...r.kernel.org, tgraf@...radead.org, kuznet@....inr.ac.ru,
	pekkas@...core.fi, jmorris@...ei.org, yoshfuji@...ux-ipv6.org,
	kaber@...sh.net, opurdila@...acom.com, ddvlad@...edu.org
Subject: Re: [PATCH] ipv4: devconf: start IPV4_DEVCONF_* from 0

On Thu, Jan 13, 2011 at 4:47 AM, David Miller <davem@...emloft.net> wrote:
> From: Lucian Adrian Grijincu <lucian.grijincu@...il.com>
> Date: Wed, 12 Jan 2011 12:19:10 +0200
>
>> The IPV4_DEVCONF_* enums are never exposed to the userspace and it
>> would make code simpler to remove all the useless (-1) adjustments.
>
> Starting values like this at "1" is usually done on purpose.
>
> It allows "0" to be illegal or mean "none", and thus easily trapping
> cases where the value fails to be initialized properly.  In this way
> the illegal sentinel "0" doesn't take up any space either.


Just that no one checks for zero as invalid anywhere.

We pass the enum names everywhere as parameters. And wherever we need
to use those values we must make sure to subtract 1 every time.

And some things work ok, but it's not entirely obvious why.

For example:
	struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX] (...) = {
                DEVINET_SYSCTL_COMPLEX_ENTRY(FORWARDING, "forwarding",
                                             devinet_sysctl_forward),

This works ok because the DEVINET_SYSCTL_* macros subtract 1 from each
array index.

Because the size of the array is __IPV4_DEVCONF_MAX (without
subtracting 1), there's an extra element at the end and because this
is a global definition it gets initialized with zeros just as required
by register_net_sysctl_table: the last element's procname must be zero
to indicate end-of-array.

Yes it works, but there does not seem to be a good reason why to
complicate things like this (again the sentinel nature of zero is not
used in any place here).


-- 
 .
..: Lucian
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ