mbox series

[v5,0/2] netlink: export policy on validation failures

Message ID 20201008104517.44312-1-johannes@sipsolutions.net (mailing list archive)
Headers show
Series netlink: export policy on validation failures | expand

Message

Johannes Berg Oct. 8, 2020, 10:45 a.m. UTC
Export the policy used for attribute validation when it fails,
so e.g. for an out-of-range attribute userspace immediately gets
the valid ranges back.

v2 incorporates the suggestion from Jakub to have a function to
estimate the size (netlink_policy_dump_attr_size_estimate()) and
check that it does the right thing on the *normal* policy dumps,
not (just) when calling it from the error scenario.

v3 only addresses a few minor style issues.

v4 fixes up a forgotten 'git add' ... sorry.

v5 is a resend, I messed up v4's cover letter subject (saying v3)
and apparently the second patch didn't go out at all.


Tested using nl80211/iw in a few scenarios, seems to work fine
and return the policy back, e.g.

kernel reports: integer out of range
policy: 04 00 0b 00 0c 00 04 00 01 00 00 00 00 00 00 00 
        ^ padding
                    ^ minimum allowed value
policy: 04 00 0b 00 0c 00 05 00 ff ff ff ff 00 00 00 00 
        ^ padding
                    ^ maximum allowed value
policy: 08 00 01 00 04 00 00 00 
        ^ type 4 == U32

for an out-of-range case.

johannes

Comments

Jakub Kicinski Oct. 10, 2020, 3:24 a.m. UTC | #1
On Thu,  8 Oct 2020 12:45:15 +0200 Johannes Berg wrote:
> Export the policy used for attribute validation when it fails,
> so e.g. for an out-of-range attribute userspace immediately gets
> the valid ranges back.
> 
> v2 incorporates the suggestion from Jakub to have a function to
> estimate the size (netlink_policy_dump_attr_size_estimate()) and
> check that it does the right thing on the *normal* policy dumps,
> not (just) when calling it from the error scenario.
> 
> v3 only addresses a few minor style issues.
> 
> v4 fixes up a forgotten 'git add' ... sorry.
> 
> v5 is a resend, I messed up v4's cover letter subject (saying v3)
> and apparently the second patch didn't go out at all.
> 
> 
> Tested using nl80211/iw in a few scenarios, seems to work fine
> and return the policy back, e.g.
> 
> kernel reports: integer out of range
> policy: 04 00 0b 00 0c 00 04 00 01 00 00 00 00 00 00 00 
>         ^ padding
>                     ^ minimum allowed value
> policy: 04 00 0b 00 0c 00 05 00 ff ff ff ff 00 00 00 00 
>         ^ padding
>                     ^ maximum allowed value
> policy: 08 00 01 00 04 00 00 00 
>         ^ type 4 == U32
> 
> for an out-of-range case.

Applied, thanks!