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-prev] [day] [month] [year] [list]
Message-Id: <200808121712.19207.arnd@arndb.de>
Date:	Tue, 12 Aug 2008 17:12:18 +0200
From:	Arnd Bergmann <arnd@...db.de>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Michael Abbott <michael@...neidae.co.uk>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH]: Make ioctl.h compatible with userland

[PATCH] Make _IOC_TYPECHECK use BUILD_BUG_ON_ZERO

This converts _IOC_TYPECHECK from a link error to a compile-time
error using BUILD_BUG_ON_ZERO. This makes it possible to use
the standard _IOC macros in user space even with non-optizing
compilers.

Signed-off-by: Arnd Bergmann <arnd@...db.de>

---
On Wednesday 30 July 2008, Andrew Morton wrote:
> We could also replace that open-coded assertion with the shiny new
> BUILD_BUG_ON(), which would a) be cleaner and b) fix the problem which
> you describe.  I expect that would be quite safe, but obviously doesn't
> have all the testing which the above patch has, so shrug.

There is one significant difference: using BUILD_BUG_ON_ZERO will
break user space code that uses broken ioctl number definitions
like _IOC('x', 1, sizeof(int)) that were fixed up in the kernel
but not in external copies of the definitions.
I'm undecided whether such breakage would be a good or a bad thing.

--- a/include/asm-generic/ioctl.h
+++ b/include/asm-generic/ioctl.h
@@ -69,11 +69,9 @@
 	 ((size) << _IOC_SIZESHIFT))
 
 /* provoke compile error for invalid uses of size argument */
-extern unsigned int __invalid_size_argument_for_IOC;
-#define _IOC_TYPECHECK(t) \
-	((sizeof(t) == sizeof(t[1]) && \
-	  sizeof(t) < (1 << _IOC_SIZEBITS)) ? \
-	  sizeof(t) : __invalid_size_argument_for_IOC)
+#define _IOC_TYPECHECK(t) (sizeof(t) + \
+	BUILD_BUG_ON_ZERO(sizeof(t) != sizeof(t[1]) || \
+			  sizeof(t) >= (1 << _IOC_SIZEBITS)))
 
 /* used to create numbers */
 #define _IO(type,nr)		_IOC(_IOC_NONE,(type),(nr),0)
--
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