Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp11895876ybl; Sat, 28 Dec 2019 01:00:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxe7twPdbO247oQATi+2fkheYFePzImF90DUINf9WDQBUWfcC4uY0jm9mwXox2oRkewuUfK X-Received: by 2002:a05:6830:4d9:: with SMTP id s25mr61848830otd.171.1577523611925; Sat, 28 Dec 2019 01:00:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577523611; cv=none; d=google.com; s=arc-20160816; b=Q/qaxwUlauM/37g59uT1qgCC81e45vVIXcIFAvSWUIBPzBgyFi2xlInqrZn8/jrYd+ RrVl+xizUCmqEXgjSe1k5T35qaslqD5N3t0PjosGx31vuVp3WGHceMVNSrAY15H0YJiA lvl+DDQZflBDpEue5IuxMAtanEgeVEJZ30DiEcYvyO2t5tPrgRUDBNzVFf6SDeaX5y95 yFJ5Hy50bdcnd5cy4OBuMhCnb6DFjK6nqMJvXQvj+urEi0SPB6gRvjh4A2F9Oacwzgtq izfdNKf9VrRC7v6jdNu7pcWzO+dLQAirKC93R9m6ynIX+oisIfIosHWLVeiAmYIvmGeE nhWA== 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=MH+78K4iJ2sSk3z5JJEzfIgvIgR+2Eu8e6pUqZ50DI4=; b=PutG8dLXcGC1hScZ/JeDimitQf6Ny+yMg61wUJfec76gnos5gNSV3VX6eaKkFN65BG Qj6bx7pvVtpsMQjHo49kaSoYkGcqniHAI2QmAF++rE4cxr/8n7WIEO0ZofHUqoSgL3W2 JS43sIwE0SVGbb0hsFZgpxfdSaq6I1i841dFvIxbmwReXjimXJ1TfPmGFrq6tFaHFnyK zgdL86uvbVoE7JkjTa4AXUwe1H9tk01AzpXPupzc3FQmZOBIv9HFKol4n95Iye1zKuFe ER1Z+MpicPHUwBNfTcCq+/KijIBW7bLwwdbf7Roy1es1l70nmXm2eUqVTO265cikwuiV /h4A== 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 p5si7712958otl.13.2019.12.28.00.59.56; Sat, 28 Dec 2019 01:00:11 -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 S1726359AbfL1I5E (ORCPT + 99 others); Sat, 28 Dec 2019 03:57:04 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:49720 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725999AbfL1I5E (ORCPT ); Sat, 28 Dec 2019 03:57:04 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 175B7B903922767835DD; Sat, 28 Dec 2019 16:57:02 +0800 (CST) Received: from huawei.com (10.175.113.25) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Sat, 28 Dec 2019 16:56:52 +0800 From: Wang ShaoBo To: , CC: , , , , , , , , , Subject: [PATCH v2] sys_personality: Add a optional arch hook arch_check_personality() Date: Sat, 28 Dec 2019 16:53:17 +0800 Message-ID: <20191228085317.136584-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..d1d5d14441e2 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 +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