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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210928085554.2299495-1-arnd@kernel.org>
Date:   Tue, 28 Sep 2021 10:55:50 +0200
From:   Arnd Bergmann <arnd@...nel.org>
To:     Kent Overstreet <kmo@...erainc.com>
Cc:     Arnd Bergmann <arnd@...db.de>, Jens Axboe <axboe@...nel.dk>,
        Coly Li <colyli@...e.de>, linux-kernel@...r.kernel.org
Subject: [PATCH] [v2] bcache: hide variable-sized types from uapi header check

From: Arnd Bergmann <arnd@...db.de>

The headers_check helper complains about a GNU extension in
one of the exported headers:

linux/bcache.h:354:2: warning: field '' with variable sized type 'union jset::(anonymous at ./usr/include/linux/bcache.h:354:2)' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
        BKEY_PADDED(uuid_bucket);
        ^
linux/bcache.h:134:2: note: expanded from macro 'BKEY_PADDED'
        union { struct bkey key; __u64 key ## _pad[BKEY_PAD]; }
        ^

Address this by enclosing the GNU extensions in an #ifdef: Since the
header check is done with --std=c90, this shuts up the warning and makes
it possible to include the header file C90 user space applications, but
allows applications built with --std=gnu89 or higher to use those
parts.

Another alternative would be to exclude this header from the check,
but the GNU extension check seems more sensible.

Fixes: 81ab4190ac17 ("bcache: Pull on disk data structures out into a separate header")
Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
v2: use __STRICT_ANSI__ check instead of __KERNEL__.

I think this version is better than the first, let me know if that
works for you.
---
 include/uapi/linux/bcache.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h
index cf7399f03b71..b7901e986193 100644
--- a/include/uapi/linux/bcache.h
+++ b/include/uapi/linux/bcache.h
@@ -23,9 +23,13 @@ static inline void SET_##name(type *k, __u64 v)			\
 struct bkey {
 	__u64	high;
 	__u64	low;
+#ifndef __STRICT_ANSI__
+	/* gcc extension not meant for user space */
 	__u64	ptr[];
+#endif
 };
 
+#ifndef __STRICT_ANSI__
 #define KEY_FIELD(name, field, offset, size)				\
 	BITMASK(name, struct bkey, field, offset, size)
 
@@ -127,6 +131,8 @@ static inline struct bkey *bkey_idx(const struct bkey *k, unsigned int nr_keys)
 
 	return (struct bkey *) (d + nr_keys);
 }
+#endif
+
 /* Enough for a key with 6 pointers */
 #define BKEY_PAD		8
 
-- 
2.29.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ