audit: use nlmsg_len() to get message payload length
authorMathias Krause <minipli@googlemail.com>
Mon, 30 Sep 2013 20:04:25 +0000 (22:04 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 3 Jan 2014 04:33:17 +0000 (04:33 +0000)
commitf42c03d9cd1b0f1ff1c76aa4456ee15984cc721d
tree371571c9d9ce61eef7bd088a6d48b39468788455
parent71deebc1112584a061ffef2d1c703bef17fd3c80
audit: use nlmsg_len() to get message payload length

commit 4d8fe7376a12bf4524783dd95cbc00f1fece6232 upstream.

Using the nlmsg_len member of the netlink header to test if the message
is valid is wrong as it includes the size of the netlink header itself.
Thereby allowing to send short netlink messages that pass those checks.

Use nlmsg_len() instead to test for the right message length. The result
of nlmsg_len() is guaranteed to be non-negative as the netlink message
already passed the checks of nlmsg_ok().

Also switch to min_t() to please checkpatch.pl.

Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Eric Paris <eparis@redhat.com>
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
[bwh: Backported to 3.2: there aren't any optional fields for AUDIT_TTY_SET
 so adjust the size test similarly as for AUDIT_SET]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
kernel/audit.c