From patchwork Mon Jul 2 11:04:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 10501057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 24F5B60362 for ; Mon, 2 Jul 2018 11:07:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15FFB28700 for ; Mon, 2 Jul 2018 11:07:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09C6628744; Mon, 2 Jul 2018 11:07:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AD1F28700 for ; Mon, 2 Jul 2018 11:07:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964963AbeGBLHj (ORCPT ); Mon, 2 Jul 2018 07:07:39 -0400 Received: from foss.arm.com ([217.140.101.70]:57600 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030389AbeGBLE7 (ORCPT ); Mon, 2 Jul 2018 07:04:59 -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 F21A01529; Mon, 2 Jul 2018 04:04:58 -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 E1A3A3F5BA; Mon, 2 Jul 2018 04:04:56 -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 13/19] kernel: add ksys_personality() Date: Mon, 2 Jul 2018 12:04:09 +0100 Message-Id: <20180702110415.10465-14-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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using this helper allows us to avoid the in-kernel call to the sys_personality() syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_personality(). Since ksys_personality is trivial, it is implemented directly in , as we do for ksys_close() and friends. This helper 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: Christoph Hellwig Cc: Dave Martin --- include/linux/syscalls.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index a368a68cb667..abfe12d8a9c5 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -80,6 +80,7 @@ union bpf_attr; #include #include #include +#include #include #ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER @@ -1281,4 +1282,14 @@ static inline long ksys_truncate(const char __user *pathname, loff_t length) return do_sys_truncate(pathname, length); } +static inline unsigned int ksys_personality(unsigned int personality) +{ + unsigned int old = current->personality; + + if (personality != 0xffffffff) + set_personality(personality); + + return old; +} + #endif