On Mon, 2020-10-05 at 12:25 -0700, Jakub Kicinski wrote:
> On Mon, 05 Oct 2020 20:58:57 +0200 Johannes Berg wrote:
> > On Mon, 2020-10-05 at 08:57 -0700, Jakub Kicinski wrote:
> > > @@ -47,19 +61,16 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info 
> > > *req_info,
> > >           NL_SET_ERR_MSG(extack, "request header missing");
> > >           return -EINVAL;
> > >   }
> > > + /* Use most permissive header policy here, ops should specify their
> > > +  * actual header policy via NLA_POLICY_NESTED(), and the real
> > > +  * validation will happen in genetlink code.
> > > +  */
> > >   ret = nla_parse_nested(tb, ETHTOOL_A_HEADER_MAX, header,
> > > -                        ethnl_header_policy, extack);
> > > +                        ethnl_header_policy_stats, extack);  
> > 
> > Would it make sense to just remove the validation here? It's already
> > done, so it just costs extra cycles and can't really fail, and if there
> > are more diverse policies in the future this might also very quickly get
> > out of hand?
> 
> I was slightly worried I missed a command and need last line of defence,

Ah. I was just about to suggest to put it into the family policy/maxattr
but that won't work of course since this is nested.

But actually what you _could_ put there is a dummy policy (non-NULL
pointer) with a maxattr of 0, and then all attrs will be completely
rejected for a command where the policy was missed.

Not if you missed the NLA_POLICY_NESTED() link, though.

johannes

Reply via email to