From patchwork Sun Aug 20 10:20:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9911069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3A9D1601D4 for ; Sun, 20 Aug 2017 10:23:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 272AF28775 for ; Sun, 20 Aug 2017 10:23:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1872A2877E; Sun, 20 Aug 2017 10:23:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 90A1228775 for ; Sun, 20 Aug 2017 10:23:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4IAn1nEXHcDsqEA4m6OhUGDFPt3mmdt2w+fF6VfzxNQ=; b=WUd0nqXwFl93uP 9SckhAC3NvHn7fMGtUf9Tt1lP5ua2qXnK85Oo0brfl1WFgOHBv7PxXxXTGjOjowMRCKRkCqzxVRx4 fScJTGCj2Nuv4gdNstULfnOstH3NWnCDzaA06qFGD4MDvo5GxUAusAtUVrr2m3tYJ4Y8Tw5NixFtl qmV1r/3OkMrmQrvuDMEQea/NRZKMrItnoFNQWajIT8OX7FogdsNzkUAGvSvbjX3ZpwQno/pcp4wxS c0ZCPTy27pF45d6KZohXbB4XLRkBOA44LOlsDCCZqwYx+49jo7fHO4EknwnXSfxKAjAVf5Q9Vcv7H 393wYcfnVXvn0tyAe05w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1djNNN-00032u-5B; Sun, 20 Aug 2017 10:22:37 +0000 Received: from mail-sn1nam02on0056.outbound.protection.outlook.com ([104.47.36.56] helo=NAM02-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1djNNI-0002vl-1H for linux-arm-kernel@lists.infradead.org; Sun, 20 Aug 2017 10:22:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=7ERxlCtQ7raWrgfd2AWPKysm7udhjObxGuPvj/qZOmw=; b=TfD46ugfHhPyyAWCvlGGyuFqLyyS3yw99WbXi04GmjybkLHSHR66iAZaqh+bnCNTwgBHUjRjsRAgGqW4coJjsutEyZ4Cgo71Omci68I4LJleX2/ZBnlI8kMp9124D5X8SjHhY7Z054BBpkvx1BmJDJ3RivKyq5mW7UTVlDeovls= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Received: from localhost (88.148.44.109) by SN1PR07MB2128.namprd07.prod.outlook.com (10.164.46.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1362.18; Sun, 20 Aug 2017 10:22:07 +0000 From: Yury Norov To: Catalin Marinas , Pratyush Anand Subject: [PATCH 2/2] arm64: cleanup {COMPAT_,}SET_PERSONALITY() macro Date: Sun, 20 Aug 2017 13:20:48 +0300 Message-Id: <20170820102048.7537-3-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170820102048.7537-1-ynorov@caviumnetworks.com> References: <20170820102048.7537-1-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [88.148.44.109] X-ClientProxiedBy: HE1PR06CA0144.eurprd06.prod.outlook.com (10.170.251.31) To SN1PR07MB2128.namprd07.prod.outlook.com (10.164.46.158) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c0333e8c-f401-4f52-9b35-08d4e7b5504e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:SN1PR07MB2128; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2128; 3:DQbTM027e9WcY2QD435swqDoj2sCP2n0C+lMbeEnMNFlIL+kqmroVJkvGPBYxP9juL9wKjz+j3OSWTde6n0g5A7oc0J56e8m/747DF+K6vNMY7lbiz8MS8eRwmNPAJ0c40V0UWip9gLBMKHDCJvap//UiYqVhlZWz5OXhOOMAjGIZALtN8zSq48BFWldm7suMwSV3vdd++kEK981OgOtdyuysHF0EECrFiFo3yeKi3/D8VSWQS3snwueMIXo+vty; 25:ONjR5tqf/fP39YvpShexXAkMPOYnM0k5A4d2uhlnTEGxv3xkW0j6/ys9gtWlvB8iEXxq4tsQvMtm5pydPGxyuxDLjbRaXLLf87B9CsA43rLvFZnHhioXQoLjL/VC6X1oits+4lojnIOffc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uHQjvH4RZ/ObenCx2Lj0vtpkON2QEkafUzsw05MCZNzog=; 4:HVzTkm7IT3cr8oCXp0Ki3bxF4lKoEyFhkEYS0dMEvU2bY2AZvxJ7jhwLzkBcrVwayVGcSZohvGe/Tt9HYywQfxa9uF2inMP58X6ddFEF1bUuMXKTWHmWonWXsApKMd/aLWDIewtjUAENl7WkNu09VhBCN4/winB2nH+Nroqir8RzV6b7U0D69gWLOewruKujZalMPl7vmhJmBKl+tw72zolk4S1mYVnLQveJ4MAI4LBBBDnIGKT7tUeWNtUqzu4y1DyKJw64eS88iHwb25dRa5N0goPorijcb5FHeFlytvs= X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(100000703101)(100105400095)(93006095)(10201501046)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR07MB2128; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR07MB2128; X-Forefront-PRVS: 040513D301 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(6069001)(199003)(189002)(6306002)(101416001)(105586002)(6486002)(4326008)(42186005)(25786009)(6496005)(50986999)(76506005)(76176999)(53936002)(48376002)(2906002)(3846002)(6116002)(50466002)(478600001)(106356001)(42882006)(6666003)(2950100002)(36756003)(1076002)(7350300001)(33646002)(5003940100001)(305945005)(68736007)(7736002)(966005)(72206003)(189998001)(81166006)(81156014)(8676002)(66066001)(97736004)(50226002)(47776003)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR07MB2128; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR07MB2128; 23:tPhiRkBntpakB62I96ikdXDitguAYIWeL1ycVut26?= =?us-ascii?Q?Ii3F4Smqy3mRgInvkOsixpBYsIRQmjLr7egTqus9uHe/REd8p7fij7tLZKLh?= =?us-ascii?Q?53USe6UrXilJiQOKjQWzrHJyj1bc15bNqDctix8fdPmjeLbyfyYylYce6l9T?= =?us-ascii?Q?rUj+Q31MpnOLv5+s9Z1fydWpaBAunPvOaEJtM8lOt1zHBirjClZmUQ/YEa0i?= =?us-ascii?Q?QSOqeaXLB4Opq7wIWEMJ7A6TFZH3Y4nQxwylJsHaDcnjL4p6tq8U51+Y8h/4?= =?us-ascii?Q?3mRXX/XiFpn+Ja9la0w1uc8OGEb2Rm5ku8C/vy+MGInYs7Jp3VoNbWs3ninM?= =?us-ascii?Q?WLiajOAt0te1DWdCAQ7LXN8oPvCNLenHm1cMK9uRm9TOKOc+UrJd5cuAubtB?= =?us-ascii?Q?IlJbWeLAdQ7b5+3kgGsglsa49YhrV3C1hZs8YzIIdddA+z525QN4zxaXdwwd?= =?us-ascii?Q?hSNGimCKBNXQwtViPOL89Ky7eoiQy3qlD1D2j24t32yTElExZ1u/3NomWQo0?= =?us-ascii?Q?CItz1miTntWxsTIKd0r6znV6xOuuaXRygMJCXiQOKUMEsbKzXihnZjh43DWA?= =?us-ascii?Q?BZLy2datuSMr/3ZnxWx2mHhOhT+vYr+jF2JDAWhj3dgglgrpPMr09hdWT/um?= =?us-ascii?Q?oL/Ab37aeZgx7MmE7kT67bJ9rldz8bnq/WFJOL96251YLtV/Xn1xlDyl1w0N?= =?us-ascii?Q?cWqC6fGiYY5xEa04RE+hQMW6wFKKTE6YvnzmPHFTWpPChVUmZVd2lSCfWzZ9?=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hV2rk+2HkNfIdcp4tss4ZpUjE4qFXijfKTas2yX6ZlDr/03Zw+sxdvnOFUEd21Rs=; 7:RkKfSi4cykq3ECcNea4yrclj1FRRa2d1uPAtr3DmM8Yj9IhNf60UNtcsb4b+LpI2XJ9KgrH/Nm5t5O5toQjxuOVNWR29/aE1mKoPNPXyLJzMb53vBBSLOMRKQ276Ywx6rFBhZoj2aMPw9a7VSbUAh8iz+QfsYBbx6AW9fIy4uRaWQoP6o7LB7E0VmZICYBIKokXsMU18eRd97Ni0qltjqM1V+jWscUEmEgsZJQ5X3kA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2017 10:22:07.8351 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2128 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170820_032232_255823_867FA315 X-CRM114-Status: GOOD ( 10.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yury Norov , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP There is some work that should be done after setting the personality. Currently it's done in the macro, which is not the best idea. In this patch new arch_setup_new_exec() routine is introduced, and all setup code is moved there, as suggested by Catalin: https://lkml.org/lkml/2017/8/4/494 v2: - don't move clearing READ_IMPLIES_EXEC flag from SET_PERSONALITY() Signed-off-by: Yury Norov CC: Pratyush Anand CC: Catalin Marinas --- arch/arm64/include/asm/elf.h | 7 +++++-- arch/arm64/include/asm/thread_info.h | 3 +++ arch/arm64/kernel/process.c | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index 517b9ff0456c..9c4434b8a9a8 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -137,9 +137,13 @@ typedef struct user_fpsimd_state elf_fpregset_t; */ #define ELF_PLAT_INIT(_r, load_addr) (_r)->regs[0] = 0 +/* + * Don't modify this macro unless you add new personality. + * All personality-related setup should be done at proper place. + * If not sure, consider the arch_setup_new_exec() function. + */ #define SET_PERSONALITY(ex) \ ({ \ - current->mm->context.flags = 0; \ clear_thread_flag(TIF_32BIT); \ current->personality &= ~READ_IMPLIES_EXEC; \ }) @@ -195,7 +199,6 @@ typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; */ #define COMPAT_SET_PERSONALITY(ex) \ ({ \ - current->mm->context.flags = MMCF_AARCH32; \ set_thread_flag(TIF_32BIT); \ }) #define COMPAT_ARCH_DLINFO diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index 46c3b93cf865..c823d2f12b4c 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -68,6 +68,9 @@ struct thread_info { #define thread_saved_fp(tsk) \ ((unsigned long)(tsk->thread.cpu_context.fp)) +void arch_setup_new_exec(void); +#define arch_setup_new_exec arch_setup_new_exec + #endif /* diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 659ae8094ed5..e99012c4803a 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -417,3 +417,11 @@ unsigned long arch_randomize_brk(struct mm_struct *mm) else return randomize_page(mm->brk, SZ_1G); } + +/* + * Called immediately after a successful exec. + */ +void arch_setup_new_exec(void) +{ + current->mm->context.flags = is_compat_task() ? MMCF_AARCH32 : 0; +}