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]
Message-ID: <niuy3o2sk54mycvircqoykvj4pwo5ds4dfehzpmuehuwpznx3u@u3fhw6656xpk>
Date: Thu, 27 Feb 2025 15:09:12 +0100
From: Joel Granados <joel.granados@...nel.org>
To: Wen Yang <wen.yang@...ux.dev>
Cc: "Eric W. Biederman" <ebiederm@...ssion.com>, 
	Luis Chamberlain <mcgrof@...nel.org>, Kees Cook <keescook@...omium.org>, 
	Christian Brauner <brauner@...nel.org>, Dave Young <dyoung@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5] sysctl: simplify the min/max boundary check

On Thu, Jan 30, 2025 at 10:32:14PM +0800, Wen Yang wrote:
> 
> 
> On 2025/1/28 01:51, Eric W. Biederman wrote:
> > Joel Granados <joel.granados@...nel.org> writes:
> > 
...
> > that use extra1 or extra2 for something besides min and max.  Then
> > remove extra1 and extra2.  At the end it is simpler and requires the
> > same or a little less space.
> > 
> > That was and remains my suggestion.
> > 
> 
> Thanks for your valuable suggestions. We will continue to move forward along
> it and need your more guidance.
> 
> But there are also a few codes that do take the extra{1, 2} as pointers, for
> example:
> 
> int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
>                           proc_handler *handler)
> {
> ...
>         for (i = 0; i < NEIGH_VAR_GC_INTERVAL; i++) {
>                 t->neigh_vars[i].data += (long) p;
>                 t->neigh_vars[i].extra1 = dev;
>                 t->neigh_vars[i].extra2 = p;
>         }
> ...
> }
> 
> static void neigh_proc_update(const struct ctl_table *ctl, int write)
> {
>         struct net_device *dev = ctl->extra1;
>         struct neigh_parms *p = ctl->extra2;
>         struct net *net = neigh_parms_net(p);
>         int index = (int *) ctl->data - p->data;
> ...
> }
> 
> 
> So could we modify it in this way to make it compatible with these two
> situations:
> 
> @@ -137,8 +137,16 @@ struct ctl_table {
>         umode_t mode;
>         proc_handler *proc_handler;     /* Callback for text formatting */
>         struct ctl_table_poll *poll;
> -       void *extra1;
> -       void *extra2;
> +       union {
> +               struct {
> +                       void *extra1;
> +                       void *extra2;
> +               };
> +               struct {
> +                       unsigned long min;
> +                       unsigned long max;
> +               };
> +       };
>  } __randomize_layout;

I'm still not convinced that a union is the best way out of this. I have
postponed reviewing this for several weeks, but I'm slowly coming back
to it.

Thx for your suggestion

Best


-- 

Joel Granados

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ