From patchwork Fri Jun 11 18:02:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 12316363 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9FB3C48BD1 for ; Fri, 11 Jun 2021 18:04:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A48E60234 for ; Fri, 11 Jun 2021 18:04:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A48E60234 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=arista.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6QM1XKms7PdRdduOv//N2Xkkne5dXiWiRcKQRF0HuZo=; b=h2sMyfhE1i6ZhI 4ZG9rhgRl67fs72di0gk5foorADdyDu7KKmwggW1UPYf6aQvjb3TdzopyZWkmKf7CuAy1QghQxnOM S3P4a0xmTDH6d3IOt/q94qv3tSYB1f5X4liobe/Ons30zH50GLq/zkoq/FnxMJjEJM6o77Gj5pVCA TNwvRbFEpM2klysLodPijJ1B2o6Pjv1GDqXxeBVu3z0yvi5b+NDMsjVoE1+/3xE26P51Ss2GdPFIR 8SFJZiJ/jz24bvp5o5NeRGI1qSYq7Y1tBGBWuFzIl8+a+2sJ0jJEtepCpVOzXrwM8PAIac7USWVqp LjurthF/ounzId5HDZOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lrlUk-006Otm-40; Fri, 11 Jun 2021 18:03:02 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lrlUg-006OsC-VF for linux-arm-kernel@lists.infradead.org; Fri, 11 Jun 2021 18:03:00 +0000 Received: by mail-wm1-x334.google.com with SMTP id l18-20020a1ced120000b029014c1adff1edso9127739wmh.4 for ; Fri, 11 Jun 2021 11:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+ZxH3CixZlkWsIeQExEBk552GYn4yb7O/v8JQ0YrsFk=; b=CRVK7dMpBkCDDD+iOdTmCqSaZQuZ87krHodrl41Glz6l6NZ9VFDc1J0o2YrZHUjKDy I4lf/bX9fyac0+a3k0m6mXrQ9COhAzVjw3Y/5GeCz8xjPmF8fr7pMbEyqRNbSFEhrmTk G/IaJdXsu3nxxenMeJpEr8e8AXhETF4z3YUHrnPXwDYiAQDbfVdKFBEUw9VNYOpDuT7/ EtkI6LD6tVWKULk2it6dTHBw3iW20VKbbnq9oVnOwdUceWxu0zr+Fla9W9PTkPuxkj7E 35i33amVo3SvU26nnsW408bMN2pIMrXKVbIQVmmoL/7knP2A1YNoGMBVBRYUqsoufuWk Tmcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+ZxH3CixZlkWsIeQExEBk552GYn4yb7O/v8JQ0YrsFk=; b=iTApYYK5qcDOTwqN2QL+tYC5o1iI0YsnJZoqFXc6HFptJvL4B6x+nGpP6J69jz102Y VpYTZaVPVldpik4QPt+gaNsqgoVo2YC4SYabpnVoy8STaTY0YTkTxo7KVOXB91iHHB5W xTyP+iT2m1F6SMjGuGUSCUImL/jm9l6a/tcF4w+HrkK71Q1YibSKH+R8k/N5SLMryf/B zQ4HPv5JMFCVkyHWrcvIOTNhTHP/9+nle6/YpPpkM9hJl339HEaN4jdtERJ1k9N2V3dR fCgIp2N1B7qlWL6sQjbSQb0XexsEquytbPsmyK3hABhZRuAbTn9GdNokRplVOa8Ml4z9 M8tw== X-Gm-Message-State: AOAM533CLdtQpTFfX60lhJ3OhQDKUVd/FbM/yCTyI5VT3mosWImLRPTP eSa9W73fGlIutN3m125D0Ij1Yg== X-Google-Smtp-Source: ABdhPJwwjZ2UPiMcwOhfpARIPLcq2/5bx41bOdaa+KiB8dZU/X/bki+LCybOVoQ2Qelszgc9HJkDWQ== X-Received: by 2002:a7b:c8d0:: with SMTP id f16mr22257887wml.115.1623434574885; Fri, 11 Jun 2021 11:02:54 -0700 (PDT) Received: from localhost.localdomain ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id v15sm7425881wrw.24.2021.06.11.11.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 11:02:54 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Cc: Dmitry Safonov <0x7f454c46@gmail.com>, Dmitry Safonov , Alexander Viro , Andrew Morton , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Guo Ren , "H. Peter Anvin" , Ingo Molnar , Oleg Nesterov , Russell King , Thomas Bogendoerfer , Thomas Gleixner , Vincenzo Frascino , Will Deacon , x86@kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 04/23] arm64: Use in_compat_task() in arch_setup_additional_pages() Date: Fri, 11 Jun 2021 19:02:23 +0100 Message-Id: <20210611180242.711399-5-dima@arista.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210611180242.711399-1-dima@arista.com> References: <20210611180242.711399-1-dima@arista.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210611_110259_035597_3004E0D5 X-CRM114-Status: GOOD ( 16.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Instead of providing compat_arch_setup_additional_pages(), check if the task is compatible from personality, which is set earlier in load_elf_binary(). That will align code with powerpc and sparc, also it'll allow to completely remove compat_arch_setyp_addtional_pages() macro after doing the same for x86, simiplifying the binfmt code in the end and leaving elf loader single function. Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Dmitry Safonov Acked-by: Will Deacon --- arch/arm64/include/asm/elf.h | 5 ----- arch/arm64/kernel/vdso.c | 21 ++++++++++----------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index d1073ffa7f24..a81953bcc1cf 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -237,11 +237,6 @@ do { \ #else #define COMPAT_ARCH_DLINFO #endif -struct linux_binprm; -extern int aarch32_setup_additional_pages(struct linux_binprm *bprm, - int uses_interp); -#define compat_arch_setup_additional_pages \ - aarch32_setup_additional_pages #endif /* CONFIG_COMPAT */ diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index a61fc4f989b3..a8bf72320ad0 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -411,29 +411,24 @@ static int aarch32_sigreturn_setup(struct mm_struct *mm) return PTR_ERR_OR_ZERO(ret); } -int aarch32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) +static int aarch32_setup_additional_pages(struct linux_binprm *bprm, + int uses_interp) { struct mm_struct *mm = current->mm; int ret; - if (mmap_write_lock_killable(mm)) - return -EINTR; - ret = aarch32_kuser_helpers_setup(mm); if (ret) - goto out; + return ret; if (IS_ENABLED(CONFIG_COMPAT_VDSO)) { ret = __setup_additional_pages(VDSO_ABI_AA32, mm, bprm, uses_interp); if (ret) - goto out; + return ret; } - ret = aarch32_sigreturn_setup(mm); -out: - mmap_write_unlock(mm); - return ret; + return aarch32_sigreturn_setup(mm); } #endif /* CONFIG_COMPAT */ @@ -470,7 +465,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) if (mmap_write_lock_killable(mm)) return -EINTR; - ret = __setup_additional_pages(VDSO_ABI_AA64, mm, bprm, uses_interp); + if (is_compat_task()) + ret = aarch32_setup_additional_pages(bprm, uses_interp); + else + ret = __setup_additional_pages(VDSO_ABI_AA64, mm, bprm, uses_interp); + mmap_write_unlock(mm); return ret;