[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1537993482.28767.34.camel@sipsolutions.net>
Date: Wed, 26 Sep 2018 22:24:42 +0200
From: Johannes Berg <johannes@...solutions.net>
To: linux-wireless@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH] netlink: add policy attribute range validation
Another thing to note:
Given the union of validation_data pointer and min/max, we'll always get
into this:
> + /* validate range */
> + if (pt->min || pt->max) {
if validation_data is set, but of course end up taking the default case,
where nothing further happens:
> + default:
> + /* no further validation */
> + validate = false;
> + break;
> + }
> +
> + if (validate && (value < pt->min || value > pt->max)) {
> + NL_SET_ERR_MSG_ATTR(extack, nla,
> + "integer out of range");
> + return -ERANGE;
> + }
> + }
> +
> return 0;
I'm not *entirely* happy with this, but I haven't been able to come up
with a way that doesn't do this, doesn't duplicate the nla types list
(NLA_{U,S}{8,16,32,64}) in the code, and also loads the attribute value
only if validation is needed.
johannes
Powered by blists - more mailing lists