All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zheng Liu <gnehzuil.liu@gmail.com>
To: jon ernst <jonernst07@gmail.com>
Cc: linux-ext4@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>
Subject: [PATCH] vfs: add missing check for __O_TMPFILE in fcntl_init() (Re: [PATCH] ext4: fix...)
Date: Thu, 25 Jul 2013 08:13:19 +0800	[thread overview]
Message-ID: <20130725001319.GA12994@gmail.com> (raw)
In-Reply-To: <CAGW2f1HgtwdekeETXpZvm-KT6Sdw1bUas799yWjQ_jZp3kwaug@mail.gmail.com>

On Wed, Jul 24, 2013 at 09:58:45PM +0000, jon ernst wrote:
> > My purpose is to trigger this bug and fix it.  So I manually define this
> > flag for my convenience.
> >
> >> I saw it has
> >> been defined in header file. (fcntl.h) Did I miss anything?
> >
> > I guess that you might 'include <fcntl.h>' header file, right?  But the
> > O_TMPFILE is defined in $LINUX/include/uapi/asm-generic/fcntl.h.  So
> > maybe compiler couldn't find this header file.
> >
> > Regards,
> >                                                 - Zheng
> --
> Got it. Thank you.  BTW, the weird thing is I didn't see any
> discussion on ext4 mailing list before Al Viro committed this change.
> The first time I heard about this is someone reporting a bug about it.
> Document about this FLAG might be necessary.

Oh, this flag has been discussed in linux-fsdevel mailing list [1].
Maybe you don't subscribe it.

1. https://lkml.org/lkml/2013/7/3/181

> Also, about this code:
> 
> /* a horrid kludge trying to make sure that this will fail on old kernels */
> #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
> 
> why not doing something like this:
> 
> #ifndef O_TMPFILE
> /* a horrid kludge trying to make sure that this will fail on old kernels */
> #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
> #endif

Sorry, I don't take a closer look at that thread.  I look at the code,
and it seems that there is no any rule about adding '#ifndef XXX'.
Meanwhile, I notice a comment:

/*
 * When introducing new O_* bits, please check its uniqueness in fcntl_init().
 */

But we are missing adding O_TMPFILE flag in fcntl_init().  So I attach a
patch below.

Al, could you please answer this question?  Thanks.

Regards,
                                                - Zheng

Subject: [PATCH] vfs: add missing check for __O_TMPFILE in fcntl_init()

From: Zheng Liu <wenqing.lz@taobao.com>

As comment in include/uapi/asm-generic/fcntl.h described, when
introducing new O_* bits, we need to check its uniqueness in
fcntl_init().  But __O_TMPFILE bit is missing.  So fix it.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
---
*This patch is against ext4/dev tree.*

 fs/fcntl.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/fcntl.c b/fs/fcntl.c
index 6599222..65343c3 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -730,14 +730,14 @@ static int __init fcntl_init(void)
 	 * Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY
 	 * is defined as O_NONBLOCK on some platforms and not on others.
 	 */
-	BUILD_BUG_ON(19 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32(
+	BUILD_BUG_ON(20 - 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	| */
 		__O_SYNC	| O_DSYNC	| FASYNC	|
 		O_DIRECT	| O_LARGEFILE	| O_DIRECTORY	|
 		O_NOFOLLOW	| O_NOATIME	| O_CLOEXEC	|
-		__FMODE_EXEC	| O_PATH
+		__FMODE_EXEC	| O_PATH	| __O_TMPFILE
 		));
 
 	fasync_cache = kmem_cache_create("fasync_cache",
-- 
1.7.9.7


  reply	other threads:[~2013-07-25  0:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17 16:19 kernel BUG at fs/ext4/namei.c:2572! Dave Jones
2013-07-19  1:17 ` Zheng Liu
2013-07-19 12:14 ` [PATCH] ext4: fix a bug when we try to open a file with O_TMPFILE flag Zheng Liu
2013-07-19 19:31   ` Darrick J. Wong
2013-07-19 20:01     ` Dave Jones
2013-07-19 23:36   ` Al Viro
2013-07-20 16:37     ` Zheng Liu
2013-07-21  0:56       ` Theodore Ts'o
2013-07-21  2:45     ` [GIT PULL] " Theodore Ts'o
2013-07-21  3:16       ` Linus Torvalds
2013-07-23  7:51   ` jon ernst
2013-07-23  9:59     ` Zheng Liu
2013-07-23 13:39       ` jon ernst
2013-07-23 23:38         ` Zheng Liu
2013-07-24 21:58           ` jon ernst
2013-07-25  0:13             ` Zheng Liu [this message]
2013-07-25  1:17               ` [PATCH] vfs: add missing check for __O_TMPFILE in fcntl_init() (Re: [PATCH] ext4: fix...) jon ernst
2013-07-29  6:17               ` Zheng Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130725001319.GA12994@gmail.com \
    --to=gnehzuil.liu@gmail.com \
    --cc=jonernst07@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.