Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp876442ybv; Sat, 22 Feb 2020 17:26:18 -0800 (PST) X-Google-Smtp-Source: APXvYqzV4fDupp8BFyeL8iuQJMKULQt3T3tTLj2r1Jrp7MQnLBwBMD1QKY7hG1UkmFAib17cH+x1 X-Received: by 2002:a9d:4e93:: with SMTP id v19mr32627644otk.200.1582421178385; Sat, 22 Feb 2020 17:26:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582421178; cv=none; d=google.com; s=arc-20160816; b=iIfewR4NSDwOJuwa3zboCQ80KFmHLrG6dVa497zjEIcQSfXM9PUrBYLnrZNp29FURb mw5bQDmDinF3pjnPeg5QCkP5UFljQ2eO31mnagJcs9QYTurGEpoxBh7z1ruGv1sOeGXs jkS5Cu4dNz7q0ZYHIMmb7hWAE0jHs+oUtG263LgWCrSdEGzepJjI+KuT2Fi2fT97OIZP zVdt+LcOqwJlZUhQKyWFQ5Yiec1/eaze0i7Wh+GigcUcznIo+yzIDck8ymv0gW25UBQL OVLM4LhUzDuo0lIRduGUXnJAMhIUECIaJ4IwfA0Sq8TpSLBsuQX3MFhG/tQT0Ia2oe3p DRNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=68D11yiRGzA8bwe2gDRAI1UVWqLWR2GSqFSk/eexeMI=; b=hNuooNgZ0/7Yp1z4ihmthD/DXDa8TAb2/4FTYQLuIj0CwuOCltKKjT7kGOTE8T7VwS UJQlR6pVOp3fisSntdYJegOSD4xEIvpE57ohcltde1jrv5kxYFcW1RKnB6TtqxxWP2ta dfdaBfRz9Yha5fLyzeugK/EzwIKYuKIDZj9SipVW7cbPmLAU0mrliCnPhBzPhj4a1/MX FR2FgEIMpwF6a+j9xG0CazUBfHd4kSVJCmkO1GcBTOopCfgK64H3La+86aNyW+9WusYr gna3EwnSLb8tqo8ytrYlzsYkjFGPGWDlWSEjmrVyzS4KAMlK/eOGqyWeQaVqrYlWFCb+ nebg== 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 u5si4430794otg.66.2020.02.22.17.26.06; Sat, 22 Feb 2020 17:26:18 -0800 (PST) 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 S1727323AbgBWB0B (ORCPT + 99 others); Sat, 22 Feb 2020 20:26:01 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:50298 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726943AbgBWB0B (ORCPT ); Sat, 22 Feb 2020 20:26:01 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j5g1j-00HDq5-Jw; Sun, 23 Feb 2020 01:25:52 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Linus Torvalds Subject: [RFC][PATCH v2 33/34] do_last(): rejoin the common path even earlier in FMODE_{OPENED,CREATED} case Date: Sun, 23 Feb 2020 01:16:25 +0000 Message-Id: <20200223011626.4103706-33-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200223011626.4103706-1-viro@ZenIV.linux.org.uk> References: <20200223011154.GY23230@ZenIV.linux.org.uk> <20200223011626.4103706-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro ... getting may_create_in_sticky() checks in FMODE_OPENED case as well. Signed-off-by: Al Viro --- fs/namei.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index ce6f2864a335..37cbe7806677 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3207,14 +3207,7 @@ static const char *do_last(struct nameidata *nd, if (IS_ERR(dentry)) return ERR_CAST(dentry); - if (file->f_mode & FMODE_OPENED) { - audit_inode(nd->name, file->f_path.dentry, 0); - dput(nd->path.dentry); - nd->path.dentry = dentry; - goto finish_open_created; - } - - if (file->f_mode & FMODE_CREATED) { + if (file->f_mode & (FMODE_OPENED | FMODE_CREATED)) { dput(nd->path.dentry); nd->path.dentry = dentry; goto finish_open_created; @@ -3238,7 +3231,9 @@ static const char *do_last(struct nameidata *nd, error = complete_walk(nd); if (error) return ERR_PTR(error); - audit_inode(nd->name, nd->path.dentry, 0); +finish_open_created: + if (!(file->f_mode & FMODE_CREATED)) + audit_inode(nd->name, nd->path.dentry, 0); if (open_flag & O_CREAT) { if (d_is_dir(nd->path.dentry)) return ERR_PTR(-EISDIR); @@ -3250,7 +3245,6 @@ static const char *do_last(struct nameidata *nd, if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry)) return ERR_PTR(-ENOTDIR); -finish_open_created: do_truncate = false; acc_mode = op->acc_mode; if (file->f_mode & FMODE_CREATED) { -- 2.11.0