[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#302478: marked as done (linux-kernel-headers: [asm/ioctl.h] _IOC_TYPECHECK trick fails under g++-3.4/4.0)



Your message dated Thu, 07 Jul 2005 13:49:16 +0900
with message-id <81u0j75igj.wl@omega.webmasters.gr.jp>
and subject line Closing bugs that was tagged as fixed-in-experimental
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 1 Apr 2005 00:07:24 +0000
>From jwnimmer@alum.mit.edu Thu Mar 31 16:07:24 2005
Return-path: <jwnimmer@alum.mit.edu>
Received: from gluck.debian.org [192.25.206.10] 
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1DH9h6-0008Pq-00; Thu, 31 Mar 2005 16:07:24 -0800
Received: from argonauts.vanu.com [64.1.227.20] 
	by gluck.debian.org with smtp (Exim 3.35 1 (Debian))
	id 1DH9h5-0002Zj-00; Thu, 31 Mar 2005 17:07:23 -0700
Received: (qmail 19926 invoked from network); 1 Apr 2005 00:06:22 -0000
Received: from unknown (HELO anaconda.vanu.com) (207.145.65.18)
  by argonauts.vanu.com with SMTP; 1 Apr 2005 00:06:22 -0000
Received: (qmail 6599 invoked by uid 0); 1 Apr 2005 00:06:22 -0000
Received: from raiders.vanu.com (192.168.0.17)
  by anaconda.vanu.com with SMTP; 1 Apr 2005 00:06:22 -0000
Content-Type: multipart/mixed; boundary="===============1277579233=="
MIME-Version: 1.0
From: Jeremy Nimmer <jwnimmer@alum.mit.edu>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: linux-kernel-headers: [asm/ioctl.h] _IOC_TYPECHECK trick fails under
 g++-3.4/4.0
X-Mailer: reportbug 3.9
Date: Fri, 01 Apr 2005 00:06:22 +0000
Message-Id: <E1DH9h5-0002Zj-00@gluck.debian.org>
Delivered-To: submit@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-6.0 required=4.0 tests=BAYES_00,HAS_PACKAGE,
	OUR_MTA_MSGID autolearn=no version=2.60-bugs.debian.org_2005_01_02
X-Spam-Level: 

This is a multi-part MIME message sent by reportbug.

--===============1277579233==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Package: linux-kernel-headers
Version: 2.5.999-test7-bk-17
Severity: normal
Tags: patch

/usr/include/asm/ioctl.h employs an _IOC_TYPECHECK trick to catch mis-uses
of _IOR, _IOW, and _IORW, as discussed in http://lwn.net/Articles/48354/

Unfortunately, the trick is incompatible with switch statments as compiled
by g++ version 3.4 and up.  See ioctl.cc attached below.

$ g++-3.4 --version | head -1
g++-3.4 (GCC) 3.4.4 20050314 (prerelease) (Debian 3.4.3-12)
$ g++-3.4 -Wall ioctl.cc
ioctl.cc: In function `int main(int, char**)':
ioctl.cc:6: error: `__invalid_size_argument_for_IOC' cannot appear in a constant-expression

$ g++-4.0 --version | head -1
g++-4.0 (GCC) 4.0.0 20050326 (prerelease) (Debian 4.0-0pre9)
$ g++-4.0 -Wall ioctl.cc
ioctl.cc: In function 'int main(int, char**)':
ioctl.cc:6: error: '__invalid_size_argument_for_IOC' cannot appear in a constant-expression

The compilation succeeds with g++-3.3 and earlier, and also succeeds if
ioctl.cc is compiled with any gcc (as a C file).

This problem prevents use of any ioctl request constants in C++ switch
statements, which hinders (for example) writing C++ stubs or testing
machinery for ioctl-based interfaces.

Since the trick is meant to catch dangerous uses of _IOR/W in kernel
modules, I suggest that userland code not be exposed to it.  The
attached patch enables the trick iff __KERNEL__ is defined.

Thanks,
- Jeremy

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.4.26-1-686
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

-- no debconf information

--===============1277579233==
Content-Type: text/x-c; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="ioctl.h.patch"

--- ioctl.h.orig	2005-03-31 23:37:51.000000000 +0000
+++ ioctl.h	2005-03-31 23:39:05.000000000 +0000
@@ -52,12 +52,16 @@
 	 ((nr)   << _IOC_NRSHIFT) | \
 	 ((size) << _IOC_SIZESHIFT))
 
+#ifdef __KERNEL__
 /* 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)
+#else
+#define _IOC_TYPECHECK(t) (sizeof(t))
+#endif
 
 /* used to create numbers */
 #define _IO(type,nr)		_IOC(_IOC_NONE,(type),(nr),0)

--===============1277579233==
Content-Type: text/x-c; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="ioctl.cc"

#include <asm/ioctl.h>

#define TEST_IOCTL _IOR('T', 1, int )

int main(int argc, char **argv) {
	switch (argc) { case TEST_IOCTL: return 1; }
	return 0;
}

--===============1277579233==--

---------------------------------------
Received: (at 302478-done) by bugs.debian.org; 7 Jul 2005 04:49:22 +0000
>From gotom@debian.or.jp Wed Jul 06 21:49:22 2005
Return-path: <gotom@debian.or.jp>
Received: from omega.webmasters.gr.jp (webmasters.gr.jp) [218.44.239.78] 
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1DqOK7-0006NN-00; Wed, 06 Jul 2005 21:49:19 -0700
Received: from omega.webmasters.gr.jp (localhost [127.0.0.1])
	by webmasters.gr.jp (Postfix) with ESMTP
	id 5F0A1DEB3C; Thu,  7 Jul 2005 13:49:16 +0900 (JST)
Date: Thu, 07 Jul 2005 13:49:16 +0900
Message-ID: <81u0j75igj.wl@omega.webmasters.gr.jp>
From: GOTO Masanori <gotom@debian.org>
To: 266115-done@bugs.debian.org, 253568-done@bugs.debian.org,
	263348-done@bugs.debian.org, 301073-done@bugs.debian.org,
	302478-done@bugs.debian.org, 271355-done@bugs.debian.org,
	290212-done@bugs.debian.org, 268078-done@bugs.debian.org,
	283597-done@bugs.debian.org
Cc: GOTO Masanori <gotom@debian.org>
Subject: Closing bugs that was tagged as fixed-in-experimental
User-Agent: Wanderlust/2.9.9 (Unchained Melody) SEMI/1.14.3 (Ushinoya)
 FLIM/1.14.3 (=?ISO-8859-4?Q?Unebigory=F2mae?=) APEL/10.3 Emacs/21.2
 (i386-debian-linux-gnu) MULE/5.0 (SAKAKI)
MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya")
Content-Type: text/plain; charset=US-ASCII
Delivered-To: 302478-done@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-3.0 required=4.0 tests=BAYES_00 autolearn=no 
	version=2.60-bugs.debian.org_2005_01_02
X-Spam-Level: 
X-CrossAssassin-Score: 9

I duploaded linux-kernel-headers 2.6.12.0-1 into unstable, so that
I've closed bugs now as follows:

  266115, 253568, 263348, 301073, 302478, 271355, 290212, 268078, 283597

These bugs were already fixed, they were tagged as
fixed-in-experimental.  If you still have any problems, please report
your problem and reopen it again.

Regards,
-- gotom



Reply to: