]> git.baikalelectronics.ru Git - kernel.git/commit
netlink: Add strict version of nlmsg_parse and nla_parse
authorDavid Ahern <dsahern@gmail.com>
Mon, 8 Oct 2018 03:16:25 +0000 (20:16 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Oct 2018 17:39:04 +0000 (10:39 -0700)
commit30cf2c75d912e2ec665593b2735f1e5f24851170
treea3f42feae3abbe665fecebe9d5350c86ce6572fd
parent28f37d24e868d8a447da5bd4ec86b0add1d356ca
netlink: Add strict version of nlmsg_parse and nla_parse

nla_parse is currently lenient on message parsing, allowing type to be 0
or greater than max expected and only logging a message

    "netlink: %d bytes leftover after parsing attributes in process `%s'."

if the netlink message has unknown data at the end after parsing. What this
could mean is that the header at the front of the attributes is actually
wrong and the parsing is shifted from what is expected.

Add a new strict version that actually fails with EINVAL if there are any
bytes remaining after the parsing loop completes, if the atttrbitue type
is 0 or greater than max expected.

Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Christian Brauner <christian@brauner.io>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/netlink.h
lib/nlattr.c