Skip to content

Commit 61ec3a5

Browse files
jmberg-intelgregkh
authored andcommitted
netlink: validate NLA_MSECS length
commit c30bc94 upstream. L2TP for example uses NLA_MSECS like this: policy: [L2TP_ATTR_RECV_TIMEOUT] = { .type = NLA_MSECS, }, code: if (info->attrs[L2TP_ATTR_RECV_TIMEOUT]) cfg.reorder_timeout = nla_get_msecs(info->attrs[L2TP_ATTR_RECV_TIMEOUT]); As nla_get_msecs() is essentially nla_get_u64() plus the conversion to a HZ-based value, this will not properly reject attributes from userspace that aren't long enough and might overrun the message. Add NLA_MSECS to the attribute minlen array to check the size properly. Cc: Thomas Graf <[email protected]> Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0fb9f68 commit 61ec3a5

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/nlattr.c

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ static const u16 nla_attr_minlen[NLA_TYPE_MAX+1] = {
2020
[NLA_U16] = sizeof(u16),
2121
[NLA_U32] = sizeof(u32),
2222
[NLA_U64] = sizeof(u64),
23+
[NLA_MSECS] = sizeof(u64),
2324
[NLA_NESTED] = NLA_HDRLEN,
2425
};
2526

0 commit comments

Comments
 (0)