From patchwork Thu Oct 17 12:59:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13839978 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9A102D37485 for ; Thu, 17 Oct 2024 13:05:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To: Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id:Date:Subject: 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=fnpP3oSO+pNE9T1R4DyYSvsrG5uVU7YmtdEeT5HWRtg=; b=UYDaOHVInRIFYy 2gUqrPMdyS6/XDpMgx1WO/FU8q+gaKSYfwL3BV50C8RXxCn/e2IvRa5lYUMR1meG9R6UbdLgyRYqt oeV/9wCxEhciA2QBvJmXYkqZMRuYduZjsxPSDHqXjxzGGH0+fc4LLWbvGn+vuex3tBO8xAxD7mq54 kGNoPvuTfKglenO12wtniEXgefMaNsvB/+5e9dGXtXgAM2W5iftqu6XoNsk0fSFfWHJiZikqwunET OUdBVqF5dt3ZfyabpRzMCyvTpMD2sRdOM+r37DIyp6bJYNBVoAqYZhOs9s9ZitPqYQdHd/z643/BT SGIQ8+wzaAWgJiGb2zLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1QBs-0000000ErXc-2mDy; Thu, 17 Oct 2024 13:05:20 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1Q5v-0000000Eqp4-0NRN for linux-arm-kernel@lists.infradead.org; Thu, 17 Oct 2024 12:59:15 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-539fbbadf83so1155108e87.0 for ; Thu, 17 Oct 2024 05:59:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729169949; x=1729774749; darn=lists.infradead.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=fnpP3oSO+pNE9T1R4DyYSvsrG5uVU7YmtdEeT5HWRtg=; b=eT11cvbl1298bClktdSe2BfsVmS/hNtEwlTSAefRHiFa6i9T2t5jovhTRqo9zxWDPS S0SdvOsFi3grDd0eATbO+Pdl4MBi3kfYBfo52UAKZUJOwTJdHhXohra0Aejhr7NWrYSD afQEgE8yxYXIRLgPr+B3lJuDzmP6KLuEI/C2moMjSSmDF8lvEidgUFNKyrWI7yEPAs3F SEVqOouQVjNYQgChHHNDDuk0zAXzWbCT5px2ln/xESBtyR6VM0HZLxKW0lKKrSI8rdCZ YekfjxqUm99gCy+YOvSlHZAHcev4vFDP+N39Bmfeym6uvsxN1vnnDAhTad5u/iWyxp3B jyRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729169949; x=1729774749; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fnpP3oSO+pNE9T1R4DyYSvsrG5uVU7YmtdEeT5HWRtg=; b=gez00FL9k7kn6GCNhUOUxlC3W2SRHfXkNBYIujES8CB1o/2LaJRfcZpSNvrisKLTU1 QRASxjY5+x6TVsKcZXv3iwqbd1ro/HCJuAS98THkB6DgXbc1fCwaA0F5ESJpwN71bf/z elnmgsTyEwsA11s8zNHg/xWl6pxIpI5X5gdnorUgFWG/mVuroVcBiJdv0sgnbl7nE2US /UAHHppuBdnUEl6MSOSYOIFEgBel0KGVNPWxpjqHCqWG4W8yjtrYVuIfnWxmiD1dccJ1 PqlO+IOL8vVOCvvMlxnPjHOjoOqWgkJ3KNZSRvGTjQQuVzKIADfGM5jUnMs+nRfz23T7 Y2CQ== X-Forwarded-Encrypted: i=1; AJvYcCVAyskkma5DdlRurPHSCx62yBqXwax5R9UDZa4qCyYWyrWw0rWed4ZgPP+Y+/pasLPb50pwCiTnFtOYnfsTCV/o@lists.infradead.org X-Gm-Message-State: AOJu0YxeVac1glEwNJU/JevnKrRp3OPLL3jdUCztq7Vh7GLucn8z86r6 1jvvbmfKvRSCNoA7UB9WFYU33+JCdpAPTyBV31qLUiMarNoFwmxci9/bvCUbPKY= X-Google-Smtp-Source: AGHT+IEnJVfMeUhY9wGBPKaQBeiAR/UT76Ac9B78KnBxmjeq9yJIEH2UaMvxN5sYtbJPnm7CkirEAg== X-Received: by 2002:a05:6512:39c5:b0:539:ebd6:a951 with SMTP id 2adb3069b0e04-539ebd6ac7cmr8909564e87.61.1729169948204; Thu, 17 Oct 2024 05:59:08 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53a00013c21sm763349e87.270.2024.10.17.05.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 05:59:07 -0700 (PDT) From: Linus Walleij Subject: [PATCH v3 0/2] Fix KASAN crash when using KASAN_VMALLOC Date: Thu, 17 Oct 2024 14:59:04 +0200 Message-Id: <20241017-arm-kasan-vmalloc-crash-v3-0-d2a34cd5b663@linaro.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIABgKEWcC/4XNQQ6CMBCF4auQrh3TForoynsYF0NboBFaMzWNh nB3CytdGJf/S+abmUVLzkZ2KmZGNrnogs9R7gqmB/S9BWdyM8llJbhQgDTBDSN6SBOOY9CgCeM AnW6NEpWoK3Vg+fpOtnPPTb5ccw8uPgK9tkdJrOt/MwngYNpWluooNTbleXQeKewD9WxFk/yE6 t+QzBBHJTvDm9ra7gtaluUNkuh2oggBAAA= To: Clement LE GOFFIC , Russell King , Kees Cook , AngeloGioacchino Del Regno , Mark Brown , Mark Rutland , Ard Biesheuvel Cc: Antonio Borneo , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Linus Walleij , stable@vger.kernel.org X-Mailer: b4 0.14.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_055911_197577_366E2AA9 X-CRM114-Status: GOOD ( 12.97 ) 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 This problem reported by Clement LE GOFFIC manifest when using CONFIG_KASAN_IN_VMALLOC and VMAP_STACK: https://lore.kernel.org/linux-arm-kernel/a1a1d062-f3a2-4d05-9836-3b098de9db6d@foss.st.com/ After some analysis it seems we are missing to sync the VMALLOC shadow memory in top level PGD to all CPUs. Add some code to perform this sync, and the bug appears to go away. As suggested by Ard, also perform a dummy read from the shadow memory of the new VMAP_STACK in the low level assembly. Signed-off-by: Linus Walleij --- Changes in v3: - Collect Mark Rutlands ACK on patch 1 - Change the simplified assembly add r2, ip, lsr #n to the canonical add r2, r2, ip, lsr #n in patch 2. - Link to v2: https://lore.kernel.org/r/20241016-arm-kasan-vmalloc-crash-v2-0-0a52fd086eef@linaro.org Changes in v2: - Implement the two helper functions suggested by Russell making the KASAN PGD copying less messy. - Link to v1: https://lore.kernel.org/r/20241015-arm-kasan-vmalloc-crash-v1-0-dbb23592ca83@linaro.org --- Linus Walleij (2): ARM: ioremap: Sync PGDs for VMALLOC shadow ARM: entry: Do a dummy read from VMAP shadow arch/arm/kernel/entry-armv.S | 8 ++++++++ arch/arm/mm/ioremap.c | 25 +++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) --- base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc change-id: 20241015-arm-kasan-vmalloc-crash-fcbd51416457 Best regards,