Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF41DC433F5 for ; Mon, 18 Oct 2021 14:19:26 +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 800DD60ED5 for ; Mon, 18 Oct 2021 14:19:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 800DD60ED5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=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: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:In-Reply-To:References: List-Owner; bh=rZM/ZpK2ozKFCGxwK6DDhw4a9VCfu811Jl5jK2cNOXs=; b=q96j0G278Eq2rn vEVAdw2ckzb/16+ZFGO23XWtt+NiAep2vFGQ69cb4qGBCBbbWgf9HO7qp88hZvicwpwmZrmbuMKbM X/o8DiW7ksWZUxQnQjM9aaJxs/gjVH86/PxUAH+Fz0LAiMaZ9l79xldvbj+MGc52HfQ8l2yo6r9AZ 3e39FlmhZJ7Tl9fbJxFRbx9Ek2M1sLcRC1jQ2REms7/En7+bNPepIqR61NIo8imrvH2o+AIQnAfb/ bI6rDi1Ds4x0w41iIwcUhrpXjjMDFi93nw/ADco7gFoc2V1ypPrVnklziA90UcI1wx1vN7WCcHAEl A5DSihy8GBTsRyIGPDcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcTS8-00G35G-Oy; Mon, 18 Oct 2021 14:17:25 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcTRG-00G2ij-MQ for linux-arm-kernel@lists.infradead.org; Mon, 18 Oct 2021 14:16:33 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5CD4E60F9F; Mon, 18 Oct 2021 14:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634566589; bh=I8Bxl8Rm0e2er3FWbrHO+1a1EnvPLYqvjJKmKM0CJQ8=; h=From:To:Cc:Subject:Date:From; b=QvFy1L2XbXuY5YM+fmL1oXXirBja4Law2g4J1Z3I/G47bvuR8c1ltCBr7XF38bPqd nc0ECoCeKwDTLPAp61lWKQrlCMFHqTmnJI+j0TKNfHXNsIDlucX3dLNHAp84b0nAVB XyPZmpubu9zN8g4jdDCh9FaeZLFtB45YNK/WBiVPPq/cQ4caAsOhxjZNfLI4UxSoRE JF9+hfXr8PMboVki9zwY5KndJHdbb+NlYYW468qmEmckpe/zo7eiAyGvfIdT5YVyEI /vNLys+e9/glTyl5YxIYDeSzBeF0Sl8WUZz5jo43rxIg4ZlIVA/wOJpXiOWad6H/D+ FiP45dAVzEjFA== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Russell King , Nicolas Pitre , Arnd Bergmann , Kees Cook , Keith Packard , Linus Walleij , Nick Desaulniers Subject: [PATCH v2 0/7] ARM: add vmap'ed stack support Date: Mon, 18 Oct 2021 16:16:08 +0200 Message-Id: <20211018141615.682070-1-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3744; h=from:subject; bh=I8Bxl8Rm0e2er3FWbrHO+1a1EnvPLYqvjJKmKM0CJQ8=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBhbYGgNhyypCb/F9Eqz6UjSCjGZpKDtb30OSxkdFFs eeO5joGJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYW2BoAAKCRDDTyI5ktmPJKXpC/ 9w1vdEfzJ2RmN0z0ESXXxO7Mg3BTTCdHDfhUGAPvsoEiYSdhnrtmC5PhBtEglthv/pIU7RFb//8O68 d7oFhtdoqdMBlrevPfePyT+ro/nXGNRqEVgGP3N/OM8oz4tf0f7rRQqPuZqcdF1uIFkLa4hkM7oqmu J4/gdHCThbomTeBpFa+JpWaexbv9WgrZqz1wbRfGrbpmDcCUb+adNMn/Gfd+W0Or4Rx+cexVLNxcxR /BKcqY8D/1nXXQeEwiTNtFxaVo05KocE1hJBcZZFTUuaP3ArYAzG3tGHhUYbaVNTr0kgOK/m2EM1PA fGICqadmufe8Fk/66/FN3QRffbjf34ntTUTIR5FnPWo3IUxQUC38UJEpdjoWenuZdy3k/JrUEapoJB D3wOEVHXlWtbGyUpObxk/LQTQZZ6pakN3FkjnHzH3sI1Rp7ylveV+tUdriLXvl5Hr62MpiyRYv6h+Z vwPmYwmwO+GAmMEVz6NYS7P7Kis2dJDFrTvmVkq3CQs+k= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211018_071630_821115_F147CF01 X-CRM114-Status: GOOD ( 17.88 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series enables support on ARM for vmap'ed task and IRQ stacks in the kernel. This is an important hardening feature that terminates tasks on inadvertent or deliberate accesses past the stack pointer, which might otherwise go completely unnoticed. Since having an accurate backtrace is especially important in such cases, this series includes some enhancements to the unwinder and to some hand rolled unwind info to increase the likelihood that a backtrace can be generated when relying on the ARM unwinder. The frame pointer unwinder turns out to be rather bullet proof in this context, and does not need any such enhancements. According to a quick survey I did, compiler generated code puts a single stack push as the first instruction in about 2/3 of the cases, which the unwinder can deal with after applying patch #4, even if this push faulted because of a stack overflow. In the remaining cases, the compiler tends to fall back to R11 or R7 as the frame pointer (on ARM or Thumb-2, respectively), or emit partial unwind frames for the part of the function that runs before the stack frame is set up, and the part that runs inside the stack frame. In either case, the unwinder can deal with such occurrences as they don't rely on the stack pointer directly. Changes since v1: - handle a missed corner case in svc_entry code, and while at it, streamline it a bit, especially for Thumb-2, which no longer needs to move SP into R0 twice to do the overflow check and the alignment check, - improve the memcpy patch so that we no longer need to push the frame pointer separately, - add Keith's tested-by Patches #1, #2 and #3 update the ARM asm string routines to align more closely with the compiler's approach in terms of unwind tables, increasing the likelihood that we can unwind them in case of a stack overflow. Patches #5 and #6 do some preparatory refactoring for the entry and switch_to code, to reduce clutter in patch #7. Patch #7 wires up the generic support, and adds the entry code to detect and deal with stack overflows. This series applies onto my IRQ stacks series sent out earlier: https://lore.kernel.org/linux-arm-kernel/20211005071542.3127341-1-ardb@kernel.org/ Cc: Russell King Cc: Nicolas Pitre Cc: Arnd Bergmann Cc: Kees Cook Cc: Keith Packard Cc: Linus Walleij Cc: Nick Desaulniers Ard Biesheuvel (7): ARM: memcpy: use frame pointer as unwind anchor ARM: memmove: use frame pointer as unwind anchor ARM: memset: clean up unwind annotations ARM: unwind: disregard unwind info before stack frame is set up ARM: switch_to: clean up Thumb2 code path ARM: entry: rework stack realignment code in svc_entry ARM: implement support for vmap'ed stacks arch/arm/Kconfig | 1 + arch/arm/include/asm/page.h | 4 + arch/arm/include/asm/thread_info.h | 8 ++ arch/arm/kernel/entry-armv.S | 112 ++++++++++++++++---- arch/arm/kernel/entry-header.S | 57 ++++++++++ arch/arm/kernel/irq.c | 9 +- arch/arm/kernel/traps.c | 65 +++++++++++- arch/arm/kernel/unwind.c | 19 +++- arch/arm/kernel/vmlinux.lds.S | 4 +- arch/arm/lib/copy_from_user.S | 13 +-- arch/arm/lib/copy_template.S | 67 ++++-------- arch/arm/lib/copy_to_user.S | 13 +-- arch/arm/lib/memcpy.S | 13 +-- arch/arm/lib/memmove.S | 60 ++++------- arch/arm/lib/memset.S | 7 +- 15 files changed, 315 insertions(+), 137 deletions(-) -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel