Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752818Ab3HEEpe (ORCPT ); Mon, 5 Aug 2013 00:45:34 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:40172 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750945Ab3HEEpd (ORCPT ); Mon, 5 Aug 2013 00:45:33 -0400 MIME-Version: 1.0 In-Reply-To: References: <51FF0F18.5020705@mit.edu> From: Andrew Lutomirski Date: Sun, 4 Aug 2013 21:45:11 -0700 X-Google-Sender-Auth: 24am1HsbwsGJgeyaHQHeFxVv4kw Message-ID: Subject: Re: O_TMPFILE fs corruption (Re: Linux 3.11-rc4) To: Linus Torvalds Cc: Al Viro , Linux Kernel Mailing List Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2293 Lines: 74 On Sun, Aug 4, 2013 at 8:45 PM, Linus Torvalds 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 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 >> #include >> #include >> #include >> #include >> >> #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; >> } >> -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/