aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Krause <minipli@googlemail.com>2013-09-30 16:04:25 -0400
committerEric Paris <eparis@redhat.com>2013-11-05 11:08:37 -0500
commit4d8fe7376a12bf4524783dd95cbc00f1fece6232 (patch)
treedb0c3dae0fa8592ed93e225a852c327d977cd4b9
parente13f91e3c57986a609c10ddf94af0546a2a97dce (diff)
audit: use nlmsg_len() to get message payload length
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> Cc: stable@vger.kernel.org # v2.6.6+ for the 1st hunk, v2.6.23+ for the 2nd 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>
-rw-r--r--kernel/audit.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/audit.c b/kernel/audit.c
index 3ce60e063aae..3ad14e6e00bd 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -771,7 +771,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
771 &status_set, sizeof(status_set)); 771 &status_set, sizeof(status_set));
772 break; 772 break;
773 case AUDIT_SET: 773 case AUDIT_SET:
774 if (nlh->nlmsg_len < sizeof(struct audit_status)) 774 if (nlmsg_len(nlh) < sizeof(struct audit_status))
775 return -EINVAL; 775 return -EINVAL;
776 status_get = (struct audit_status *)data; 776 status_get = (struct audit_status *)data;
777 if (status_get->mask & AUDIT_STATUS_ENABLED) { 777 if (status_get->mask & AUDIT_STATUS_ENABLED) {
@@ -944,7 +944,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
944 944
945 memset(&s, 0, sizeof(s)); 945 memset(&s, 0, sizeof(s));
946 /* guard against past and future API changes */ 946 /* guard against past and future API changes */
947 memcpy(&s, data, min(sizeof(s), (size_t)nlh->nlmsg_len)); 947 memcpy(&s, data, min_t(size_t, sizeof(s), nlmsg_len(nlh)));
948 if ((s.enabled != 0 && s.enabled != 1) || 948 if ((s.enabled != 0 && s.enabled != 1) ||
949 (s.log_passwd != 0 && s.log_passwd != 1)) 949 (s.log_passwd != 0 && s.log_passwd != 1))
950 return -EINVAL; 950 return -EINVAL;