From patchwork Mon Jul 2 11:04:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 140730 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3854731ljj; Mon, 2 Jul 2018 04:05:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ0Q72mZhAwY0nKuVPgM9xP+jn8QkWDi83NfjYtiRSdq2Cnal84IZEkoFfG378Cfisj4ZqX X-Received: by 2002:a63:2c94:: with SMTP id s142-v6mr20854877pgs.39.1530529512891; Mon, 02 Jul 2018 04:05:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530529512; cv=none; d=google.com; s=arc-20160816; b=Te2EQVZryiBFx/y8cllWYZHtJBBL20+Tm+Wm8xYhsjj3CwI+KaSEwlOtIHMg7Isn9D MHhq4ZxQDujjjHs8RRsVF2JbzaAX0e3M/TydzVGnOzTcJAkay4GqzNGiGxoWtjDCDjqj t/r40BVmtFqVolJskUP+0CvGfjB3ZdXS7jVHiAWuIRcODUQiqRpajZ4u8DHDboNKng0z 6G9qaatNeoZ5/zY0Po8Qj+jkInJOv38u9WAniY0mkrINpnXp0qeX7vo2Ql0K3V6nLdkF EoGpnK+IyFRNidqZI65JUt6VSTrpfToVw43CLjrtKV98EopbProQfVm3B4TD0+BQhq+f 67Kg== 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=VHIBZD6OjHpcIqa5o8v0gxQRO/xJp3kWA0Kavz9205g=; b=POh8w0qCvrr8FFfG7ow38R7TZLJDxmfwRlXSNPrb9+R7uEsTi3esEHwqcvzJjD3cmP 8LDUQGz9rraFbyIuqq6HEDxboksKimTGLy7vtR8xLWaf5XOFbm44/uKNmZd2qxG2b22D MpBasQcFI6pNK2sJvvVwwxHwD9vj0EP0lELFROsuAQBKTtS8VgOHfENv36bBeTE/t7fw sD6C/viBR81hWGAzjiIomaiChr2duKjwBXGmwu/iOjnkK8Ut0EgIlbG8kuke1kateqgC kPfHBvckRvLPd6W2U+8GU/IdkLqSAmIZ6EzCq2vBxaALP670QDwelAGmt/3M3Ma+RYZq fS7w== 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 k33-v6si12797585pld.269.2018.07.02.04.05.12; Mon, 02 Jul 2018 04:05:12 -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 S1030475AbeGBLFL (ORCPT + 31 others); Mon, 2 Jul 2018 07:05:11 -0400 Received: from foss.arm.com ([217.140.101.70]:57608 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030417AbeGBLFC (ORCPT ); Mon, 2 Jul 2018 07:05:02 -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 5A06E19F6; Mon, 2 Jul 2018 04:05:02 -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 495D73F5BA; Mon, 2 Jul 2018 04:05:00 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, hch@infradead.org, 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 Subject: [PATCHv4 14/19] kernel: add kcompat_sys_{f,}statfs64() Date: Mon, 2 Jul 2018 12:04:10 +0100 Message-Id: <20180702110415.10465-15-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180702110415.10465-1-mark.rutland@arm.com> References: <20180702110415.10465-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 c68acc47da57..43f4ed44c5d5 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -1028,6 +1028,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)