Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1618696ybf; Sun, 1 Mar 2020 13:57:58 -0800 (PST) X-Google-Smtp-Source: APXvYqzM38w66zfCk3qUh1QeGYg3c6NASFqN9TKUQez6vZkh8LI6/RSygB/TU9y4bjTSzQNIKy61 X-Received: by 2002:a9d:70ce:: with SMTP id w14mr7255932otj.194.1583099878342; Sun, 01 Mar 2020 13:57:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583099878; cv=none; d=google.com; s=arc-20160816; b=LZ5nXgV4SmgI/lPqc/f+MD/4p74xBVE1tEzrSn0eMZ90Udo3qsyEBTz5bLbj30pVoo V+EOW7/t9/8/8hh68ej9CMPpLEDL3QNYceswjbz972C8TRLkQB6rD4d+rwlUMl7bF2/M j3SL+z1OMhhiDeW58XhNiI2s/ErVP92SHdGKvpz83tzarpDa6kKZ6ZDwtK9yrycyrCfN WIfvUC2cBHQoaI32eM8UIoXef0kI7uStEcuTtO0srUth4MPhptWHWmoc9pAG8NCPSSWs 0cccN5UKXEXE+unNwMA5lqzA0X/UNalZovNZ63Sv4s6x5hntqaCBteQr4q3A2MNPI79s 9KJw== 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=9IAqUwAYcLHdIP/NfD01sBB5kXPdjJIFJij2K/I9dlc=; b=ci2AKP73TWyStizMiJVNQYmdEJx/mtPPpJc4DxpTfA3d3Jj0RmTXjzwpcxYw4FKU1V hgZ9RrPKEjONH2DZRBaulM2TnenI5AaGZcXWBrY/iBdTpNT/pyMzVf6jCAoxneBOaYgD PjOTYZDEkjVTUW7uU5GtAX4v21ukiVPGF3mbBy/Nz+zbnrkl8JOem9HwCfJo1T/2TLAJ y5HF+nm7I6h+tzaZaFd3eTy4/s9GZ0HJvtF3Rpu3ukuTrgpv3/3G7pihSTWvTJxgrja7 bLePnUnAbF4WTHHZZGwSoWf0ou+SvIXmOc2pUT2begNxTQtJGC1qpyyTpoik8wkbQo8Z q0eQ== 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 l1si4963669otn.213.2020.03.01.13.57.46; Sun, 01 Mar 2020 13:57:58 -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 S1727213AbgCAV4Y (ORCPT + 99 others); Sun, 1 Mar 2020 16:56:24 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:41554 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726592AbgCAVwm (ORCPT ); Sun, 1 Mar 2020 16:52:42 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8WVs-003fM4-Sm; Sun, 01 Mar 2020 21:52:40 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Linus Torvalds Subject: [RFC][PATCH v3 04/55] follow_automount() doesn't need the entire nameidata Date: Sun, 1 Mar 2020 21:51:49 +0000 Message-Id: <20200301215240.873899-4-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200301215240.873899-1-viro@ZenIV.linux.org.uk> References: <20200301215125.GA873525@ZenIV.linux.org.uk> <20200301215240.873899-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 Only the address of ->total_link_count and the flags. And fix an off-by-one is ELOOP detection - make it consistent with symlink following, where we check if the pre-increment value has reached 40, rather than check the post-increment one. [kudos to Christian Brauner for spotted braino] Signed-off-by: Al Viro --- fs/namei.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 39dd56f5171f..6721c5f7e9d5 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1208,7 +1208,7 @@ EXPORT_SYMBOL(follow_up); * - return -EISDIR to tell follow_managed() to stop and return the path we * were called with. */ -static int follow_automount(struct path *path, struct nameidata *nd) +static int follow_automount(struct path *path, int *count, unsigned lookup_flags) { struct dentry *dentry = path->dentry; @@ -1223,13 +1223,12 @@ static int follow_automount(struct path *path, struct nameidata *nd) * as being automount points. These will need the attentions * of the daemon to instantiate them before they can be used. */ - if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY | + if (!(lookup_flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY | LOOKUP_OPEN | LOOKUP_CREATE | LOOKUP_AUTOMOUNT)) && dentry->d_inode) return -EISDIR; - nd->total_link_count++; - if (nd->total_link_count >= 40) + if (count && (*count)++ >= MAXSYMLINKS) return -ELOOP; return finish_automount(dentry->d_op->d_automount(path), path); @@ -1290,7 +1289,8 @@ static int follow_managed(struct path *path, struct nameidata *nd) /* Handle an automount point */ if (flags & DCACHE_NEED_AUTOMOUNT) { - ret = follow_automount(path, nd); + ret = follow_automount(path, &nd->total_link_count, + nd->flags); if (ret < 0) break; continue; -- 2.11.0