Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1445873ybl; Wed, 8 Jan 2020 17:44:15 -0800 (PST) X-Google-Smtp-Source: APXvYqyqxG4L/ZX7HbQ390KWfqZ/fhHA+qBbvM+3WTimq0yOPoY7wD9q95H9kMirPwpgK77HRah1 X-Received: by 2002:a9d:7851:: with SMTP id c17mr6787821otm.58.1578534255380; Wed, 08 Jan 2020 17:44:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578534255; cv=none; d=google.com; s=arc-20160816; b=QxwZdH7twS7JyyRfFcKE1EWOGvEEB3KUijyVKzH9ek9zOked7u1oGnt/Rh1XfdgIb3 hf4bRmTvHuyUNpqOs+zxbMc42tkDSr+1jFzh3HTDraGrv3fd+pYf0E9/SEMqIsqF4v4h QyelKC+68OEGrJ31P9ASnSkRfXLa1RpU8tB9Yjvr9BFKfv17KSi3stpZKDRpzw5VsO2w MC2KYyIA+qydKiz5W5y56X0coZW4rf4qfnjXdpFXgt5QKS7tPuPkFO6Zf8p9lFfej06r LN5LxbV2dsOPte7dI344lPVwx1sdYEhnBEIuiKwHdjY6BDywL9rKdTdaRckdc8THE+EY zz8g== 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=CXlMlRtK2JeH+dowdMUq9AdQIj5dXi7nm0gjx9htGQc=; b=j8HMN6uCizjOX/iNAOMVbujUBjlEJu4hhvK74Cd9IDpBCmEsGD5lGgoCbnpsUP8VL4 P+nLLn8aT+GEZex1C/aKg5Jd1z0+p4WgofY8UBaVJRZoaMd6dYG8GUjReHdnPQokkmSJ YXFLSywD2rAzGwOeq7SwQRseeJdoLkeWAXY1X4iWBySibeJmdHHYMKU5pEqEt/g212nW FugD4JbRI5vlgqkxiW5c4xi3gbGOpeRQrFv8zRvMJ74muzDkc1Err86bfgl7LSjFu6nW 6aV4T0PdTsRygvx53UTm4TQxTKBBpLNeSdTkUuaVrozbW8HUPkHQzxa06FM9rLntPYYK iuXQ== 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 p22si2991788ota.43.2020.01.08.17.44.01; Wed, 08 Jan 2020 17:44:15 -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 S1727807AbgAIBnL (ORCPT + 99 others); Wed, 8 Jan 2020 20:43:11 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:53410 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726913AbgAIBnL (ORCPT ); Wed, 8 Jan 2020 20:43:11 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 860306547382F741E094; Thu, 9 Jan 2020 09:43:09 +0800 (CST) Received: from huawei.com (10.175.113.25) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Thu, 9 Jan 2020 09:43:00 +0800 From: Wang ShaoBo To: , CC: , , , , , , , , , Subject: [PATCH] sys_personality: Add a optional arch hook arch_check_personality() for common sys_personality() Date: Thu, 9 Jan 2020 09:38:46 +0800 Message-ID: <20200109013846.174796-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. But 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 | 7 +++---- kernel/exec_domain.c | 14 ++++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c index d5ffaaab31a7..5c01816d7a77 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,8 +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 *); #include diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c index 33f07c5f2515..d1d5d14441e2 100644 --- a/kernel/exec_domain.c +++ b/kernel/exec_domain.c @@ -35,12 +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) { - unsigned int old = current->personality; + int check; - if (personality != 0xffffffff) - set_personality(personality); + check = arch_check_personality(personality); + if (check) + return check; - return old; + return ksys_personality(personality); } -- 2.20.1