Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1881851ybl; Thu, 30 Jan 2020 07:39:55 -0800 (PST) X-Google-Smtp-Source: APXvYqxc7qLTYB90B6wIKMbt8IaEGSiaSjaqfZ0VW+8zT0K2d7jqqfvWLnFcW8BLu7ak6/tn4F8l X-Received: by 2002:a9d:2c2a:: with SMTP id f39mr2323741otb.301.1580398795014; Thu, 30 Jan 2020 07:39:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580398795; cv=none; d=google.com; s=arc-20160816; b=r+Fm3niBZkVEiDVO9+eRxD1RA/kbrrUP2XwJEmwSYfZtnTcy0HUfs+aJ7iS/LdkEC/ r6O/IKkWKQ8+kUnWkuM2Iymuh8rspFFtsyiN504uJj/DaSAWkHq3aJ/KMKalPnxl7WaX QCSxucG/BiOudBGXFzE9N/YMoo5/UgHu/+mNifYOmjsNxzLQyOVTmngyCtqfxubLqEY/ zUrNElOIaBTy+aCqck8KasWPLyb5imEz32/cilPk76XTjDubKLbasdZ/aITKTvZZli/S sCUqPh6Jv3e8ffLt6vyWa1nP2vE7Yyz+xGGOruqYKYIAJN3pJAXYAyl/H7gSp4mZ9Pvq 2JBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=gd2JI0DnJZ8jrp+dMOHsVNstK7hu6dHnCWf0rglMssM=; b=QLIA6ok5g2d9R8UPhzxnMnJtJM6koztLiqVTIM/ToLWy3/TeFtCR1gNnEjPHV17/9W P2uCK7T2JqKXSY+R/6QAxdZcuMjWWwFgeZxqwgLCw5zfoAoR3C0iKD19PfN45aBIr1Rv 6odSQjhlrQgLiQ5ubhnB9A8vjIadT1bahDFTI49039xhRMRFj/thC1jBERvkx2Gcv/Xs PX0Ch0+EOIp+ImLWG+oC31NCx3+bpGiiVzrEiDYKKohdqlpLoFnO+GidD6eOOqhQZUla XG9XL8NC3lhkutPQkl/gLwmnU+1JXmm8T3VP6Y8Uz+cuWrASlaQ1bx1WTj9IkOhNJzUp Dkaw== 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 t28si3318130otr.16.2020.01.30.07.39.42; Thu, 30 Jan 2020 07:39:55 -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 S1727238AbgA3Pi3 (ORCPT + 99 others); Thu, 30 Jan 2020 10:38:29 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:55710 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727158AbgA3Pi3 (ORCPT ); Thu, 30 Jan 2020 10:38:29 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixBth-004oy2-Rz; Thu, 30 Jan 2020 15:38:25 +0000 Date: Thu, 30 Jan 2020 15:38:25 +0000 From: Al Viro To: Christian Brauner Cc: linux-fsdevel@vger.kernel.org, Linus Torvalds , linux-kernel@vger.kernel.org, Aleksa Sarai , David Howells , Eric Biederman Subject: Re: [PATCH 04/17] follow_automount() doesn't need the entire nameidata Message-ID: <20200130153825.GA23230@ZenIV.linux.org.uk> References: <20200119031423.GV8904@ZenIV.linux.org.uk> <20200119031738.2681033-1-viro@ZenIV.linux.org.uk> <20200119031738.2681033-4-viro@ZenIV.linux.org.uk> <20200130144520.hnf2yk5tjalxfddn@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200130144520.hnf2yk5tjalxfddn@wittgenstein> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 30, 2020 at 03:45:20PM +0100, Christian Brauner wrote: > > - nd->total_link_count++; > > - if (nd->total_link_count >= 40) > > + if (count && *count++ >= 40) > > He, side-effects galore. :) > Isn't this incrementing the address but you want to increment the > counter? > Seems like this should be > > if (count && (*count)++ >= 40) Nice catch; incidentally, it means that usual testsuites (xfstests, LTP) are missing the automount loop detection. Hmm... Something like export $FOO over nfs4 to localhost mkdir $FOO/sub touch $FOO/a mount $SCRATCH_DEV $FOO/sub touch $FOO/sub/a cd $BAR mkdir nfs mount -t nfs localhost:$FOO nfs for i in `seq 40`; do ln -s l`expr $i - 1` l$i; done for i in `seq 40`; do ln -s m`expr $i - 1` m$i; done ln -s nfs/sub/a l0 ln -s nfs/a m0 for i in `seq 40`; do umount nfs/sub 2>/dev/null cat l$i m$i done BTW, the check of pre-increment value is more correct - it's accidental, but it does give consistency with the normal symlink following. We do allow up to 40 symlinks over the pathname resolution, not up to 39. The thing above should produce cat: l39: Too many levels of symbolic links cat: l40: Too many levels of symbolic links cat: m40: Too many levels of symbolic links Here l and m go through n + 1 symlink, ending at nfs/sub/a and nfs/a resp.; the former does trigger an automount, the latter does not. On mainline it actually starts to complain about l38, l39, l40 and m40, due to that off-by-one in follow_automount().