From patchwork Fri Jun 1 11:24:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 137517 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp806910lji; Fri, 1 Jun 2018 04:27:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIRFJRXs6wuus7FFU/SY6PVSKzjGxDE0e+LRwBpqD982GtPmKMHQE0mMpx1CjhAv5IwfBwd X-Received: by 2002:a62:5c06:: with SMTP id q6-v6mr10548912pfb.118.1527852421704; Fri, 01 Jun 2018 04:27:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527852421; cv=none; d=google.com; s=arc-20160816; b=lZ4uWktJ+dgiDlMmzznxBsy3S+laLY2Wz+zFelhW9ZZmlq6gqnjKIvzQPoFzrfuBsf Nx3rF+E0PIeZeWmkLiHIxlCqKsDKgEU3aVw5Wg99cgBmIKWQLngdq/tjfihDwE9gOtAZ j5GnsY9jsEcHJTrhSbOEt7PsDN0PZXl2qg+ae4eFoawaacRJ9L0FP/q5PjFeaC2/GGPl OMUL2kt/tpXTfaC0j4RG9Cz+1SoO2GHpEI9oabSojLXCdghV0hnN5gtxhUmRqwAmoYlm XvtdBA5r1J/ftg39ueBNgi71sCWa4RW69XG7Oe4Biu/YRKMsFTMt//wmY+Lsh4B+JLz+ jAhQ== 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=dp8RxSY3pxFhNh2uOnT85B8C1J+zrWhFUVvCYt5IMEQ=; b=T9OdIrwa/3CZpDdYMcnMWO/FLiFUZBNya7ny4/a9sS2s+ec2v2JWolLLxbnz7nWyd4 HjMoQBBKnW9MD5KDVfy9trDXswOxMjSzl/FHm5d5G4IvaINf1D5YFR27XrYBS+l7vlWA 6QGPxupixYzTeNBvQFgmEeJGKvrNEoduhuxwHnA+GlXZ3fAbv5Rm2dXijR0By+JlESrC XKSob21M/NbVI0dpkFCnkeOZvCNb1geG/AHN1fe4tXSRzPl+etUqvDOq0/0WymvOd6za wag9h45beyu06zfbkVSIAQ+79MGRbPHg1z4hGkzjnaW/4vrAEeaKwMjh5mXQFB79a9tU m2uA== 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 m9-v6si39397641pfc.9.2018.06.01.04.27.01; Fri, 01 Jun 2018 04:27: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 S1752035AbeFALZV (ORCPT + 30 others); Fri, 1 Jun 2018 07:25:21 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:50334 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751968AbeFALZO (ORCPT ); Fri, 1 Jun 2018 07:25:14 -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 88D401684; Fri, 1 Jun 2018 04:25:14 -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 E25313F25D; Fri, 1 Jun 2018 04:25:12 -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 , Christoph Hellwig , Dave Martin , Dominik Brodowski Subject: [PATCHv2 13/19] kernel: add ksys_personality() Date: Fri, 1 Jun 2018 12:24:35 +0100 Message-Id: <20180601112441.37810-14-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 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 Cc: Al Viro Cc: Christoph Hellwig Cc: Dave Martin Cc: Dominik Brodowski --- 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 70fcda1a9049..652e166deb64 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -79,6 +79,7 @@ union bpf_attr; #include #include #include +#include #include #ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER @@ -1268,4 +1269,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