From patchwork Wed Jul 11 13:56:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 141754 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp321885ljj; Wed, 11 Jul 2018 06:58:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc/FY+5ah/k3pENz+8Wa7sq7mmfYb2z1EPKteAaKcsi3cqXMz828UGTDxzfeA51BDD/hsEA X-Received: by 2002:a65:6252:: with SMTP id q18-v6mr27211951pgv.106.1531317485178; Wed, 11 Jul 2018 06:58:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531317485; cv=none; d=google.com; s=arc-20160816; b=ca8JHbkoGc2pQrwDCeUEt3YVsrQ84plezYZHNDxj3MXGz3uQbWbtqLXqPtYvhP+fdt uEs2O6GilYNxHkfNMi8FSHwrFSOi9B0Lp8DQjl5p6m4Y+vbnB8aZ4NMaIZJryRYuHWPd 8CiCvnHd5hMUW0tvEuJ0rf3THQGgCQ4rAycULhSc5seNBFT1EyixLgRKy2tOQ+RBC2Md WqGe0aB17VUTfKqAuo5vDJ8NtnsqoxqwF6iW2C7kzVPz24zpSe6iSYswJFrxRDJsQRjW dXRhayMyTDwbsnbtr75JjE2pLtA5+RL0nxCrjUFhM0GroqAwyVb8roOEr2cLzL0mqeBs FL/g== 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=EiAw280OXAyuFcaboM71NFu7hBrGJZLbkN9lo+B9Ncej1uEU67Jfr2jPGgYBsx035e wtlxAUcyyypggRM7lrPEwJY8o7xyG8aNslACfgeb+tNcnH6gHARjND+MwjB7Ripv9rP0 BccuewXNDNfdeTJfX0fBgdY39eiuV+iXDgcM72FTmaFaaqHpUw1kjxfH4puc1m8Uvi/B +4pKNktkAMUyZEcTW0aaKGnqyvfbH1OQxN/LZjREfRK1pfi/GdfkRPPTHudISZYfxi7Z sNNHpCCfWRIm0HgYZ9WKmdTiRqQBS/993MKFCM9gtG4LdY38YnYq17uXAPJegRZ1f14B vGkA== 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 q11-v6si18208757pgb.102.2018.07.11.06.58.04; Wed, 11 Jul 2018 06:58:05 -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 S2388580AbeGKOCa (ORCPT + 23 others); Wed, 11 Jul 2018 10:02:30 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:36452 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388274AbeGKOCa (ORCPT ); Wed, 11 Jul 2018 10:02:30 -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 46B1C2379; Wed, 11 Jul 2018 06:58: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 3627F3F5B1; Wed, 11 Jul 2018 06:58:00 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will.deacon@arm.com Cc: 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: [PATCHv5 16/21] kernel: add kcompat_sys_{f,}statfs64() Date: Wed, 11 Jul 2018 14:56:51 +0100 Message-Id: <20180711135656.20670-17-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180711135656.20670-1-mark.rutland@arm.com> References: <20180711135656.20670-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)