Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3007164ybx; Sun, 3 Nov 2019 08:40:17 -0800 (PST) X-Google-Smtp-Source: APXvYqwsbwJ+Yd4rZIN0YYcoU1LbP3EOzx+9V4foiglq0OuDWtMtT8APClGJUWXhSoSXyMMSG0pX X-Received: by 2002:a50:870c:: with SMTP id i12mr24119832edb.16.1572799217539; Sun, 03 Nov 2019 08:40:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572799217; cv=none; d=google.com; s=arc-20160816; b=WU/Gmj802sk4d83BvtzZYBbdmDCURrvtYPCuwqfwsvSzcrIl5vvBLn2Sji67hJOqj2 TApPZsw6qWHJ7JvkkqE6yGKdTtv5nfkMODxTe5WjFokytkv2IbAeoZwONit6euaChl7F tQD+mBnGIvGyVKVl5+Et6fPOiYxXj6wY4U5jEwi+Vjwq09/tUwAkkhEW4hcONSGsre7Z WeEbMKryXQnz+LTHV3FVig5iHgJ25qXwBcsGyNTycBGKPM0TJyVgP1YeYme9fozwxuaq SoLVJ6DmQQwHqdfdIjXIbStoOox1YHdC7d158108u1j8aBZsQi6rf79Jo+UltA8uLXgg O2Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Tg0i6brKqvzgSjb76broRV0px0leCLpn2X0tX+wYwU8=; b=w+0alCt6ip3OtlpEih2/iQDQzxeP8s9klC2dhX60Xq6ae/B25ecDnezIlVGM7XW9If E13UiOkpuZPBqUF3ZLekeRj3h8JVKjEugvZVrgQapj7jtvFA1WUF6EhUtQEZzE9P9baz f1Xd3ZK+q4sZn2ADRX+6ZkyEZR1QQ0SdFQQWCDfhKhrdGAVqJN5TmVVSrflSZqAKsk6J 0lpZ6uSdtwBmbVgVQ+lDHK/a9+d3mQgcsAcaM3qyD831OxLqeXywSlZQvHYMzrT0fFkh Knz/D9a5C/RbSkv8YTdWRUw6JjFL+9inmdSH5jaXwv73tSzqqxfw32o6hRaCaQnQPbCC jawQ== 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 j11si5474021edj.43.2019.11.03.08.39.41; Sun, 03 Nov 2019 08:40:17 -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 S1727846AbfKCQf1 (ORCPT + 99 others); Sun, 3 Nov 2019 11:35:27 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:39232 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727717AbfKCQf1 (ORCPT ); Sun, 3 Nov 2019 11:35:27 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iRIqa-0000LY-4u; Sun, 03 Nov 2019 16:35:24 +0000 Date: Sun, 3 Nov 2019 16:35:24 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Ritesh Harjani , linux-kernel@vger.kernel.org, wugyuan@cn.ibm.com, jlayton@kernel.org, hsiangkao@aol.com, Jan Kara , Linus Torvalds Subject: [RFC] lookup_one_len_unlocked() lousy calling conventions Message-ID: <20191103163524.GO26530@ZenIV.linux.org.uk> References: <20190927044243.18856-1-riteshh@linux.ibm.com> <20191015040730.6A84742047@d06av24.portsmouth.uk.ibm.com> <20191022133855.B1B4752050@d06av21.portsmouth.uk.ibm.com> <20191022143736.GX26530@ZenIV.linux.org.uk> <20191022201131.GZ26530@ZenIV.linux.org.uk> <20191023110551.D04AE4C044@d06av22.portsmouth.uk.ibm.com> <20191101234622.GM26530@ZenIV.linux.org.uk> <20191102172229.GT20975@paulmck-ThinkPad-P72> <20191102180842.GN26530@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191102180842.GN26530@ZenIV.linux.org.uk> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 02, 2019 at 06:08:42PM +0000, Al Viro wrote: > It is converging to a reasonably small and understandable surface, actually, > most of that being in core pathname resolution. Two big piles of nightmares > left to review - overlayfs and (somewhat surprisingly) setxattr call chains, > the latter due to IMA/EVM/LSM insanity... One thing found while digging through overlayfs (and responsible for several remaining pieces from the assorted pile): lookup_one_len_unlocked() calling conventions are wrong for its callers. Namely, 11 out of 12 callers really want ERR_PTR(-ENOENT) on negatives. Most of them take care to check, some rely upon that being impossible in their case. Interactions with dentry turning positive right after lookup_one_len_unlocked() has returned it are of varying bugginess... The only exception is ecryptfs, where we do lookup in the underlying fs on ecryptfs_lookup() and want to retain a negative dentry if we get one. Not sure what's the best way to handle that - it looks like we want a primitive with different behaviour on negatives, so the most conservative variant would be to add such, leaving lookup_one_len_unlocked() use for ecryptfs (and dealing with barriers properly in there), with everybody else switching to lookup_positive_unlocked(), or whatever we call that new primitive. Other variants: 1) add a primitve with existing lookup_one_len_unlocked() behaviour, changing lookup_one_len_unlocked() itselt to new calling conventions. Switch ecryptfs to that, drop now-useless checks from other callers. 2) get rid of pinning negative underlying dentries in ecryptfs. The cost will be doing lookup in underlying layer twice on something like mkdir(2), the second one quite likely served out of dcache. That would make _all_ callers of lookup_one_len_unlocked() need the same calling conventions. Preferences?