Add a new attribute NLMSGERR_ATTR_POLICY to the extended ACK to advertise the policy, e.g. if an attribute was out of range, you'll know the range that's permissible. Add new NL_SET_ERR_MSG_ATTR_POL() and NL_SET_ERR_MSG_ATTR_POL() macros to set this, since realistically it's only useful to do this when the bad attribute (offset) is also returned. Use it in lib/nlattr.c which practically does all the policy validation. v2: - add and use netlink_policy_dump_attr_size_estimate() v3: - remove redundant break v4: - really remove redundant break ... sorry
Showing the changes to include/uapi/linux (1 of 6 files). Show all
Unified · Split
| @@ -129,6 +129,7 @@ struct nlmsgerr { · 128 unmodified lines | |||
| 129 | * @NLMSGERR_ATTR_COOKIE: arbitrary subsystem specific cookie to | 129 | * @NLMSGERR_ATTR_COOKIE: arbitrary subsystem specific cookie to |
| 130 | * be used - in the success case - to identify a created | 130 | * be used - in the success case - to identify a created |
| 131 | * object or operation or similar (binary) | 131 | * object or operation or similar (binary) |
| 132 | * @NLMSGERR_ATTR_POLICY: policy for a rejected attribute | ||
| 132 | * @__NLMSGERR_ATTR_MAX: number of attributes | 133 | * @__NLMSGERR_ATTR_MAX: number of attributes |
| 133 | * @NLMSGERR_ATTR_MAX: highest attribute number | 134 | * @NLMSGERR_ATTR_MAX: highest attribute number |
| 134 | */ | 135 | */ |
| @@ -137,6 +138,7 @@ enum nlmsgerr_attrs { · 2 unmodified lines | |||
| 137 | NLMSGERR_ATTR_MSG, | 138 | NLMSGERR_ATTR_MSG, |
| 138 | NLMSGERR_ATTR_OFFS, | 139 | NLMSGERR_ATTR_OFFS, |
| 139 | NLMSGERR_ATTR_COOKIE, | 140 | NLMSGERR_ATTR_COOKIE, |
| 141 | NLMSGERR_ATTR_POLICY, | ||
| 140 | 142 | ||
| 141 | __NLMSGERR_ATTR_MAX, | 143 | __NLMSGERR_ATTR_MAX, |
| 142 | NLMSGERR_ATTR_MAX = __NLMSGERR_ATTR_MAX - 1 | 144 | NLMSGERR_ATTR_MAX = __NLMSGERR_ATTR_MAX - 1 |