* [PATCH 0/3] O_* bit numbers uniqueness check patches
@ 2010-03-16 1:08 Wu Fengguang
2010-03-16 1:08 ` [PATCH 1/3] vfs: O_* bit numbers uniqueness check Wu Fengguang
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Wu Fengguang @ 2010-03-16 1:08 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wu Fengguang, LKML
Andrew,
These are the patches to do O_* bit numbers uniqueness check.
The first one should already be in your tree, so only
need to pull the next twos.
Thanks,
Fengguang
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] vfs: O_* bit numbers uniqueness check
2010-03-16 1:08 [PATCH 0/3] O_* bit numbers uniqueness check patches Wu Fengguang
@ 2010-03-16 1:08 ` Wu Fengguang
2010-03-16 1:08 ` [PATCH 2/3] vfs: O_* bit numbers uniqueness check fix Wu Fengguang
2010-03-16 1:08 ` [PATCH 3/3] vfs: O_* bit numbers uniqueness check fix 2 Wu Fengguang
2 siblings, 0 replies; 5+ messages in thread
From: Wu Fengguang @ 2010-03-16 1:08 UTC (permalink / raw)
To: Andrew Morton
Cc: Wu Fengguang, LKML, David Miller, Stephen Rothwell, Al Viro,
Christoph Hellwig, Eric Paris, Roland Dreier, Jamie Lokier,
Andreas Schwab
[-- Attachment #1: mutt-wfg-t61-1000-6194-5 --]
[-- Type: text/plain, Size: 1949 bytes --]
The O_* bit numbers are defined in 20+ arch/*, and can silently overlap.
Add a compile time check to ensure the uniqueness as suggested by David
Miller.
Cc: David Miller <davem@davemloft.net>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Eric Paris <eparis@redhat.com>
Cc: Roland Dreier <rdreier@cisco.com>
Cc: Jamie Lokier <jamie@shareable.org>
Cc: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
fs/fcntl.c | 14 ++++++++++++--
include/asm-generic/fcntl.h | 2 ++
2 files changed, 14 insertions(+), 2 deletions(-)
--- linux-mm.orig/fs/fcntl.c 2010-03-11 13:52:59.000000000 +0800
+++ linux-mm/fs/fcntl.c 2010-03-16 09:07:43.000000000 +0800
@@ -739,11 +739,21 @@ void kill_fasync(struct fasync_struct **
}
EXPORT_SYMBOL(kill_fasync);
-static int __init fasync_init(void)
+static int __init fcntl_init(void)
{
+ /* please add new bits here to ensure allocation uniqueness */
+ BUILD_BUG_ON(17 != HWEIGHT32(
+ O_RDONLY | O_WRONLY | O_RDWR |
+ O_CREAT | O_EXCL | O_NOCTTY |
+ O_TRUNC | O_APPEND | O_NONBLOCK |
+ __O_SYNC | O_DSYNC | FASYNC |
+ O_DIRECT | O_LARGEFILE | O_DIRECTORY |
+ O_NOFOLLOW | O_NOATIME | O_CLOEXEC
+ ));
+
fasync_cache = kmem_cache_create("fasync_cache",
sizeof(struct fasync_struct), 0, SLAB_PANIC, NULL);
return 0;
}
-module_init(fasync_init)
+module_init(fcntl_init)
--- linux-mm.orig/include/asm-generic/fcntl.h 2010-03-11 13:52:59.000000000 +0800
+++ linux-mm/include/asm-generic/fcntl.h 2010-03-12 21:26:41.000000000 +0800
@@ -4,6 +4,8 @@
#include <linux/types.h>
/*
+ * When introducing new O_* bits, please check its uniqueness in fcntl_init().
+ *
* FMODE_EXEC is 0x20
* FMODE_NONOTIFY is 0x1000000
* These cannot be used by userspace O_* until internal and external open
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] vfs: O_* bit numbers uniqueness check fix
2010-03-16 1:08 [PATCH 0/3] O_* bit numbers uniqueness check patches Wu Fengguang
2010-03-16 1:08 ` [PATCH 1/3] vfs: O_* bit numbers uniqueness check Wu Fengguang
@ 2010-03-16 1:08 ` Wu Fengguang
2010-03-16 1:08 ` [PATCH 3/3] vfs: O_* bit numbers uniqueness check fix 2 Wu Fengguang
2 siblings, 0 replies; 5+ messages in thread
From: Wu Fengguang @ 2010-03-16 1:08 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wu Fengguang, LKML, Eric Paris
[-- Attachment #1: fcntl_init-O_RDONLY --]
[-- Type: text/plain, Size: 1108 bytes --]
Follow the comment by Eric:
Until the FMODE_ and O_ bits do not overload I think we need to check
FMODE_EXEC and FMODE_NONOTIFY (if you have that one) inside fcntl_init()
as well. I guess I'll send a patch to someone ?Al? to add FMODE_EXEC to
the list....
CC: Eric Paris <eparis@redhat.com>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
fs/fcntl.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- linux-mm.orig/fs/fcntl.c 2010-03-12 21:27:12.000000000 +0800
+++ linux-mm/fs/fcntl.c 2010-03-12 23:11:46.000000000 +0800
@@ -742,13 +742,14 @@ EXPORT_SYMBOL(kill_fasync);
static int __init fcntl_init(void)
{
/* please add new bits here to ensure allocation uniqueness */
- BUILD_BUG_ON(17 != HWEIGHT32(
+ BUILD_BUG_ON(18 != HWEIGHT32(
O_RDONLY | O_WRONLY | O_RDWR |
O_CREAT | O_EXCL | O_NOCTTY |
O_TRUNC | O_APPEND | O_NONBLOCK |
__O_SYNC | O_DSYNC | FASYNC |
O_DIRECT | O_LARGEFILE | O_DIRECTORY |
- O_NOFOLLOW | O_NOATIME | O_CLOEXEC
+ O_NOFOLLOW | O_NOATIME | O_CLOEXEC |
+ FMODE_EXEC
));
fasync_cache = kmem_cache_create("fasync_cache",
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] vfs: O_* bit numbers uniqueness check fix 2
2010-03-16 1:08 [PATCH 0/3] O_* bit numbers uniqueness check patches Wu Fengguang
2010-03-16 1:08 ` [PATCH 1/3] vfs: O_* bit numbers uniqueness check Wu Fengguang
2010-03-16 1:08 ` [PATCH 2/3] vfs: O_* bit numbers uniqueness check fix Wu Fengguang
@ 2010-03-16 1:08 ` Wu Fengguang
2 siblings, 0 replies; 5+ messages in thread
From: Wu Fengguang @ 2010-03-16 1:08 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wu Fengguang, LKML, Andreas Dilger
[-- Attachment #1: fcntl_init-O_RDONLY-2 --]
[-- Type: text/plain, Size: 980 bytes --]
Follow the comment by Andreas:
It's non-obvious why there are 18 flags listed here, but the hweight
is only 17? Presumably this is because O_RDONLY has value 0, but that
should at least be
listed in a comment, or the test could be written more explicitly, like:
BUILD_BUG_ON(18 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32(
CC: Andreas Dilger <adilger@sun.com>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
fs/fcntl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- linux-mm.orig/fs/fcntl.c 2010-03-12 23:11:46.000000000 +0800
+++ linux-mm/fs/fcntl.c 2010-03-12 23:12:05.000000000 +0800
@@ -742,7 +742,7 @@ EXPORT_SYMBOL(kill_fasync);
static int __init fcntl_init(void)
{
/* please add new bits here to ensure allocation uniqueness */
- BUILD_BUG_ON(18 != HWEIGHT32(
+ BUILD_BUG_ON(19 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32(
O_RDONLY | O_WRONLY | O_RDWR |
O_CREAT | O_EXCL | O_NOCTTY |
O_TRUNC | O_APPEND | O_NONBLOCK |
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] vfs: O_* bit numbers uniqueness check
2010-03-16 1:36 [PATCH 0/3] O_* bit numbers uniqueness check patches (V2) Wu Fengguang
@ 2010-03-16 1:36 ` Wu Fengguang
0 siblings, 0 replies; 5+ messages in thread
From: Wu Fengguang @ 2010-03-16 1:36 UTC (permalink / raw)
To: Andrew Morton
Cc: Wu Fengguang, LKML, David Miller, Stephen Rothwell, Al Viro,
Christoph Hellwig, Eric Paris, Roland Dreier, Jamie Lokier,
Andreas Schwab
[-- Attachment #1: mutt-wfg-t61-1000-6194-5 --]
[-- Type: text/plain, Size: 1909 bytes --]
The O_* bit numbers are defined in 20+ arch/*, and can silently overlap.
Add a compile time check to ensure the uniqueness as suggested by David
Miller.
Cc: David Miller <davem@davemloft.net>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Eric Paris <eparis@redhat.com>
Cc: Roland Dreier <rdreier@cisco.com>
Cc: Jamie Lokier <jamie@shareable.org>
Cc: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
fs/fcntl.c | 14 ++++++++++++--
include/asm-generic/fcntl.h | 4 ++++
2 files changed, 16 insertions(+), 2 deletions(-)
--- linux-mm.orig/fs/fcntl.c 2010-03-16 09:18:28.000000000 +0800
+++ linux-mm/fs/fcntl.c 2010-03-16 09:32:17.000000000 +0800
@@ -739,11 +739,21 @@ void kill_fasync(struct fasync_struct **
}
EXPORT_SYMBOL(kill_fasync);
-static int __init fasync_init(void)
+static int __init fcntl_init(void)
{
+ /* please add new bits here to ensure allocation uniqueness */
+ BUILD_BUG_ON(17 != HWEIGHT32(
+ O_RDONLY | O_WRONLY | O_RDWR |
+ O_CREAT | O_EXCL | O_NOCTTY |
+ O_TRUNC | O_APPEND | O_NONBLOCK |
+ __O_SYNC | O_DSYNC | FASYNC |
+ O_DIRECT | O_LARGEFILE | O_DIRECTORY |
+ O_NOFOLLOW | O_NOATIME | O_CLOEXEC
+ ));
+
fasync_cache = kmem_cache_create("fasync_cache",
sizeof(struct fasync_struct), 0, SLAB_PANIC, NULL);
return 0;
}
-module_init(fasync_init)
+module_init(fcntl_init)
--- linux-mm.orig/include/asm-generic/fcntl.h 2010-03-16 09:31:16.000000000 +0800
+++ linux-mm/include/asm-generic/fcntl.h 2010-03-16 09:33:30.000000000 +0800
@@ -3,6 +3,10 @@
#include <linux/types.h>
+/*
+ * When introducing new O_* bits, please check its uniqueness in fcntl_init().
+ */
+
#define O_ACCMODE 00000003
#define O_RDONLY 00000000
#define O_WRONLY 00000001
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-03-16 1:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-16 1:08 [PATCH 0/3] O_* bit numbers uniqueness check patches Wu Fengguang
2010-03-16 1:08 ` [PATCH 1/3] vfs: O_* bit numbers uniqueness check Wu Fengguang
2010-03-16 1:08 ` [PATCH 2/3] vfs: O_* bit numbers uniqueness check fix Wu Fengguang
2010-03-16 1:08 ` [PATCH 3/3] vfs: O_* bit numbers uniqueness check fix 2 Wu Fengguang
-- strict thread matches above, loose matches on Subject: below --
2010-03-16 1:36 [PATCH 0/3] O_* bit numbers uniqueness check patches (V2) Wu Fengguang
2010-03-16 1:36 ` [PATCH 1/3] vfs: O_* bit numbers uniqueness check Wu Fengguang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox