Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp870329ybv; Sat, 22 Feb 2020 17:17:53 -0800 (PST) X-Google-Smtp-Source: APXvYqyhkidDevS+/AKGrKXzuilXB15ia1EC6BnIjGE3TiOQXJVznpbpXmSutNEj35mr+TAgBfMY X-Received: by 2002:aca:f10:: with SMTP id 16mr7576166oip.117.1582420673470; Sat, 22 Feb 2020 17:17:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582420673; cv=none; d=google.com; s=arc-20160816; b=XQBO/CjrjW7LU9ajoMZJ26mCp/o3AnuqYVh+0+gHmNMjMCXcYslJxc4JP7QSdxH8S3 b5TCrjywmodvlXAo/+BGoIF7Bpq9/EAajXXUqN84V4vWnGAm4YU4yoSuSlAnFIMYSJ/s mD9llbTBrIbSkq454BP25oV1v31Agp8y4Wb3mLspjrPRnfI9hPoeKmpLLkmbfKSkG7Y0 0W6NOMeGEaa5rG2HHLv29i1d64+PEh4SIeNGNVoPTDjyPJEhsBGKs0gROkcEJabNKwCA ljJ8ryTiUF8CYr3buJdurt9/J3+3hL6H2RqGWoXGONSD1YXFuURlLWO3x3Uug23byQam rp/Q== 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=aQmwsVRA9VE/ocTOUSX+Gx9NBOqVlJ8EpBEDEpleZ0icjzg/Wkh37r3DZ2Ju6PDlj9 wywcJgssnJIk7y6FctnbXuKT2V2qiA+2qu1Ku09NxKHmuUA/+1eojm4VJMeGOp4fEoyo bJapJWE4CEFVhcf6t0ouyZVmzdvC2iNh8lSpuE7aTo6OB+k1dmMQAUMTIl8sAKi/i/5k PgF08w4pP3hC00b5KUiaHyLDLx2Xw4xSjcFxmlAr11A+HEk/c03YBOIDGT9WCz6cfhCS SlOUiwQfycyHb//tgYsa5N9Oq2Bb+8D/noz9uzvWPVCisH5xIAJRHxouDVzAXsTaA7ev rQZQ== 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 f81si3085468oig.110.2020.02.22.17.17.41; Sat, 22 Feb 2020 17:17:53 -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 S1727193AbgBWBRP (ORCPT + 99 others); Sat, 22 Feb 2020 20:17:15 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:50092 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726955AbgBWBRO (ORCPT ); Sat, 22 Feb 2020 20:17:14 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j5ft9-00HDaI-Ul; Sun, 23 Feb 2020 01:17:02 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Linus Torvalds Subject: [RFC][PATCH v2 04/34] follow_automount() doesn't need the entire nameidata Date: Sun, 23 Feb 2020 01:15:56 +0000 Message-Id: <20200223011626.4103706-4-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 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