lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1387117055-19881-1-git-send-email-doront@mellanox.com>
Date:	Sun, 15 Dec 2013 16:17:35 +0200
From:	Doron Tsur <doront@...lanox.com>
To:	linux-kernel@...r.kernel.org
Cc:	itaib@...lanox.com, Doron Tsur <doront@...lanox.com>
Subject: [PATCH] User level kernel headers -Wall -Wextra -Werror support fix For code using: #include <linux/netlink.h> NLMSG_OK -I<INSTALL_HDR_PATH>/include

Tested-by: Doron Tsur <doront@...lanox.com>
Test log:
Compilation environments:
Ubuntu 13.10, x86_64, gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
Ubuntu 13.04, x86_64, gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
[ -ftrack-macro-expansion=2 issue submitted:
  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59495 ]
Kernel headers installed at:
make -C .../linux-stable headers_install \
    INSTALL_HDR_PATH=/builds/kernel_tests_user_headers/
Pre-patch compilation:
gcc -Wall -Wextra -Werror
-I/builds/kernel_tests_pre_patch_user_headers/include
include-uapi-linux-netlink.h.test.c
In file included from include-uapi-linux-netlink.h.test.c:2:0:
include-uapi-linux-netlink.h.test.c: In function ‘main’:
/builds/kernel_tests_pre_patch_user_headers/include/linux/netlink.h:89:24:
error: comparison between signed and unsigned integer expressions
[-Werror=sign-compare]
       (nlh)->nlmsg_len <= (len))
                        ^
include-uapi-linux-netlink.h.test.c:26:5: note: in expansion of macro ‘NLMSG_OK’
     NLMSG_OK(&auxiliary_netlink_header, active_len));
     ^
cc1: all warnings being treated as errors
Post-patch:
$ gcc  -Wall -Wextra -Werror
-I/builds/kernel_tests_user_headers/include/
include-uapi-linux-netlink.h.test.c
$ ./a.out
nlmsg_len= 1, len = 1 NLMSG_OK(nlh,len) test result: 0
nlmsg_len= 1, len = 3000 NLMSG_OK(nlh,len) test result: 0
nlmsg_len= 3000, len = 1 NLMSG_OK(nlh,len) test result: 0
nlmsg_len= 3000, len = 3000 NLMSG_OK(nlh,len) test result: 1

Signed-off-by: Doron Tsur <doront@...lanox.com>
---
 include/uapi/linux/netlink.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/uapi/linux/netlink.h b/include/uapi/linux/netlink.h
index 1a85940..1884d4e 100644
--- a/include/uapi/linux/netlink.h
+++ b/include/uapi/linux/netlink.h
@@ -86,7 +86,7 @@ struct nlmsghdr {
 				  (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
 #define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
 			   (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
-			   (nlh)->nlmsg_len <= (len))
+			   (int)(nlh)->nlmsg_len <= (len))
 #define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))
 
 #define NLMSG_NOOP		0x1	/* Nothing.		*/
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ