From patchwork Thu Sep 17 08:22:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11781959 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DBF2112E for ; Thu, 17 Sep 2020 08:27:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BA7F2075E for ; Thu, 17 Sep 2020 08:27:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="g8ro5qhh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726327AbgIQI1P (ORCPT ); Thu, 17 Sep 2020 04:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726185AbgIQI1J (ORCPT ); Thu, 17 Sep 2020 04:27:09 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3B0FC061756; Thu, 17 Sep 2020 01:27:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=HKYpexQhsrJ4y+Vhn3pkHKTtzHzhQSByyD4ZaYSZNsI=; b=g8ro5qhhTYxW4cT8WB+KZezeUt mZW8CgpW9Q58rjTyaHzpp+V7qrQJllJJ5gKCvd7mWbzq23cbM+3VGCx05kWDwcIYcjSQxItjcbhPK 9fFDCmMal+UM1RSMjzlgY8DKaL4uP/jtWQ1FPl9N2s4P1KMv84GzQTjy9U36vLb4esJ88vMSL4x+F 19Ent+mF5iS+qTfSvYuNvF6aMjhq3lcVzQsU6qmeZkX5i6etFpash8aMpi7AEIN5wR9duihf2grrn jqqrfBlGzUGrHmkQI6tcDZa5XJPfeXT2KJ49WhCAc7fB+vQziVX96p8tYFJo8PdO537jENjgl7qwW iBFHs9Ig==; Received: from 089144214092.atnat0023.highway.a1.net ([89.144.214.92] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIpFq-0001D6-0R; Thu, 17 Sep 2020 08:26:59 +0000 From: Christoph Hellwig To: Al Viro Cc: Richard Henderson , Ivan Kokshaysky , Matt Turner , Trond Myklebust , Anna Schumaker , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org Subject: [PATCH 1/5] nfs: simplify nfs4_parse_monolithic Date: Thu, 17 Sep 2020 10:22:32 +0200 Message-Id: <20200917082236.2518236-2-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200917082236.2518236-1-hch@lst.de> References: <20200917082236.2518236-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Remove a level of indentation for the version 1 mount data parsing, and simplify the NULL data case a little bit as well. Signed-off-by: Christoph Hellwig --- fs/nfs/fs_context.c | 135 +++++++++++++++++++++----------------------- 1 file changed, 63 insertions(+), 72 deletions(-) diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c index 524812984e2d43..cbf6a4ba5e5806 100644 --- a/fs/nfs/fs_context.c +++ b/fs/nfs/fs_context.c @@ -1049,89 +1049,80 @@ static int nfs4_parse_monolithic(struct fs_context *fc, struct sockaddr *sap = (struct sockaddr *)&ctx->nfs_server.address; char *c; - if (data == NULL) - goto out_no_data; + if (!data) { + if (is_remount_fc(fc)) + goto done; + return nfs_invalf(fc, + "NFS4: mount program didn't pass any mount data"); + } ctx->version = 4; - switch (data->version) { - case 1: - if (data->host_addrlen > sizeof(ctx->nfs_server.address)) - goto out_no_address; - if (data->host_addrlen == 0) - goto out_no_address; - ctx->nfs_server.addrlen = data->host_addrlen; - if (copy_from_user(sap, data->host_addr, data->host_addrlen)) - return -EFAULT; - if (!nfs_verify_server_address(sap)) - goto out_no_address; - ctx->nfs_server.port = ntohs(((struct sockaddr_in *)sap)->sin_port); - - if (data->auth_flavourlen) { - rpc_authflavor_t pseudoflavor; - if (data->auth_flavourlen > 1) - goto out_inval_auth; - if (copy_from_user(&pseudoflavor, - data->auth_flavours, - sizeof(pseudoflavor))) - return -EFAULT; - ctx->selected_flavor = pseudoflavor; - } else - ctx->selected_flavor = RPC_AUTH_UNIX; - - c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN); - if (IS_ERR(c)) - return PTR_ERR(c); - ctx->nfs_server.hostname = c; - - c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN); - if (IS_ERR(c)) - return PTR_ERR(c); - ctx->nfs_server.export_path = c; - dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", c); + if (data->version != 1) + return generic_parse_monolithic(fc, data); - c = strndup_user(data->client_addr.data, 16); - if (IS_ERR(c)) - return PTR_ERR(c); - ctx->client_address = c; - - /* - * Translate to nfs_fs_context, which nfs_fill_super - * can deal with. - */ + if (data->host_addrlen > sizeof(ctx->nfs_server.address)) + goto out_no_address; + if (data->host_addrlen == 0) + goto out_no_address; + ctx->nfs_server.addrlen = data->host_addrlen; + if (copy_from_user(sap, data->host_addr, data->host_addrlen)) + return -EFAULT; + if (!nfs_verify_server_address(sap)) + goto out_no_address; + ctx->nfs_server.port = ntohs(((struct sockaddr_in *)sap)->sin_port); - ctx->flags = data->flags & NFS4_MOUNT_FLAGMASK; - ctx->rsize = data->rsize; - ctx->wsize = data->wsize; - ctx->timeo = data->timeo; - ctx->retrans = data->retrans; - ctx->acregmin = data->acregmin; - ctx->acregmax = data->acregmax; - ctx->acdirmin = data->acdirmin; - ctx->acdirmax = data->acdirmax; - ctx->nfs_server.protocol = data->proto; - nfs_validate_transport_protocol(ctx); - if (ctx->nfs_server.protocol == XPRT_TRANSPORT_UDP) - goto out_invalid_transport_udp; + if (data->auth_flavourlen) { + rpc_authflavor_t pseudoflavor; - break; - default: - goto generic; + if (data->auth_flavourlen > 1) + goto out_inval_auth; + if (copy_from_user(&pseudoflavor, data->auth_flavours, + sizeof(pseudoflavor))) + return -EFAULT; + ctx->selected_flavor = pseudoflavor; + } else { + ctx->selected_flavor = RPC_AUTH_UNIX; } + c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN); + if (IS_ERR(c)) + return PTR_ERR(c); + ctx->nfs_server.hostname = c; + + c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN); + if (IS_ERR(c)) + return PTR_ERR(c); + ctx->nfs_server.export_path = c; + dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", c); + + c = strndup_user(data->client_addr.data, 16); + if (IS_ERR(c)) + return PTR_ERR(c); + ctx->client_address = c; + + /* + * Translate to nfs_fs_context, which nfs_fill_super + * can deal with. + */ + + ctx->flags = data->flags & NFS4_MOUNT_FLAGMASK; + ctx->rsize = data->rsize; + ctx->wsize = data->wsize; + ctx->timeo = data->timeo; + ctx->retrans = data->retrans; + ctx->acregmin = data->acregmin; + ctx->acregmax = data->acregmax; + ctx->acdirmin = data->acdirmin; + ctx->acdirmax = data->acdirmax; + ctx->nfs_server.protocol = data->proto; + nfs_validate_transport_protocol(ctx); + if (ctx->nfs_server.protocol == XPRT_TRANSPORT_UDP) + goto out_invalid_transport_udp; +done: ctx->skip_reconfig_option_check = true; return 0; -generic: - return generic_parse_monolithic(fc, data); - -out_no_data: - if (is_remount_fc(fc)) { - ctx->skip_reconfig_option_check = true; - return 0; - } - return nfs_invalf(fc, "NFS4: mount program didn't pass any mount data"); - out_inval_auth: return nfs_invalf(fc, "NFS4: Invalid number of RPC auth flavours %d", data->auth_flavourlen); From patchwork Thu Sep 17 08:22:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11781981 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F2A3B112E for ; Thu, 17 Sep 2020 08:29:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF4A220715 for ; Thu, 17 Sep 2020 08:29:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="h/YwUqRP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726403AbgIQI3X (ORCPT ); Thu, 17 Sep 2020 04:29:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbgIQI3V (ORCPT ); Thu, 17 Sep 2020 04:29:21 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ECB4C06174A; Thu, 17 Sep 2020 01:29:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=V+AxwQGWoIbqc8x7A3UXP9dSWRbh6BxB+DuWCl5hM/g=; b=h/YwUqRPHztumPo41cJ1tEtgz9 MuDLUw61pdTBNB7NxT724bN3a9YeCXaM2ngSpQyPpsgR8yhrYvT+oi8RHjoUR0iJPH8w7Dh+PgTRm qy4hiUuCFsjN26N9ia32tAQLbBSeDaoPERk06Nms6kmhLZa0xeVNX3WuUK+PXKjihrTaDBMyBRLNc b51Nt9nGanfH7Gq8fUGjl3f/Sou0TimK2qSdbuvWzT1wspuA/UA2TQ5bLreG2F1vBStSrKmu5MxdM JRAJcDSJmpsJoOjHdgkfMNoeTnYc8jiM4ppZacZmMO69qmZmhcijc3giUcl0mRus7tiR4e7Q1yPZj Qsi1ghgA==; Received: from 089144214092.atnat0023.highway.a1.net ([89.144.214.92] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIpHz-0001N6-6u; Thu, 17 Sep 2020 08:29:11 +0000 From: Christoph Hellwig To: Al Viro Cc: Richard Henderson , Ivan Kokshaysky , Matt Turner , Trond Myklebust , Anna Schumaker , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org Subject: [PATCH 2/5] fs,nfs: lift compat nfs4 mount data handling into the nfs code Date: Thu, 17 Sep 2020 10:22:33 +0200 Message-Id: <20200917082236.2518236-3-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200917082236.2518236-1-hch@lst.de> References: <20200917082236.2518236-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org There is no reason the generic fs code should bother with NFS specific binary mount data - lift the conversion into nfs4_parse_monolithic instead. Signed-off-by: Christoph Hellwig --- fs/compat.c | 75 --------------------------------------------- fs/nfs/fs_context.c | 62 +++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 75 deletions(-) diff --git a/fs/compat.c b/fs/compat.c index 436d228cf71c09..9b00523d7fa571 100644 --- a/fs/compat.c +++ b/fs/compat.c @@ -19,73 +19,6 @@ #include #include "internal.h" -struct compat_nfs_string { - compat_uint_t len; - compat_uptr_t data; -}; - -static inline void compat_nfs_string(struct nfs_string *dst, - struct compat_nfs_string *src) -{ - dst->data = compat_ptr(src->data); - dst->len = src->len; -} - -struct compat_nfs4_mount_data_v1 { - compat_int_t version; - compat_int_t flags; - compat_int_t rsize; - compat_int_t wsize; - compat_int_t timeo; - compat_int_t retrans; - compat_int_t acregmin; - compat_int_t acregmax; - compat_int_t acdirmin; - compat_int_t acdirmax; - struct compat_nfs_string client_addr; - struct compat_nfs_string mnt_path; - struct compat_nfs_string hostname; - compat_uint_t host_addrlen; - compat_uptr_t host_addr; - compat_int_t proto; - compat_int_t auth_flavourlen; - compat_uptr_t auth_flavours; -}; - -static int do_nfs4_super_data_conv(void *raw_data) -{ - int version = *(compat_uint_t *) raw_data; - - if (version == 1) { - struct compat_nfs4_mount_data_v1 *raw = raw_data; - struct nfs4_mount_data *real = raw_data; - - /* copy the fields backwards */ - real->auth_flavours = compat_ptr(raw->auth_flavours); - real->auth_flavourlen = raw->auth_flavourlen; - real->proto = raw->proto; - real->host_addr = compat_ptr(raw->host_addr); - real->host_addrlen = raw->host_addrlen; - compat_nfs_string(&real->hostname, &raw->hostname); - compat_nfs_string(&real->mnt_path, &raw->mnt_path); - compat_nfs_string(&real->client_addr, &raw->client_addr); - real->acdirmax = raw->acdirmax; - real->acdirmin = raw->acdirmin; - real->acregmax = raw->acregmax; - real->acregmin = raw->acregmin; - real->retrans = raw->retrans; - real->timeo = raw->timeo; - real->wsize = raw->wsize; - real->rsize = raw->rsize; - real->flags = raw->flags; - real->version = raw->version; - } - - return 0; -} - -#define NFS4_NAME "nfs4" - COMPAT_SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name, const char __user *, type, compat_ulong_t, flags, @@ -111,14 +44,6 @@ COMPAT_SYSCALL_DEFINE5(mount, const char __user *, dev_name, if (IS_ERR(options)) goto out2; - if (kernel_type && options) { - if (!strcmp(kernel_type, NFS4_NAME)) { - retval = -EINVAL; - if (do_nfs4_super_data_conv(options)) - goto out3; - } - } - retval = do_mount(kernel_dev, dir_name, kernel_type, flags, options); out3: diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c index cbf6a4ba5e5806..222afba70bc08e 100644 --- a/fs/nfs/fs_context.c +++ b/fs/nfs/fs_context.c @@ -1039,6 +1039,65 @@ static int nfs23_parse_monolithic(struct fs_context *fc, } #if IS_ENABLED(CONFIG_NFS_V4) +struct compat_nfs_string { + compat_uint_t len; + compat_uptr_t data; +}; + +static inline void compat_nfs_string(struct nfs_string *dst, + struct compat_nfs_string *src) +{ + dst->data = compat_ptr(src->data); + dst->len = src->len; +} + +struct compat_nfs4_mount_data_v1 { + compat_int_t version; + compat_int_t flags; + compat_int_t rsize; + compat_int_t wsize; + compat_int_t timeo; + compat_int_t retrans; + compat_int_t acregmin; + compat_int_t acregmax; + compat_int_t acdirmin; + compat_int_t acdirmax; + struct compat_nfs_string client_addr; + struct compat_nfs_string mnt_path; + struct compat_nfs_string hostname; + compat_uint_t host_addrlen; + compat_uptr_t host_addr; + compat_int_t proto; + compat_int_t auth_flavourlen; + compat_uptr_t auth_flavours; +}; + +static void nfs4_compat_mount_data_conv(struct nfs4_mount_data *data) +{ + struct compat_nfs4_mount_data_v1 *compat = + (struct compat_nfs4_mount_data_v1 *)data; + + /* copy the fields backwards */ + data->auth_flavours = compat_ptr(compat->auth_flavours); + data->auth_flavourlen = compat->auth_flavourlen; + data->proto = compat->proto; + data->host_addr = compat_ptr(compat->host_addr); + data->host_addrlen = compat->host_addrlen; + compat_nfs_string(&data->hostname, &compat->hostname); + compat_nfs_string(&data->mnt_path, &compat->mnt_path); + compat_nfs_string(&data->client_addr, &compat->client_addr); + data->acdirmax = compat->acdirmax; + data->acdirmin = compat->acdirmin; + data->acregmax = compat->acregmax; + data->acregmin = compat->acregmin; + data->retrans = compat->retrans; + data->timeo = compat->timeo; + data->wsize = compat->wsize; + data->rsize = compat->rsize; + data->flags = compat->flags; + data->version = compat->version; +} + /* * Validate NFSv4 mount options */ @@ -1061,6 +1120,9 @@ static int nfs4_parse_monolithic(struct fs_context *fc, if (data->version != 1) return generic_parse_monolithic(fc, data); + if (in_compat_syscall()) + nfs4_compat_mount_data_conv(data); + if (data->host_addrlen > sizeof(ctx->nfs_server.address)) goto out_no_address; if (data->host_addrlen == 0) From patchwork Thu Sep 17 08:22:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11781987 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CF9F618 for ; Thu, 17 Sep 2020 08:31:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EECB121973 for ; Thu, 17 Sep 2020 08:31:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="c62RFStp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726260AbgIQIbb (ORCPT ); Thu, 17 Sep 2020 04:31:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726106AbgIQIba (ORCPT ); Thu, 17 Sep 2020 04:31:30 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25DB2C06174A; Thu, 17 Sep 2020 01:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=cc06p2BxoywswAJioubUiCZ1fLeFXdznz+FEzVubHRM=; b=c62RFStpjYOoUbZOLbzVBcZXQH CP6h9nBf+VzK6thMzY/OxTfZd7Nt9o6+Vzv6hafUm1iByTW4wHLrt8PZcxCcE7V8jbJHyC7OlxUo6 /kP7vbINZ5O/rM+HGpPnXTg3GTXmYbEOsOCjAsszvdzUdy17Z1fjg3E6PLeMYGdxjmkKBvPgJzRiR g63UjFJe+SOGT54e7pecWJ3k7+6uxfwikQFcwmaqf+xD0CcJHhDLz1rk/TBtxpn6hb8V7Qi2mGFML yvLMKROcSgRBY3nBNqHAP1SW6InnZct9HMGgCKFjGXmlzINAS63BgGFvnx8nBgoG3WMInh4ZQw2G7 TACxrl2Q==; Received: from 089144214092.atnat0023.highway.a1.net ([89.144.214.92] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIpK6-0001aH-6b; Thu, 17 Sep 2020 08:31:22 +0000 From: Christoph Hellwig To: Al Viro Cc: Richard Henderson , Ivan Kokshaysky , Matt Turner , Trond Myklebust , Anna Schumaker , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org Subject: [PATCH 3/5] fs: remove compat_sys_mount Date: Thu, 17 Sep 2020 10:22:34 +0200 Message-Id: <20200917082236.2518236-4-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200917082236.2518236-1-hch@lst.de> References: <20200917082236.2518236-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org compat_sys_mount is identical to the regular sys_mount now, so remove it and use the native version everywhere. Signed-off-by: Christoph Hellwig --- arch/arm64/include/asm/unistd32.h | 2 +- arch/mips/kernel/syscalls/syscall_n32.tbl | 2 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 2 +- arch/parisc/kernel/syscalls/syscall.tbl | 2 +- arch/powerpc/kernel/syscalls/syscall.tbl | 2 +- arch/s390/kernel/syscalls/syscall.tbl | 2 +- arch/sparc/kernel/syscalls/syscall.tbl | 2 +- arch/x86/entry/syscalls/syscall_32.tbl | 2 +- fs/Makefile | 1 - fs/compat.c | 57 ------------------- fs/internal.h | 3 - fs/namespace.c | 4 +- include/linux/compat.h | 6 -- include/uapi/asm-generic/unistd.h | 2 +- tools/include/uapi/asm-generic/unistd.h | 2 +- .../arch/powerpc/entry/syscalls/syscall.tbl | 2 +- .../perf/arch/s390/entry/syscalls/syscall.tbl | 2 +- 17 files changed, 14 insertions(+), 81 deletions(-) delete mode 100644 fs/compat.c diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h index 734860ac7cf9d5..5fd095d6545022 100644 --- a/arch/arm64/include/asm/unistd32.h +++ b/arch/arm64/include/asm/unistd32.h @@ -53,7 +53,7 @@ __SYSCALL(__NR_lseek, compat_sys_lseek) #define __NR_getpid 20 __SYSCALL(__NR_getpid, sys_getpid) #define __NR_mount 21 -__SYSCALL(__NR_mount, compat_sys_mount) +__SYSCALL(__NR_mount, sys_mount) /* 22 was sys_umount */ __SYSCALL(22, sys_ni_syscall) #define __NR_setuid 23 diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl b/arch/mips/kernel/syscalls/syscall_n32.tbl index f9df9edb67a407..61fa9e7013cbc1 100644 --- a/arch/mips/kernel/syscalls/syscall_n32.tbl +++ b/arch/mips/kernel/syscalls/syscall_n32.tbl @@ -167,7 +167,7 @@ 157 n32 sync sys_sync 158 n32 acct sys_acct 159 n32 settimeofday compat_sys_settimeofday -160 n32 mount compat_sys_mount +160 n32 mount sys_mount 161 n32 umount2 sys_umount 162 n32 swapon sys_swapon 163 n32 swapoff sys_swapoff diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl b/arch/mips/kernel/syscalls/syscall_o32.tbl index 195b43cf27c848..b992e89be7ff8a 100644 --- a/arch/mips/kernel/syscalls/syscall_o32.tbl +++ b/arch/mips/kernel/syscalls/syscall_o32.tbl @@ -29,7 +29,7 @@ 18 o32 unused18 sys_ni_syscall 19 o32 lseek sys_lseek 20 o32 getpid sys_getpid -21 o32 mount sys_mount compat_sys_mount +21 o32 mount sys_mount 22 o32 umount sys_oldumount 23 o32 setuid sys_setuid 24 o32 getuid sys_getuid diff --git a/arch/parisc/kernel/syscalls/syscall.tbl b/arch/parisc/kernel/syscalls/syscall.tbl index def64d221cd4fb..07efd978182fea 100644 --- a/arch/parisc/kernel/syscalls/syscall.tbl +++ b/arch/parisc/kernel/syscalls/syscall.tbl @@ -29,7 +29,7 @@ 18 common stat sys_newstat compat_sys_newstat 19 common lseek sys_lseek compat_sys_lseek 20 common getpid sys_getpid -21 common mount sys_mount compat_sys_mount +21 common mount sys_mount 22 common bind sys_bind 23 common setuid sys_setuid 24 common getuid sys_getuid diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl index c2d737ff2e7bec..a36ad4fec73c19 100644 --- a/arch/powerpc/kernel/syscalls/syscall.tbl +++ b/arch/powerpc/kernel/syscalls/syscall.tbl @@ -34,7 +34,7 @@ 18 spu oldstat sys_ni_syscall 19 common lseek sys_lseek compat_sys_lseek 20 common getpid sys_getpid -21 nospu mount sys_mount compat_sys_mount +21 nospu mount sys_mount 22 32 umount sys_oldumount 22 64 umount sys_ni_syscall 22 spu umount sys_ni_syscall diff --git a/arch/s390/kernel/syscalls/syscall.tbl b/arch/s390/kernel/syscalls/syscall.tbl index 10456bc936fb09..4b803dfbee2be9 100644 --- a/arch/s390/kernel/syscalls/syscall.tbl +++ b/arch/s390/kernel/syscalls/syscall.tbl @@ -26,7 +26,7 @@ 16 32 lchown - sys_lchown16 19 common lseek sys_lseek compat_sys_lseek 20 common getpid sys_getpid sys_getpid -21 common mount sys_mount compat_sys_mount +21 common mount sys_mount sys_mount 22 common umount sys_oldumount sys_oldumount 23 32 setuid - sys_setuid16 24 32 getuid - sys_getuid16 diff --git a/arch/sparc/kernel/syscalls/syscall.tbl b/arch/sparc/kernel/syscalls/syscall.tbl index 4af114e84f2022..d5ff798fa08f80 100644 --- a/arch/sparc/kernel/syscalls/syscall.tbl +++ b/arch/sparc/kernel/syscalls/syscall.tbl @@ -201,7 +201,7 @@ 164 64 utrap_install sys_utrap_install 165 common quotactl sys_quotactl 166 common set_tid_address sys_set_tid_address -167 common mount sys_mount compat_sys_mount +167 common mount sys_mount 168 common ustat sys_ustat compat_sys_ustat 169 common setxattr sys_setxattr 170 common lsetxattr sys_lsetxattr diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl index 9d11028736661b..5a40b226fb7b7a 100644 --- a/arch/x86/entry/syscalls/syscall_32.tbl +++ b/arch/x86/entry/syscalls/syscall_32.tbl @@ -32,7 +32,7 @@ 18 i386 oldstat sys_stat 19 i386 lseek sys_lseek compat_sys_lseek 20 i386 getpid sys_getpid -21 i386 mount sys_mount compat_sys_mount +21 i386 mount sys_mount 22 i386 umount sys_oldumount 23 i386 setuid sys_setuid16 24 i386 getuid sys_getuid16 diff --git a/fs/Makefile b/fs/Makefile index 1c7b0e3f6daa11..d72ee2ce7af080 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -37,7 +37,6 @@ obj-$(CONFIG_FS_DAX) += dax.o obj-$(CONFIG_FS_ENCRYPTION) += crypto/ obj-$(CONFIG_FS_VERITY) += verity/ obj-$(CONFIG_FILE_LOCKING) += locks.o -obj-$(CONFIG_COMPAT) += compat.o obj-$(CONFIG_BINFMT_AOUT) += binfmt_aout.o obj-$(CONFIG_BINFMT_EM86) += binfmt_em86.o obj-$(CONFIG_BINFMT_MISC) += binfmt_misc.o diff --git a/fs/compat.c b/fs/compat.c deleted file mode 100644 index 9b00523d7fa571..00000000000000 --- a/fs/compat.c +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * linux/fs/compat.c - * - * Kernel compatibililty routines for e.g. 32 bit syscall support - * on 64 bit kernels. - * - * Copyright (C) 2002 Stephen Rothwell, IBM Corporation - * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com) - * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be) - * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs - * Copyright (C) 2003 Pavel Machek (pavel@ucw.cz) - */ - -#include -#include -#include -#include -#include -#include "internal.h" - -COMPAT_SYSCALL_DEFINE5(mount, const char __user *, dev_name, - const char __user *, dir_name, - const char __user *, type, compat_ulong_t, flags, - const void __user *, data) -{ - char *kernel_type; - void *options; - char *kernel_dev; - int retval; - - kernel_type = copy_mount_string(type); - retval = PTR_ERR(kernel_type); - if (IS_ERR(kernel_type)) - goto out; - - kernel_dev = copy_mount_string(dev_name); - retval = PTR_ERR(kernel_dev); - if (IS_ERR(kernel_dev)) - goto out1; - - options = copy_mount_options(data); - retval = PTR_ERR(options); - if (IS_ERR(options)) - goto out2; - - retval = do_mount(kernel_dev, dir_name, kernel_type, flags, options); - - out3: - kfree(options); - out2: - kfree(kernel_dev); - out1: - kfree(kernel_type); - out: - return retval; -} diff --git a/fs/internal.h b/fs/internal.h index 10517ece45167f..a7cd0f64faa4ab 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -82,9 +82,6 @@ int may_linkat(struct path *link); /* * namespace.c */ -extern void *copy_mount_options(const void __user *); -extern char *copy_mount_string(const void __user *); - extern struct vfsmount *lookup_mnt(const struct path *); extern int finish_automount(struct vfsmount *, struct path *); diff --git a/fs/namespace.c b/fs/namespace.c index bae0e95b3713a3..12b431b61462b9 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -3072,7 +3072,7 @@ static void shrink_submounts(struct mount *mnt) } } -void *copy_mount_options(const void __user * data) +static void *copy_mount_options(const void __user * data) { char *copy; unsigned size; @@ -3097,7 +3097,7 @@ void *copy_mount_options(const void __user * data) return copy; } -char *copy_mount_string(const void __user *data) +static char *copy_mount_string(const void __user *data) { return data ? strndup_user(data, PATH_MAX) : NULL; } diff --git a/include/linux/compat.h b/include/linux/compat.h index b354ce58966e2d..92db17cc5c5e33 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -522,12 +522,6 @@ asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd, asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, compat_ulong_t arg); -/* fs/namespace.c */ -asmlinkage long compat_sys_mount(const char __user *dev_name, - const char __user *dir_name, - const char __user *type, compat_ulong_t flags, - const void __user *data); - /* fs/open.c */ asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_statfs __user *buf); diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h index 995b36c2ea7d8a..fc98c943760976 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h @@ -140,7 +140,7 @@ __SYSCALL(__NR_renameat, sys_renameat) #define __NR_umount2 39 __SYSCALL(__NR_umount2, sys_umount) #define __NR_mount 40 -__SC_COMP(__NR_mount, sys_mount, compat_sys_mount) +__SYSCALL(__NR_mount, sys_mount) #define __NR_pivot_root 41 __SYSCALL(__NR_pivot_root, sys_pivot_root) diff --git a/tools/include/uapi/asm-generic/unistd.h b/tools/include/uapi/asm-generic/unistd.h index 995b36c2ea7d8a..fc98c943760976 100644 --- a/tools/include/uapi/asm-generic/unistd.h +++ b/tools/include/uapi/asm-generic/unistd.h @@ -140,7 +140,7 @@ __SYSCALL(__NR_renameat, sys_renameat) #define __NR_umount2 39 __SYSCALL(__NR_umount2, sys_umount) #define __NR_mount 40 -__SC_COMP(__NR_mount, sys_mount, compat_sys_mount) +__SYSCALL(__NR_mount, sys_mount) #define __NR_pivot_root 41 __SYSCALL(__NR_pivot_root, sys_pivot_root) diff --git a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl index 3ca6fe057a0b1f..c2866c65965061 100644 --- a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +++ b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl @@ -32,7 +32,7 @@ 18 spu oldstat sys_ni_syscall 19 common lseek sys_lseek compat_sys_lseek 20 common getpid sys_getpid -21 nospu mount sys_mount compat_sys_mount +21 nospu mount sys_mount 22 32 umount sys_oldumount 22 64 umount sys_ni_syscall 22 spu umount sys_ni_syscall diff --git a/tools/perf/arch/s390/entry/syscalls/syscall.tbl b/tools/perf/arch/s390/entry/syscalls/syscall.tbl index 6a0bbea225db0d..8e0806f6c38eb0 100644 --- a/tools/perf/arch/s390/entry/syscalls/syscall.tbl +++ b/tools/perf/arch/s390/entry/syscalls/syscall.tbl @@ -26,7 +26,7 @@ 16 32 lchown - compat_sys_s390_lchown16 19 common lseek sys_lseek compat_sys_lseek 20 common getpid sys_getpid sys_getpid -21 common mount sys_mount compat_sys_mount +21 common mount sys_mount 22 common umount sys_oldumount compat_sys_oldumount 23 32 setuid - compat_sys_s390_setuid16 24 32 getuid - compat_sys_s390_getuid16 From patchwork Thu Sep 17 08:22:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11781991 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5576139A for ; Thu, 17 Sep 2020 08:33:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8DD822083B for ; Thu, 17 Sep 2020 08:33:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="NSDTpPpp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726358AbgIQIdo (ORCPT ); Thu, 17 Sep 2020 04:33:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726106AbgIQIdn (ORCPT ); Thu, 17 Sep 2020 04:33:43 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9929C06174A; Thu, 17 Sep 2020 01:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=pK3ZGE1heHTlt9wO/wdfyB7vDi2paiMLw72nt8Y8iog=; b=NSDTpPppN9I32oNKteZhXs8xN/ RMr0juqsnTEogCXyOYbtjYLoZ8WgoOWu15rdPjANN5ROBEZ7YA5cHMP3keiiK7wNbqvItjucYP1oH Yui5begMOphZn+RiAHsjTNPrtOQ2kKMlNq2N5nZptVhIafYfDnUuNduCruAqRMIdPn6dl5vhOO1jG Uj+qSc6kZnT8BnaAyLoap7rbxoSV+87qxdeurp1OW49FGACK0i17+xm25bTtTUAOTGS7HQqRTpobe /xrEEh21QSKcx1FEWPyEJWmOxEzdmL1KJ5nnieW/HigihvakI1Zd+LZcoVebDAiS3fjw2t+SlqGzi tEUUD7hA==; Received: from 089144214092.atnat0023.highway.a1.net ([89.144.214.92] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIpMD-0001fn-7r; Thu, 17 Sep 2020 08:33:33 +0000 From: Christoph Hellwig To: Al Viro Cc: Richard Henderson , Ivan Kokshaysky , Matt Turner , Trond Myklebust , Anna Schumaker , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org Subject: [PATCH 4/5] alpha: simplify osf_mount Date: Thu, 17 Sep 2020 10:22:35 +0200 Message-Id: <20200917082236.2518236-5-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200917082236.2518236-1-hch@lst.de> References: <20200917082236.2518236-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Merge the mount_args structures and mount helpers to simplify the code a bit. Signed-off-by: Christoph Hellwig --- arch/alpha/kernel/osf_sys.c | 111 +++++++++--------------------------- 1 file changed, 28 insertions(+), 83 deletions(-) diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index d5367a1c6300c1..5fd155b13503b5 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c @@ -421,109 +421,54 @@ SYSCALL_DEFINE3(osf_fstatfs64, unsigned long, fd, * * Although to be frank, neither are the native Linux/i386 ones.. */ -struct ufs_args { +struct osf_mount_args { char __user *devname; int flags; uid_t exroot; + /* this has lots more here for cdfs at least, but we don't bother */ }; -struct cdfs_args { - char __user *devname; - int flags; - uid_t exroot; - - /* This has lots more here, which Linux handles with the option block - but I'm too lazy to do the translation into ASCII. */ -}; - -struct procfs_args { - char __user *devname; - int flags; - uid_t exroot; -}; - -/* - * We can't actually handle ufs yet, so we translate UFS mounts to - * ext2fs mounts. I wouldn't mind a UFS filesystem, but the UFS - * layout is so braindead it's a major headache doing it. - * - * Just how long ago was it written? OTOH our UFS driver may be still - * unhappy with OSF UFS. [CHECKME] - */ -static int -osf_ufs_mount(const char __user *dirname, - struct ufs_args __user *args, int flags) +SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path, + int, flag, void __user *, data) { - int retval; - struct cdfs_args tmp; + struct osf_mount_args tmp; struct filename *devname; - - retval = -EFAULT; - if (copy_from_user(&tmp, args, sizeof(tmp))) - goto out; - devname = getname(tmp.devname); - retval = PTR_ERR(devname); - if (IS_ERR(devname)) - goto out; - retval = do_mount(devname->name, dirname, "ext2", flags, NULL); - putname(devname); - out: - return retval; -} - -static int -osf_cdfs_mount(const char __user *dirname, - struct cdfs_args __user *args, int flags) -{ + const char *fstype; int retval; - struct cdfs_args tmp; - struct filename *devname; - - retval = -EFAULT; - if (copy_from_user(&tmp, args, sizeof(tmp))) - goto out; - devname = getname(tmp.devname); - retval = PTR_ERR(devname); - if (IS_ERR(devname)) - goto out; - retval = do_mount(devname->name, dirname, "iso9660", flags, NULL); - putname(devname); - out: - return retval; -} - -static int -osf_procfs_mount(const char __user *dirname, - struct procfs_args __user *args, int flags) -{ - struct procfs_args tmp; if (copy_from_user(&tmp, args, sizeof(tmp))) return -EFAULT; - return do_mount("", dirname, "proc", flags, NULL); -} - -SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path, - int, flag, void __user *, data) -{ - int retval; - switch (typenr) { - case 1: - retval = osf_ufs_mount(path, data, flag); + case 1: /* ufs */ + /* + * We can't actually handle ufs yet, so we translate UFS mounts + * to ext2 mounts. I wouldn't mind a UFS filesystem, but the UFS + * layout is so braindead it's a major headache doing it. + * + * Just how long ago was it written? OTOH our UFS driver may be + * still unhappy with OSF UFS. [CHECKME] + */ + fstype = "ext2"; + devname = getname(tmp.devname); break; - case 6: - retval = osf_cdfs_mount(path, data, flag); + case 6: /* cdfs */ + fstype = "iso9660"; + devname = getname(tmp.devname); break; - case 9: - retval = osf_procfs_mount(path, data, flag); + case 9: /* procfs */ + fstype = "proc"; + devname = getname_kernel(""); break; default: - retval = -EINVAL; printk("osf_mount(%ld, %x)\n", typenr, flag); + return -EINVAL; } + if (IS_ERR(devname)) + return PTR_ERR(devname); + retval = do_mount(devname.name, dirname, fstype, flags, NULL); + putname(devname); return retval; } From patchwork Thu Sep 17 08:22:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11782019 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6816C1709 for ; Thu, 17 Sep 2020 08:35:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4AF8B2068D for ; Thu, 17 Sep 2020 08:35:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="GYwqhapV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726427AbgIQIfy (ORCPT ); Thu, 17 Sep 2020 04:35:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726106AbgIQIfv (ORCPT ); Thu, 17 Sep 2020 04:35:51 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88D1AC06174A; Thu, 17 Sep 2020 01:35:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Kl93QICC5aQvQJMxCeiVqLPxdrJCLvLfKIO/mt3R/aE=; b=GYwqhapVq04TTeK40il4+eAjIH eEPWkMcwVUYVvwu/vyIhYQFWJLFOK99rpCjNEPMZ1FYG9P0d1uQmpXDJK+nIeU0oNqlqN1SYFZ/Y5 OnO8Mxt8h6UwEnK/j/Q+LymGzkLGnPqPkMeaflWU/DNH8dK2UiPK3vnFcVz1X7LX1JcYWiDaIrstD 4LLddZquANPfwvWhP6AhISfAl3Y3CsdFK+/JNjVbeCQsDoqedJpfEs0BpqLQYfdzxvuHTQusrkLJV MprkkLou2kbyqmRXOCgGao41uRx4IcuIeTnX48V51+5VfwJpDTqzV9+9u/1aqlJaaDrgnYCsnz0Bu facfdBjw==; Received: from 089144214092.atnat0023.highway.a1.net ([89.144.214.92] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIpOK-0001rA-C3; Thu, 17 Sep 2020 08:35:44 +0000 From: Christoph Hellwig To: Al Viro Cc: Richard Henderson , Ivan Kokshaysky , Matt Turner , Trond Myklebust , Anna Schumaker , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org Subject: [PATCH 5/5] fs: remove do_mounts Date: Thu, 17 Sep 2020 10:22:36 +0200 Message-Id: <20200917082236.2518236-6-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200917082236.2518236-1-hch@lst.de> References: <20200917082236.2518236-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org There are only two callers left, one of which is is in the alpha-specific OSF/1 compat code. Just open code it in both. Signed-off-by: Christoph Hellwig --- arch/alpha/kernel/osf_sys.c | 7 ++++++- fs/namespace.c | 25 ++++++++----------------- include/linux/fs.h | 2 -- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 5fd155b13503b5..8acd5101097576 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c @@ -434,6 +434,7 @@ SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path, struct osf_mount_args tmp; struct filename *devname; const char *fstype; + struct path path; int retval; if (copy_from_user(&tmp, args, sizeof(tmp))) @@ -467,7 +468,11 @@ SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path, if (IS_ERR(devname)) return PTR_ERR(devname); - retval = do_mount(devname.name, dirname, fstype, flags, NULL); + retval = user_path_at(AT_FDCWD, dirname, LOOKUP_FOLLOW, &path); + if (!retval) { + ret = path_mount(devname.name, &path, fstype, flags, NULL); + path_put(&path); + } putname(devname); return retval; } diff --git a/fs/namespace.c b/fs/namespace.c index 12b431b61462b9..2ff373ebeaf27f 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -3193,20 +3193,6 @@ int path_mount(const char *dev_name, struct path *path, data_page); } -long do_mount(const char *dev_name, const char __user *dir_name, - const char *type_page, unsigned long flags, void *data_page) -{ - struct path path; - int ret; - - ret = user_path_at(AT_FDCWD, dir_name, LOOKUP_FOLLOW, &path); - if (ret) - return ret; - ret = path_mount(dev_name, &path, type_page, flags, data_page); - path_put(&path); - return ret; -} - static struct ucounts *inc_mnt_namespaces(struct user_namespace *ns) { return inc_ucount(ns, current_euid(), UCOUNT_MNT_NAMESPACES); @@ -3390,10 +3376,11 @@ EXPORT_SYMBOL(mount_subtree); SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name, char __user *, type, unsigned long, flags, void __user *, data) { - int ret; + struct path path; char *kernel_type; char *kernel_dev; void *options; + int ret; kernel_type = copy_mount_string(type); ret = PTR_ERR(kernel_type); @@ -3410,8 +3397,12 @@ SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name, if (IS_ERR(options)) goto out_data; - ret = do_mount(kernel_dev, dir_name, kernel_type, flags, options); - + ret = user_path_at(AT_FDCWD, dir_name, LOOKUP_FOLLOW, &path); + if (ret) + goto out_options; + ret = path_mount(kernel_dev, &path, kernel_type, flags, options); + path_put(&path); +out_options: kfree(options); out_data: kfree(kernel_dev); diff --git a/include/linux/fs.h b/include/linux/fs.h index 7519ae003a082c..bd9878bdd4bfe9 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2292,8 +2292,6 @@ extern struct vfsmount *kern_mount(struct file_system_type *); extern void kern_unmount(struct vfsmount *mnt); extern int may_umount_tree(struct vfsmount *); extern int may_umount(struct vfsmount *); -extern long do_mount(const char *, const char __user *, - const char *, unsigned long, void *); extern struct vfsmount *collect_mounts(const struct path *); extern void drop_collected_mounts(struct vfsmount *); extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *,