Received: by 10.213.65.68 with SMTP id h4csp461839imn; Sat, 17 Mar 2018 10:24:18 -0700 (PDT) X-Google-Smtp-Source: AG47ELuqTPKeO+VDl6m55bzxRn3zJjt78BlzHdP1/BNI0+KnyE3RR6zgDyKruH0P5sDw/aIdKRX8 X-Received: by 10.101.67.135 with SMTP id m7mr1276298pgp.26.1521307458380; Sat, 17 Mar 2018 10:24:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521307458; cv=none; d=google.com; s=arc-20160816; b=tOLa4qs5LCeQkvVppUeYkGyrMSYgGXN4XAPwS8JwCPHkT5GqyAwbgLWQP+Va47/xal OB3Ipj99bh9auEc7IU+w7/sXOvmLL3cPdmotGHGgsjo2CnSvCTSJ2bQ2st+3iTNVPXjC OS5pY7kCiebuUvV1AvbQahfRneCVDAjaFGn0ZFAefupseixxL6yaDTxqvwsWlLZTElOs vAqtOuJkugk0+Zv8C9V1Xe7jtxKGp/EcAWHA2uYDXwJ5+BuXTGlHmY+7ifHJTMGjofEe lXqwSC/ofzX6Rz/Ze5WYkn9aiArrgwDskOtVIRpiawwM+uKHh5HgGw0r2rnBzF7Idw5w spoA== 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:arc-authentication-results; bh=mfOCcgyj/rjfbiXk/SLniMA/WlU5y5nXlsb7VCUao70=; b=n+3/p5qxAT3re9JWH/9TsBL/n79tcPBGTIklIAc3FSmA+PCkcCxLEOYn6F6lR7bPcp 2wL2TrswFxkrMimSMyZokZOwrcS5ENR6pkQGUcd+eUXj+a+PKRLfXd4gSFTPKu8cdnFl A3JAehl0j8GTLrtJAx5ehc7o7xVCRxJuMXkHW6P7U4X/7yDov1+e2Y8WZ1XV31RN8aVa mcUBGPNZ1f455wUVt7pEU8H44sW/qqjOV1x+O5nU9ItZ6uS1pQMkyAOlvBnocnrPIFBv gZmFk3wiYJ2qgZqPM20noHyAPCqYKiDv4S3SHnzB+X5MJPXGo41Fw0Y2xsMC1t1MQcJv xN8g== 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 b34-v6si3558402pld.249.2018.03.17.10.24.04; Sat, 17 Mar 2018 10:24:18 -0700 (PDT) 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 S1753838AbeCQRWW (ORCPT + 99 others); Sat, 17 Mar 2018 13:22:22 -0400 Received: from isilmar-4.linta.de ([136.243.71.142]:35194 "EHLO isilmar-4.linta.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753333AbeCQRVN (ORCPT ); Sat, 17 Mar 2018 13:21:13 -0400 Received: from light.dominikbrodowski.net (isilmar.linta [10.0.0.1]) by isilmar-4.linta.de (Postfix) with ESMTPS id ADB9C200917; Sat, 17 Mar 2018 17:21:10 +0000 (UTC) Received: by light.dominikbrodowski.net (Postfix, from userid 1000) id DD99520CF0; Sat, 17 Mar 2018 18:09:29 +0100 (CET) Date: Sat, 17 Mar 2018 18:09:29 +0100 From: Dominik Brodowski To: Arnd Bergmann Cc: Linux Kernel Mailing List , Linus Torvalds , Al Viro , Andy Lutomirski , Ingo Molnar , Andrew Morton Subject: Re: [PATCH v2 24/36] fs: add ksys_unlink() wrapper; remove in-kernel calls to sys_unlink() Message-ID: <20180317170929.GC3351@light.dominikbrodowski.net> References: <20180315190529.20943-1-linux@dominikbrodowski.net> <20180315190529.20943-25-linux@dominikbrodowski.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 15, 2018 at 09:21:39PM +0100, Arnd Bergmann wrote: > On Thu, Mar 15, 2018 at 8:05 PM, Dominik Brodowski > wrote: > > Using this wrapper allows us to avoid the in-kernel calls to the > > sys_unlink() syscall. > > > > Cc: Al Viro > > Cc: Andrew Morton > > Signed-off-by: Dominik Brodowski > > --- > > include/linux/syscalls.h | 11 +++++++++++ > > init/do_mounts.h | 2 +- > > init/do_mounts_initrd.c | 4 ++-- > > init/do_mounts_rd.c | 2 +- > > init/initramfs.c | 4 ++-- > > 5 files changed, 17 insertions(+), 6 deletions(-) > > > > diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h > > index 8f0f99702e7a..31aea3873de7 100644 > > --- a/include/linux/syscalls.h > > +++ b/include/linux/syscalls.h > > @@ -971,4 +971,15 @@ int ksys_chdir(const char __user *filename); > > int ksys_sync_file_range(int fd, loff_t offset, loff_t nbytes, > > unsigned int flags); > > > > +/* > > + * The following kernel syscall equivalents are just wrappers to fs-internal > > + * functions. Therefore, provide stubs to be inlined at the callsites. > > + */ > > +extern long do_unlinkat(int dfd, struct filename *name); > > + > > +static inline long ksys_unlink(const char __user *pathname) > > +{ > > + return do_unlinkat(AT_FDCWD, getname(pathname)); > > +} > > Why does this take a __user pointer? > > > static inline int create_dev(char *name, dev_t dev) > > { > > - sys_unlink(name); > > + ksys_unlink(name); > > return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev)); > > } > > > > diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c > > index c19d9070134e..784576b633fd 100644 > > --- a/init/do_mounts_initrd.c > > +++ b/init/do_mounts_initrd.c > > @@ -128,11 +128,11 @@ bool __init initrd_load(void) > > * mounted in the normal path. > > */ > > if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) { > > - sys_unlink("/initrd.image"); > > + ksys_unlink("/initrd.image"); > > handle_initrd(); > > return true; > > } > > } > > - sys_unlink("/initrd.image"); > > + ksys_unlink("/initrd.image"); > > return false; > > In all callers we seem to have regular kernel strings, so I think > you should skip the getname() and change the argument to > a regular pointer. In line with my explanations in other messages, I have added the following paragraph to the commit message: In the near future, all callers of ksys_unlink() should be converted to call do_unlinkat() directly or, at least, to operate on regular kernel pointers. Thanks, Dominik