From patchwork Fri Jun 1 11:24:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 137513 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp805503lji; Fri, 1 Jun 2018 04:25:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLJEfeJUmxuGteErDh98lOhC8HJqTfeyuWfw2CMpw0yN9wHV6hfKI+pQgAF0N4GGxTodBDO X-Received: by 2002:a63:720f:: with SMTP id n15-v6mr8799882pgc.12.1527852325805; Fri, 01 Jun 2018 04:25:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527852325; cv=none; d=google.com; s=arc-20160816; b=fN/PINQS21rBwuIwIga2TKQsMD6SkElAi7gaKNQrj2RGWka033YPzMdqItazeeT6QU CmvU90SluY/jXVngVcGo7qUFZJuts5hOsED95jSXKQx9pyWGWSbouB9VxlgtHySIZQ6G dzySJ9us7CSz5z/sWjrvcxoJMZN69MfXV6i9BDBEK8h4XmsVreu1AxINKyaVn1dRtubg YjiDfwlLgeOUSmFF+X1Fx5rnGEwBrGKslqdp1fqgZRYg2mCWh9WyM4zk0Gk1bAH9VxFS +kGEuQFtDi8lSb8aGrsxNUq8g7nZ5nO3vS93L1xfFH9ZyZgH9UBgrx2FNxy3emdmxaZV 2KUQ== 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=5esnfEHpxG6UbSVuzA3aJDrMybAxCpMjqaMHPcJ6UCM=; b=mtIcnvF7klCSUi5YdXxMmvQlnTTJe7E3P7KKluH5RdkEVlcEV/CFtXfl2Nminn7h4A RemqXe7bPQOIwFVKeMn9yci/l5aVfNqA8Mkv5A8+tL52R1hg5yVHpZADLkYVkCseyiT5 xEY1JC+R43byLCB6nHxskDKgRY2w+W2O8wW7vjO6OHE/T3TdG9smttlmq9UABgEJh6xH 9PWGuL+p28pA/tMbyV8Hcfy8ezMXu56NJqbYsOfEuXiSs5sSZn0L8zMOgpoLVPoH59j1 TjeGcy94eBpsciVVuvb6IkDj6U9VITOjogEevBGLpXoN254PYGjyhCtkhhsUy44GUiL9 lETA== 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 b67-v6si38762507pfa.71.2018.06.01.04.25.25; Fri, 01 Jun 2018 04:25:25 -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 S1752058AbeFALZX (ORCPT + 30 others); Fri, 1 Jun 2018 07:25:23 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:50344 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752006AbeFALZQ (ORCPT ); Fri, 1 Jun 2018 07:25:16 -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 2ABA216A0; Fri, 1 Jun 2018 04:25:16 -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 CAEC43F25D; Fri, 1 Jun 2018 04:25:14 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will.deacon@arm.com, catalin.marinas@arm.com Cc: Mark Rutland , Al Viro , linux-fsdevel@vger.kernel.org Subject: [PATCHv2 14/19] kernel: add kcompat_sys_{f,}statfs64() Date: Fri, 1 Jun 2018 12:24:36 +0100 Message-Id: <20180601112441.37810-15-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180601112441.37810-1-mark.rutland@arm.com> References: <20180601112441.37810-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 Reviewed-by: Dominik Brodowski Cc: Al Viro Cc: linux-fsdevel@vger.kernel.org --- fs/statfs.c | 14 ++++++++++++-- include/linux/compat.h | 11 +++++++++++ 2 files changed, 23 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/compat.h b/include/linux/compat.h index 081281ad5772..6cecf9f11d6b 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -1013,6 +1013,17 @@ static inline struct compat_timeval ns_to_compat_timeval(s64 nsec) return ctv; } +/* + * Kernel code should not call compat syscalls (i.e., compat_sys_xyzyyz()) + * directly. Instead, use one of the functions which work equivalently, such + * as the kcompat_sys_xyzyyz() functions prototyped below. + */ + +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); + #else /* !CONFIG_COMPAT */ #define is_compat_task() (0)