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: <CO1PR11MB5089F94062C67A8D608FD939D6579@CO1PR11MB5089.namprd11.prod.outlook.com>
Date:   Thu, 29 Sep 2022 17:27:11 +0000
From:   "Keller, Jacob E" <jacob.e.keller@...el.com>
To:     Jakub Kicinski <kuba@...nel.org>,
        Pablo Neira Ayuso <pablo@...filter.org>
CC:     "davem@...emloft.net" <davem@...emloft.net>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "edumazet@...gle.com" <edumazet@...gle.com>,
        "pabeni@...hat.com" <pabeni@...hat.com>,
        Johannes Berg <johannes@...solutions.net>,
        Nikolay Aleksandrov <razor@...ckwall.org>,
        Nicolas Dichtel <nicolas.dichtel@...nd.com>,
        Guillaume Nault <gnault@...hat.com>,
        Florent Fourcot <florent.fourcot@...irst.fr>,
        "Florian Westphal" <fw@...len.de>,
        Jamal Hadi Salim <jhs@...atatu.com>,
        Hangbin Liu <liuhangbin@...il.com>
Subject: RE: [PATCH net-next RESEND] genetlink: reject use of nlmsg_flags for
 new commands



> -----Original Message-----
> From: Jakub Kicinski <kuba@...nel.org>
> Sent: Thursday, September 29, 2022 8:55 AM
> To: Pablo Neira Ayuso <pablo@...filter.org>
> Cc: davem@...emloft.net; netdev@...r.kernel.org; edumazet@...gle.com;
> pabeni@...hat.com; Johannes Berg <johannes@...solutions.net>; Nikolay
> Aleksandrov <razor@...ckwall.org>; Nicolas Dichtel
> <nicolas.dichtel@...nd.com>; Guillaume Nault <gnault@...hat.com>; Florent
> Fourcot <florent.fourcot@...irst.fr>; Florian Westphal <fw@...len.de>; Jamal
> Hadi Salim <jhs@...atatu.com>; Keller, Jacob E <jacob.e.keller@...el.com>;
> Hangbin Liu <liuhangbin@...il.com>
> Subject: Re: [PATCH net-next RESEND] genetlink: reject use of nlmsg_flags for
> new commands
> 
> On Thu, 29 Sep 2022 17:49:46 +0200 Pablo Neira Ayuso wrote:
> > On Thu, Sep 29, 2022 at 08:06:50AM -0700, Jakub Kicinski wrote:
> > > > no bail out for incorrectly set NLM_F_DUMP flag?
> > >
> > > Incorrectly? Special handling is because we want to make sure both bits
> > > are set for DUMP, if they are not we'll not clear them here and the
> > > condition below will fire. Or do you mean some other incorrectness?
> >
> > I have seen software in the past setting only one of the bits in the
> > NLM_F_DUMP bitmask to request a dump. I agree that userspace software
> > relying in broken semantics and that software should be fixed. What I
> > am discussing if silently clearing the 2 bits is the best approach.
> 
> I don't think it is and I don't think I silently clear both.
> Here's the code again:
> 
> +	flags = nlh->nlmsg_flags;
> +	if ((flags & NLM_F_DUMP) == NLM_F_DUMP) /* DUMP is 2 bits */
> +		flags &= ~NLM_F_DUMP;
> +	if (flags & ~(NLM_F_REQUEST | NLM_F_ACK | NLM_F_ECHO)) {
> +		NL_SET_ERR_MSG(extack,
> +			       "ambiguous or reserved bits set in nlmsg_flags");
> +		return -EINVAL;
> +	}

To clarify, my reading of whats going on is that we first see if NLM_F_DUMP is set (both bits!) and if they *are* then we remove them from the set being considered  in the following check, thus they won't be reported as an error.

However, if only one of the bits is set, then they will flag the 2nd error and thus be caught as ambiguous.

Since we modify a local copy of flags, this doesn't modify the actual nlmsg_flags field.

This is somewhat tricky but I don't see another way to approach this unless we duplicate the NL_SET_ERR_MSG.

Thanks,
Jake

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ