diff options
author | Mike Frysinger <vapier@gentoo.org> | 2016-11-14 20:04:44 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2016-11-14 20:04:44 +0000 |
commit | 3dd0867b44edb81ced68cfe5776cca836c2d5311 (patch) | |
tree | 73f8223a316b635314a565fbbe8557c077c9f04f /4.8/00_all_0008-netlink-drop-int-cast-on-length-arg-in-NLMSG_OK.patch | |
parent | add more packages for testing (diff) | |
download | linux-headers-patches-3dd0867b44edb81ced68cfe5776cca836c2d5311.tar.gz linux-headers-patches-3dd0867b44edb81ced68cfe5776cca836c2d5311.tar.bz2 linux-headers-patches-3dd0867b44edb81ced68cfe5776cca836c2d5311.zip |
initial 4.8 patchset based on last 4.7 patchset
Diffstat (limited to '4.8/00_all_0008-netlink-drop-int-cast-on-length-arg-in-NLMSG_OK.patch')
-rw-r--r-- | 4.8/00_all_0008-netlink-drop-int-cast-on-length-arg-in-NLMSG_OK.patch | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/4.8/00_all_0008-netlink-drop-int-cast-on-length-arg-in-NLMSG_OK.patch b/4.8/00_all_0008-netlink-drop-int-cast-on-length-arg-in-NLMSG_OK.patch new file mode 100644 index 0000000..f64b51c --- /dev/null +++ b/4.8/00_all_0008-netlink-drop-int-cast-on-length-arg-in-NLMSG_OK.patch @@ -0,0 +1,43 @@ +From 1c92839b48e932d6031302baeda3b9464970fd8c Mon Sep 17 00:00:00 2001 +From: Mike Frysinger <vapier@gentoo.org> +Date: Thu, 5 Mar 2015 00:26:58 -0500 +Subject: [PATCH] netlink: drop (int) cast on length arg in NLMSG_OK + +The NLMSG_OK macro compares three things: + - the len arg from the user + - a size_t: sizeof(struct nlmsghdr) + - an int: sizeof(struct nlmsghdr) casted + - an u32: the nlmsghdr->nlmsg_len member + +When building with -Wsign-compare, this macro triggers a signed compare +warning. This is because it compares len to an int, and then compares +it to a u32. If len is signed, we get a warning due to the last test. +If len is unsigned, we get a warning due to the first test. Like in +strace: +socketutils.c:145:8: warning: comparison between signed and unsigned + integer expressions [-Wsign-compare] + +Lets drop the int cast on the first sizeof. This way, once the user +casts len to an unsigned value, everything shakes out correctly. + +Signed-off-by: Mike Frysinger <vapier@gentoo.org> +--- + include/uapi/linux/netlink.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/uapi/linux/netlink.h b/include/uapi/linux/netlink.h +index 0dba4e4ed2be..56b79fbd84dc 100644 +--- a/include/uapi/linux/netlink.h ++++ b/include/uapi/linux/netlink.h +@@ -85,7 +85,7 @@ struct nlmsghdr { + #define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0))) + #define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \ + (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len))) +-#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \ ++#define NLMSG_OK(nlh,len) ((len) >= sizeof(struct nlmsghdr) && \ + (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \ + (nlh)->nlmsg_len <= (len)) + #define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len))) +-- +2.9.0 + |