Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp858009imm; Wed, 11 Jul 2018 12:10:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgperKSs6faZepgMX1EdfWtzdLlAyzgkEK0he0YwzQMBWgKODrbX0W55Mg0N7MBsSYMkF/QAd X-Received: by 2002:a63:e742:: with SMTP id j2-v6mr14197357pgk.114.1531336252350; Wed, 11 Jul 2018 12:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531336252; cv=none; d=google.com; s=arc-20160816; b=A7X4IPDMUij4+aUeRZSOHcJyGRfbYjYfvTSehvChteSApslKwlrqbnPcxzRNJp3oaQ vU4zjeCSonRGDuf7fV9Gy6J/2AGEQqWsPklQRYXqwj8gQGZgO9zkfQ8ZMvaHGlzCbUhj nldOvkrAD08JSZP5nqyrptflA7v3eQDiQKFOnn4lwLH8O8dPIkFxJ/55l0XAiWr4ffgr pAEezcJk17lx7XhwTW7T5Ua6gPzklyAT7QXEBbmHgJWlBE+D/PlysbrUP8Y8ttzrwhYi pquzYZfbJtdX1Qy0kL8xc5IG/vqvWYI7wXPGpwYUEZigqJ7tZzSycRtWln9NGlQpFZXi 85/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=grwlM6XPaMOgAQgGw4ascY/LYeDlD2Fl9mrjb76e1FA=; b=G9KGcSrjnpK5sbMflI8n/N945C1OVE03XxcsvryvXyVRitfqEVmOZ+sfi4YfS7vyjn DQqCW1k9rUtEzOVuNVPCkE531+dpLxBFYCK+awJJye2u7MY2Tf0tTfR1OQ7RQrOTeRZO xTFI/SWZ25AmNqad8Mosi0N2cX7rFrNmKpEq/rgOeNiPknVUlVqpLC+UPix4xnKRbeBY sPhyr1AH2KHuBbeDndL2mwasng5aKaI2jHHitvy1OUIxftIUH1zY9zHBINdxLYlgg8xN QTxyqjtNHkVIQ/zAFAoE1bmHz8Qxl1f0CPZZXzFpd58kSqWZoEIPZalVKQssT8Np3bfI SusA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k18-v6si19476775pll.404.2018.07.11.12.10.35; Wed, 11 Jul 2018 12:10:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387846AbeGKQUq (ORCPT + 99 others); Wed, 11 Jul 2018 12:20:46 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:38518 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbeGKQUp (ORCPT ); Wed, 11 Jul 2018 12:20:45 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fdHmG-0004uZ-DQ; Wed, 11 Jul 2018 16:15:40 +0000 Date: Wed, 11 Jul 2018 17:15:40 +0100 From: Al Viro To: Linus Torvalds Cc: linux-fsdevel , Linux Kernel Mailing List , Miklos Szeredi Subject: Re: [RFC][PATCH 01/42] drm_mode_create_lease_ioctl(): fix open-coded filp_clone_open() Message-ID: <20180711161540.GS30522@ZenIV.linux.org.uk> References: <20180711021136.GN30522@ZenIV.linux.org.uk> <20180711022206.12571-1-viro@ZenIV.linux.org.uk> <20180711152555.GR30522@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180711152555.GR30522@ZenIV.linux.org.uk> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 11, 2018 at 04:25:55PM +0100, Al Viro wrote: > FWIW, looking at the ->f_flags handling, I'm seriously tempted to do > alloc_file_pseudo(inode, mnt, name, f_flags, ops). > > Reason: right now all but two callers of alloc_file_pseudo() are followed > by setting ->f_flags and for all those callers the mode argument passed > to alloc_file_pseudo() is equal to OPEN_FMODE(->f_flags value to be). > > The exceptions are __shmem_file_setup() and hugetlb_file_setup(). Both > end up with FMODE_READ | FMODE_WRITE combined with 0 (i.e. O_RDONLY) in > f_flags. Which smells like a bug in making, at the very least. > > Unless somebody has a good reason why those shouldn't have O_RDWR, > I want to add (and fold back into individual "convert to alloc_file_pseudo" > commits) the following: [snip] > Objections? Another odd beastie is do_shmat() - there we end up with > f_mode not matching f_flags, same way as in shmem and hugetlb. If we > could rectify that one as well, we'd be able to switch alloc_file_clone() > to flags as well. I would obviously prefer that kind of change to happen > before these helpers go into mainline... Actually, looking at the entire thing, I'm rather tempted to go for alloc_empty_file(f_flags, cred) setting both f_flags and f_flags-derived part of f_mode, making alloc_file_pseudo(inode, mnt, name, f_flags, ops) alloc_file_clone(base, f_flags, ops) do the same automatically as they call alloc_empty_file(). do_dentry_open() would, instead of f->f_mode |= OPEN_FMODE(f->f_flags) | FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE; do just f->f_mode |= FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE; just before calling ->open(), with comment along the lines of "usually we want those set; let ->open() remove the wrong ones if it wants to".