mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
netlink: allow NLA_NESTED to specify nested policy to validate
Now that we have a validation_data pointer, and the len field in the policy is unused for NLA_NESTED, we can allow using them both to have nested validation. This can be nice in code, although we still have to use nla_parse_nested() or similar which would also take a policy; however, it also serves as documentation in the policy without requiring a look at the code. Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
c29f1845b2
commit
9a659a35ba
2 changed files with 25 additions and 2 deletions
14
lib/nlattr.c
14
lib/nlattr.c
|
|
@ -155,6 +155,20 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
|
|||
*/
|
||||
if (attrlen == 0)
|
||||
break;
|
||||
if (attrlen < NLA_HDRLEN)
|
||||
goto out_err;
|
||||
if (pt->validation_data) {
|
||||
err = nla_validate(nla_data(nla), nla_len(nla), pt->len,
|
||||
pt->validation_data, extack);
|
||||
if (err < 0) {
|
||||
/*
|
||||
* return directly to preserve the inner
|
||||
* error message/attribute pointer
|
||||
*/
|
||||
return err;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (pt->len)
|
||||
minlen = pt->len;
|
||||
|
|
|
|||
Loading…
Reference in a new issue