From patchwork Wed Jul 11 13:56:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 141753 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp321821ljj; Wed, 11 Jul 2018 06:58:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcsMsC7m26TpD5capoeYV2zHrJIEiOPs7mUSkO2UkjNtVvILHSwRRG64LTUnQHL6BGyqivX X-Received: by 2002:a17:902:aa01:: with SMTP id be1-v6mr28776227plb.296.1531317481011; Wed, 11 Jul 2018 06:58:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531317481; cv=none; d=google.com; s=arc-20160816; b=he9tJ4+kzWCwZ38Ws2t+hKV2E5bLvmViJQl8G75Azw+Gt4xQpsnllzzMkvwVeMRv20 +yE6LNBeV5ojXEBmyMPeS1GgQFkqRiFtProblvD0U096blKPPdGfn+iouABWQSsAhYQz ndvT5F2LMZ2QLQNy1VJSBCaxdLJa8nOnkTgKJCqHMq/aOJJWzJE/ecULJQZ1aIu3Y+95 28IDyMtvjHOtsSwmFHKg/heAHa61vQt+0O8fUS9EyKzg0hlb8vWG+EW7B38Lea7f6WLC 9XtaQgYDKtFKNHI9ZXjdI9KBhFIqqu22LTvtKSFmwXVNHq7FK/fRoaHpEoCj8EmFe169 edKQ== 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=QR6AYj0erSu4mrb/hQXJOFPO1fLRJozeG1ZhKnAPjDE=; b=Q+pk1dw47IJ5zNfK9bQ8qiaJsArLUiMJX+H8in7RR5emgPeT/u/xk8eR9O5zFu22pg QKPcFLN70b1bwSv0zJJKrrgyBv2WsdggUHYVHxC6j8PXWybGzAKXi5viNp51IxQQMMp9 JLf2sR42ZL0ybazGxIprfM67JxGFkeST9aTIBdjJzs6M8gjZR4dUF8B3E6YD5iIhUtQL +WpaSJ6Der16qsdun6Xd78swr3NMgCtRNcDXBD7jQCh8wBO2/WThDTpB6nj+1E3YUpiy QY3cgMzoiLdMxmPM4pD5jR566G/EZNam4rZk0s1CQdY5FOH15eGimoK2I6uGnahhN1V6 afLA== 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 j21-v6si3368461pgg.303.2018.07.11.06.58.00; Wed, 11 Jul 2018 06:58:01 -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 S2388565AbeGKOC0 (ORCPT + 23 others); Wed, 11 Jul 2018 10:02:26 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:36444 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388274AbeGKOCZ (ORCPT ); Wed, 11 Jul 2018 10:02:25 -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 8ABB622F8; Wed, 11 Jul 2018 06:57:57 -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 7A7283F5B1; Wed, 11 Jul 2018 06:57:55 -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 15/21] kernel: add ksys_personality() Date: Wed, 11 Jul 2018 14:56:50 +0100 Message-Id: <20180711135656.20670-16-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 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(+) -- 2.11.0 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