Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp11890719ybl; Sat, 28 Dec 2019 00:51:46 -0800 (PST) X-Google-Smtp-Source: APXvYqz8JaPtX23Iwq2KnjgvU3Bmo8znCOcaxCWnD4li/W21vpF8C2t0ka8xyMAyYqxuBw9Li2cZ X-Received: by 2002:a05:6830:1cd3:: with SMTP id p19mr57921426otg.118.1577523106694; Sat, 28 Dec 2019 00:51:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577523106; cv=none; d=google.com; s=arc-20160816; b=H8ELP4C0eXsiHpTjJcEejquMWlbrmtKMINV/+hrrc4yXdGVgdXkUGy9QrqMBuzM41J 4CFc1qjRrWzVfMuRJ2ABsUZFRf7H/7nUahTx4WNHR1kx2maN7xXz6lw9w/Zypb0S4oAp zPuXDAwsHntTtDi1vJXLHgbaBQoxsnzFyT1ZNJd9YA5v3W1+QVxDVd25rUUsk9riJTXD ixvVtgosmcqRHAww5lRS269aX3SKTVoblUmDUsZmMgh8YlRlED9217MYxhClJtXJU+nF B7uqeeNjAwhblRRoUeSZmGk31IgNASjihsW2m19gTYAlDcWg7R9XRFJi6JyQDwhxKJlj qHtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=KTpmQHmOUnB96gFdJJ8TibE/YSTFtph8ufVZKeafuH8=; b=T96TlTJMAXtZnSmvdzgAdDNE/rI8G+7KXsrkbjvHcHeWqHmN9LYtkkfdHtGJM14n+M d28/7QNsn8uVjSYQ3ezDnIwzMJQD279+0nyXF2cfGNgG3Cpr4349ljc5cgcMHTXZng9G fqPdIoUrfRYaDpi1NlkoqJKToXu/pFwf86BS8T4wFvCu+9LEeYVd7R3A7jb7BwgiZBzA lQMg6LaHuQwp/Snxa24zWXjMjZQgiqsbvJy6cQYOtcdFIutY12LuRT4ngLMUpzmQ4fuB 3XiE7pP3jjMokpuusO3Hcl4W5k5sSqCNL+ncXswmz0mqWMQFzDIoZMlMUaoqOjRp6laa nQkg== 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 r1si19836235otq.298.2019.12.28.00.51.21; Sat, 28 Dec 2019 00:51:46 -0800 (PST) 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 S1726248AbfL1Irx (ORCPT + 99 others); Sat, 28 Dec 2019 03:47:53 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:40408 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725999AbfL1Irx (ORCPT ); Sat, 28 Dec 2019 03:47:53 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E3173902610BA9CE06EE; Sat, 28 Dec 2019 16:47:50 +0800 (CST) Received: from huawei.com (10.175.113.25) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Sat, 28 Dec 2019 16:47:41 +0800 From: Wang ShaoBo To: , CC: , , , , , , , , , Subject: [PATCH] sys_personality: Add a optional arch hook arch_check_personality() Date: Sat, 28 Dec 2019 16:43:59 +0800 Message-ID: <20191228084359.133745-1-bobo.shaobowang@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org currently arm64 use __arm64_sys_arm64_personality() as its default syscall. Now using a normal hook arch_check_personality() can reject personality settings for special case of different archs. Signed-off-by: Wang ShaoBo --- arch/arm64/kernel/sys.c | 6 +++--- kernel/exec_domain.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c index d5ffaaab31a7..751fbd57eb1e 100644 --- a/arch/arm64/kernel/sys.c +++ b/arch/arm64/kernel/sys.c @@ -28,12 +28,13 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT); } -SYSCALL_DEFINE1(arm64_personality, unsigned int, personality) +int arch_check_personality(unsigned int personality) { if (personality(personality) == PER_LINUX32 && !system_supports_32bit_el0()) return -EINVAL; - return ksys_personality(personality); + + return 0; } asmlinkage long sys_ni_syscall(void); @@ -46,7 +47,6 @@ asmlinkage long __arm64_sys_ni_syscall(const struct pt_regs *__unused) /* * Wrappers to pass the pt_regs argument. */ -#define __arm64_sys_personality __arm64_sys_arm64_personality #undef __SYSCALL #define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *); diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c index f7a0512ddc23..ec6b16e30ed1 100644 --- a/kernel/exec_domain.c +++ b/kernel/exec_domain.c @@ -35,7 +35,18 @@ static int __init proc_execdomains_init(void) module_init(proc_execdomains_init); #endif +static int __weak arch_check_personality(unsigned int personality) +{ + return 0; +} + SYSCALL_DEFINE1(personality, unsigned int, personality) { + int check; + + check = arch_check_personality(personality); + if (check) + return check; + return ksys_personality(personality); } -- 2.20.1