Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp875975ybv; Sat, 22 Feb 2020 17:25:36 -0800 (PST) X-Google-Smtp-Source: APXvYqwUAVLGeENVplSE5k2SDbuxanGFcdoPoSCMd9UBvlhO/bcmjHhuAVCKG3UAtUA/Q8qAfJaS X-Received: by 2002:a05:6830:10d7:: with SMTP id z23mr34655767oto.114.1582421136233; Sat, 22 Feb 2020 17:25:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582421136; cv=none; d=google.com; s=arc-20160816; b=wEr+KLqVQOib8xCwPyllGZ6T70LukWJmU1hz7WnElfgsMrmUk0+DVMCgwoAky6RFkr 0nUbg5FKpzCC4zBM78hTnWM5UTqAGyMGjhpj0zvXYKxE9OFfPy7qGGCNw2s8e75w0RUH lTZ20dHXTyLh5gaHCBHamOAlf2biUyFd/vuiBniD+wQdwYdNcH9PL6Qoc9xzu7Xschfs GoaOgA16ZU0XWpzsB3ii0add7ucZbFrZUYP/pw2WsvVyC1354+xELavo+VmfjKAEd8X5 QReRah4cdIjAGd81/gSIdTFcSIvztDkXu5ZDe/OOgeO7mlGV63wnhfAqMBu5K7l2G1jk doYQ== 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=sTTLvnJV/RPrppLHhecqnSfi8n/Le4U8b/lJaiXyHTM=; b=lKa6xlRRhsQFmDQZVH6aPVUnUOgY/oEkO8uovCxRwCbTbK5pnkm+EHF555oqnUwZry SWVip1tFx+7mwj7GrJsCXTMaONcCSAJUlmmkdOL6H2MtVWLtSm1AS5OThPXJ5WF8RIU5 J+MMfqmvIxWjkx8PiN6yYeMBanqyb1wPwWTMldtDVn4tqR+dE58Ax4CTHVMnOlbatRw+ iSouU/RxUODV2bxvvd//1XqN19s1RSfQRrL99v7oE0IaeDnx7wNNSPksuXzgoLIl7JUd eqAX2RzWcLCtjxzc16L23Ql2DY25vgX5j7BO0JnPcY233iJBzsLYDkeNVVMav+86Zf6V Mo9Q== 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 k66si3027020oih.200.2020.02.22.17.25.24; Sat, 22 Feb 2020 17:25:36 -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 S1727391AbgBWBYS (ORCPT + 99 others); Sat, 22 Feb 2020 20:24:18 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:50238 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726983AbgBWBYR (ORCPT ); Sat, 22 Feb 2020 20:24:17 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j5g00-00HDlf-QO; Sun, 23 Feb 2020 01:24:07 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Linus Torvalds Subject: [RFC][PATCH v2 27/34] atomic_open(): return the right dentry in FMODE_OPENED case Date: Sun, 23 Feb 2020 01:16:19 +0000 Message-Id: <20200223011626.4103706-27-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 ->atomic_open() might have used a different alias than the one we'd passed to it; in "not opened" case we take care of that, in "opened" one we don't. Currently we don't care downstream of "opened" case which alias to return; however, that will change shortly when we get to unifying may_open() calls. It's not hard to get right in all cases, anyway. Signed-off-by: Al Viro --- fs/namei.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/namei.c b/fs/namei.c index a7730bbee162..c2244ee4b2f0 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2956,11 +2956,15 @@ static struct dentry *atomic_open(struct nameidata *nd, struct dentry *dentry, d_lookup_done(dentry); if (!error) { if (file->f_mode & FMODE_OPENED) { + int acc_mode = op->acc_mode; + if (unlikely(dentry != file->f_path.dentry)) { + dput(dentry); + dentry = dget(file->f_path.dentry); + } /* * We didn't have the inode before the open, so check open * permission here. */ - int acc_mode = op->acc_mode; if (file->f_mode & FMODE_CREATED) { WARN_ON(!(open_flag & O_CREAT)); fsnotify_create(dir, dentry); -- 2.11.0