From patchwork Mon May 14 09:46:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135711 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1532116lji; Mon, 14 May 2018 02:48:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrmCCLeC83c2oK+0CTR50CC/5imJJAlalRXGCwSbskfv0nvLSVJA9Hm0oF4h2rH0xbG5vhJ X-Received: by 2002:a17:902:6687:: with SMTP id e7-v6mr3181818plk.242.1526291283336; Mon, 14 May 2018 02:48:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291283; cv=none; d=google.com; s=arc-20160816; b=IUaf6T5CAursZDBwxqXkrOf4GJL8jT6F3iTgJcVj2/pUqxrklRdbcV5JJJPQzsGeQw C5NZPtFo10DFEGDrKcHMVBznSAiw2lWNqdnkW2M6j9f7pAlD0J0R4CGmm5YoxEhgdk0u JwMe93LOYPfJBN97WSx82may8Rfwr9G7DvgXW0vAGUtKFfNeaINpZNikeiEzO9vSX66F qRQ3XNO6Ljea95s8ovwupRhw2Yd+i5X/k7H/NcVUhtfQvERgTOjtBMD9nf7v/kWpU5D7 ig81hgwpI/tl9opbEeV+cQBBW9TQSDPVUh4Cyg2INQ2FrU1mqIrZMtERzTecwSnaIrG5 Gozg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=fs+Hj3uvr4RgvwVOQbd8T6mzw798/4Adh2Ecs6hvvWg=; b=C9VwmdpfapjXbR99wTBwasahOZgq/iq+pMkLlsW06rFf4jwA8Jy6U1FH03Fo99cP/W FkVK6g9puEa8bwIGFJDbXdrkG1su6Aph3qYv6fgHM+C1aWcearFvR0pR3tY++votcEKC lZ9Qr7HYJ9fd08DA492PG4RgoFW1hOK9Sut78WenijWcngJDzeAgz9tYyhxYAjtX7Rtl ameJ5CYzsIiZEQuGXKBsSVLCMPYKsNWpFPAnfHpezHKFroWo9q7GItRABiBRUWsgHf/H Vndz4O/6T/n5dw2DoLB0YE5hlGHooeBbTA3nQkHNV+cHLWklyVZFM44/tMB2AToM0eQ4 7x+Q== 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 t8-v6si3367871pgc.142.2018.05.14.02.48.03; Mon, 14 May 2018 02:48:03 -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 S1752671AbeENJsA (ORCPT + 29 others); Mon, 14 May 2018 05:48:00 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38330 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752611AbeENJr4 (ORCPT ); Mon, 14 May 2018 05:47:56 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D9367199B; Mon, 14 May 2018 02:47:55 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EC3873F25D; Mon, 14 May 2018 02:47:53 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 13/18] kernel: add kcompat_sys_{f,}statfs64() Date: Mon, 14 May 2018 10:46:35 +0100 Message-Id: <20180514094640.27569-14-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using this helper allows us to avoid the in-kernel calls to the compat_sys_{f,}statfs64() sycalls, as are necessary for parameter mangling in arm64's compat handling. Following the example of ksys_* functions, kcompat_sys_* functions are intended to be a drop-in replacement for their compat_sys_* counterparts, with the same calling convention. This is necessary to enable conversion of arm64's syscall handling to use pt_regs wrappers. Signed-off-by: Mark Rutland Cc: Al Viro Cc: Dominik Brodowski Cc: linux-fsdevel@vger.kernel.org --- fs/statfs.c | 14 ++++++++++++-- include/linux/syscalls.h | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) -- 2.11.0 diff --git a/fs/statfs.c b/fs/statfs.c index 5b2a24f0f263..f0216629621d 100644 --- a/fs/statfs.c +++ b/fs/statfs.c @@ -335,7 +335,7 @@ static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstat return 0; } -COMPAT_SYSCALL_DEFINE3(statfs64, const char __user *, pathname, compat_size_t, sz, struct compat_statfs64 __user *, buf) +int kcompat_sys_statfs64(const char __user * pathname, compat_size_t sz, struct compat_statfs64 __user * buf) { struct kstatfs tmp; int error; @@ -349,7 +349,12 @@ COMPAT_SYSCALL_DEFINE3(statfs64, const char __user *, pathname, compat_size_t, s return error; } -COMPAT_SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, compat_size_t, sz, struct compat_statfs64 __user *, buf) +COMPAT_SYSCALL_DEFINE3(statfs64, const char __user *, pathname, compat_size_t, sz, struct compat_statfs64 __user *, buf) +{ + return kcompat_sys_statfs64(pathname, sz, buf); +} + +int kcompat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct compat_statfs64 __user * buf) { struct kstatfs tmp; int error; @@ -363,6 +368,11 @@ COMPAT_SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, compat_size_t, sz, struct co return error; } +COMPAT_SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, compat_size_t, sz, struct compat_statfs64 __user *, buf) +{ + return kcompat_sys_fstatfs64(fd, sz, buf); +} + /* * This is a copy of sys_ustat, just dealing with a structure layout. * Given how simple this syscall is that apporach is more maintainable diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 6723ea51ec99..e0bf3e4bb897 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -59,6 +59,7 @@ struct tms; struct utimbuf; struct mq_attr; struct compat_stat; +struct compat_statfs64; struct compat_timeval; struct robust_list_head; struct getcpu_cache; @@ -1150,6 +1151,13 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len, ssize_t ksys_readahead(int fd, loff_t offset, size_t count); unsigned int ksys_personality(unsigned int personality); +#ifdef CONFIG_COMPAT +int kcompat_sys_statfs64(const char __user * pathname, compat_size_t sz, + struct compat_statfs64 __user * buf); +int kcompat_sys_fstatfs64(unsigned int fd, compat_size_t sz, + struct compat_statfs64 __user * buf); +#endif + /* * The following kernel syscall equivalents are just wrappers to fs-internal * functions. Therefore, provide stubs to be inlined at the callsites.