All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lutomirski <luto@mit.edu>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: O_TMPFILE fs corruption (Re: Linux 3.11-rc4)
Date: Sun, 4 Aug 2013 21:45:11 -0700	[thread overview]
Message-ID: <CAObL_7HipLJ7Rwz4q-eFZa4KhHF2jrXg+HJmu6ZAjhZi6Q=syQ@mail.gmail.com> (raw)
In-Reply-To: <CA+55aFw9AY2GLC3xieuy7jgFwsUePJ+kety-AHqFxkP1pPUAVw@mail.gmail.com>

On Sun, Aug 4, 2013 at 8:45 PM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
> The patch looks right to me - we should pass in similar flags for the
> create case as for tmpfile to the filesystem.

Alternatively, in case anyone ever wants to add more O_TMPFILE-related
flags, open could return -EINVAL if __O_TMPFILE is set and mode
contains bits outside S_IALLUGO.  Given the ABI discussion about
O_TMPFILE, this might be useful some day.

--Andy

>
> But let's make sure we're all on the same page. Al?
>
>                  Linus
>
> On Sun, Aug 4, 2013 at 7:34 PM, Andy Lutomirski <luto@mit.edu> wrote:
>> On 08/04/2013 02:09 PM, Linus Torvalds wrote:
>>>
>>> It's that time of the week again..
>>
>>
>> I still get filesystem corruption with O_TMPFILE.  The program below, run as
>> flinktest foo proc (or flinktest foo linkat if you're root) will produce a
>> bogus inode.  On ext4, once the inode is gone from cache, the inode will be
>> impossible to delete and will require a fsck to fix
>>
>> A patch (not necessarily the appropriate fix) is here:
>>
>> http://article.gmane.org/gmane.linux.kernel/1537088
>>
>> --- cut here ---
>>
>> #include <stdio.h>
>> #include <err.h>
>> #include <fcntl.h>
>> #include <unistd.h>
>> #include <string.h>
>>
>> #define __O_TMPFILE 020000000
>> #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
>> #define AT_EMPTY_PATH 0x1000
>>
>> int main(int argc, char **argv)
>> {
>>   char buf[128];
>>
>>   if (argc != 3)
>>     errx(1, "Usage: flinktest PATH linkat|proc");
>>
>>   int fd = open(".", O_TMPFILE | O_RDWR, 0600);
>>   if (fd == -1)
>>     err(1, "O_TMPFILE");
>>   write(fd, "test", 4);
>>
>>   if (!strcmp(argv[2], "linkat")) {
>>     if (linkat(fd, "", AT_FDCWD, argv[1], AT_EMPTY_PATH) != 0)
>>       err(1, "linkat");
>>   } else if (!strcmp(argv[2], "proc")) {
>>     sprintf(buf, "/proc/self/fd/%d", fd);
>>     if (linkat(AT_FDCWD, buf, AT_FDCWD, argv[1], AT_SYMLINK_FOLLOW) != 0)
>>       err(1, "linkat");
>>   } else {
>>     errx(1, "invalid mode");
>>   }
>>   return 0;
>> }
>>

  reply	other threads:[~2013-08-05  4:45 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-04 21:09 Linux 3.11-rc4 Linus Torvalds
2013-08-05  2:34 ` O_TMPFILE fs corruption (Re: Linux 3.11-rc4) Andy Lutomirski
2013-08-05  3:45   ` Linus Torvalds
2013-08-05  4:45     ` Andrew Lutomirski [this message]
2013-08-05  8:26     ` Christoph Hellwig
2013-08-05 16:04       ` Jörn Engel
2013-08-05 14:31     ` Al Viro
2013-08-05  4:20 ` Linux 3.11-rc4 Felipe Contreras
2013-08-05 13:29   ` Oleg Nesterov
2013-08-05 14:27     ` Felipe Contreras
2013-08-05 14:39       ` Oleg Nesterov
2013-08-05 17:02         ` Felipe Contreras
2013-08-05 17:11           ` Oleg Nesterov
2013-08-05 17:40             ` Felipe Contreras
2013-08-05 17:56               ` Oleg Nesterov
2013-08-05 17:39     ` Linus Torvalds
2013-08-05 17:43       ` Felipe Contreras
2013-08-05 18:08         ` Felipe Contreras
2013-08-05 17:47       ` Oleg Nesterov
2013-08-05 18:46   ` Oleg Nesterov
2013-08-05 18:54     ` Linus Torvalds
2013-08-05 18:57       ` Oleg Nesterov
2013-08-05 19:06         ` Linus Torvalds
2013-08-06 15:43   ` [PATCH 0/1] (Was: Linux 3.11-rc4) Oleg Nesterov
2013-08-06 15:43     ` [PATCH 1/1] Revert "ptrace: PTRACE_DETACH should do flush_ptrace_hw_breakpoint(child)" Oleg Nesterov
2013-08-07 12:05     ` [PATCH 0/1] (Was: Linux 3.11-rc4) Grazvydas Ignotas
2013-08-07 17:22       ` Oleg Nesterov
2013-08-07 19:26       ` Linus Torvalds
2013-08-07 19:27         ` Oleg Nesterov
2013-08-07 19:47           ` Linus Torvalds
2013-08-08 15:41             ` Oleg Nesterov
2013-08-08 16:25               ` Linus Torvalds
2013-08-08 16:54               ` Frederic Weisbecker
2013-08-08 18:15                 ` Oleg Nesterov
2013-08-09 16:45                   ` Frederic Weisbecker
2013-08-09 17:12                     ` Oleg Nesterov

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='CAObL_7HipLJ7Rwz4q-eFZa4KhHF2jrXg+HJmu6ZAjhZi6Q=syQ@mail.gmail.com' \
    --to=luto@mit.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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.