Message ID | 20241021-arm-kasan-vmalloc-crash-v4-3-837d1294344f@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> 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 67789D15D90 for <linux-arm-kernel@archiver.kernel.org>; Mon, 21 Oct 2024 13:34:07 +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:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EPZW3o9O8KMd2l9bsdly639M9ayrVvVJPmPDhVzCI64=; b=xMMBcLONBQ0gHE73wVPFCW97j6 FVnH86xiOSm7gCD+R+CKWJgj/Ntgl7ZBv8tyxi22BRgjR6BslxYzQDqXz3gZNEpPJVjACOmAI3qRV 59nbVUMHCCnJQB37bwfwSXLHulLLwF33JAfcuTDvEPoeabl5ZVtt5l/X7+gNejRNKKjaGjuIY0i/Q DV0pw2ntwVhPro8uyc+uPnIerKxS/6G7+yUEs4FPCRlWuiyuG8py0rAD1hkEdif2DO4qqyvJs6Geg MzpzMFsdwQZpjj5zIPoA3iAZESkIzaRHldDy9zYtoCqhTwdTiQtui8LGyBeTByrzWSWMkhmSShmMa kiQ3fl6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2sXj-00000007QmV-12d3; Mon, 21 Oct 2024 13:33:55 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2s41-00000007MIi-1b4H for linux-arm-kernel@bombadil.infradead.org; Mon, 21 Oct 2024 13:03:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=EPZW3o9O8KMd2l9bsdly639M9ayrVvVJPmPDhVzCI64=; b=lAocx7Mcr2QCN89/vagm1jFIs7 OGFH8omMXPzh08DzaeGebDkPAA/iuuuaos6kueGdS7SMNaNzThASQeTZoYlA6FkIVMD0I/vEKeNnc INtkyTZ9mAs9UxtjSZq0I6UxtRTWU2G5XnTUqsrP15Y16k/0WjZwSm1P9iRy28NYfLk5V3o344kM1 8bhg4Ow/qnZy0brdmAGOVsq4P3wxi3tHJnZ5n70cmwpO+HQvkAjsNL9AnqxDsHs68zyxHic/eeSA+ y2eWgyMGkhyG7OVeeZxpHE2FXRI4rqM+u5KoTV8ZjzKAJ55Rur2wkX0NKXaoAF08T7v3M4ei/Yee5 IwCIE24g==; Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2s3y-00000007wZ0-20K1 for linux-arm-kernel@lists.infradead.org; Mon, 21 Oct 2024 13:03:12 +0000 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2fb561f273eso43246301fa.2 for <linux-arm-kernel@lists.infradead.org>; Mon, 21 Oct 2024 06:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729515787; x=1730120587; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EPZW3o9O8KMd2l9bsdly639M9ayrVvVJPmPDhVzCI64=; b=oIF9dZBPNgjqfhKzt7YCJmJdAo6IZ2vh6KItmF7F44DUudSQLkE0L76SXqa5GHIC6K sIeXRTKYkD3fXh9+az9w+CF9O4H3D5FcP8O+YglEvHqB6Fp5GUiZNYHnaI0hKe+uIMsm GgWCfzWnVvS5oreKvISImUSRkg6hyxvodT2zwrl5ffpbVm/9vK5700zO4spUXkdDFwu6 ISkeB5bs/Nd52NNZqrhec2xMc+btW/7Zk+5aAivnE9ELKySc5rsmM0/aDC2bOkxoC/QE wwDtgyju4smiLEy+qiHYw1avQVMNddC57ReGUoL7KwCd0U52xTo7R6iq/5E5y8S1/qUC 9RXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729515787; x=1730120587; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EPZW3o9O8KMd2l9bsdly639M9ayrVvVJPmPDhVzCI64=; b=dnzLnyqwRfkZHLGgfSiTUg3yJyfK0tLmjWrMDkee+uUslIcIjxdaq0wjFzniQhciGR +tHd7Pr81q+eROFsp+5ITFLZsY3PezsqQsMit2de2/AHlF0GObXSPikn97ntsGWCdNb0 +aTIobQEYFiGwKMshTbC4ciHVaRpKNhoPgQuoawwaGFun7WVsMbnQjtJRZoLaYWIGR2/ V5hIUntFF/wFlrzqnJ6ZoI4z7umtqS0ROZlUEwnotWG8wm/yd4kU9IQTGI8sUOOeLKTE SJ8BiLHrw1JOBef14ywQuK5ZglMlMvoxrrr4VFI3fujRUs3ufTDfZfuTl9djEb1huQfQ RXuw== X-Forwarded-Encrypted: i=1; AJvYcCUhehSfFsWIaRgVKeyGjXXmB/gMqjCUuDOScHie+fCN+NLGSkj78qLdkirsh9kEJVVoGMUBkw+enxWqo1d4fvRg@lists.infradead.org X-Gm-Message-State: AOJu0Yxi2NWMILIOZOkw1VwTs1D0CulQQGE0BXm/kcgVha2dAYDk8gxG rxpDlRX8t9AmggctR5KdU26z2Hh/PIMYjnIKVaL5x8EcmtdEuiLvdqLXR3w/Rus= X-Google-Smtp-Source: AGHT+IE4bNxBuZiSo/LWHqIIi8XGiP3WfZqN2gNbTogSdqcLj7y34HS7yjaWiYcbIZDL3xkyYyjdIw== X-Received: by 2002:a2e:e0a:0:b0:2fa:cdac:8723 with SMTP id 38308e7fff4ca-2fb83208b7cmr38383041fa.29.1729515787337; Mon, 21 Oct 2024 06:03:07 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2fb9ae24d51sm4808351fa.130.2024.10.21.06.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 06:03:06 -0700 (PDT) From: Linus Walleij <linus.walleij@linaro.org> Date: Mon, 21 Oct 2024 15:03:00 +0200 Subject: [PATCH v4 3/3] mm: Pair atomic_set_release() with _read_acquire() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20241021-arm-kasan-vmalloc-crash-v4-3-837d1294344f@linaro.org> References: <20241021-arm-kasan-vmalloc-crash-v4-0-837d1294344f@linaro.org> In-Reply-To: <20241021-arm-kasan-vmalloc-crash-v4-0-837d1294344f@linaro.org> To: Clement LE GOFFIC <clement.legoffic@foss.st.com>, Russell King <linux@armlinux.org.uk>, Melon Liu <melon1335@163.com>, Kees Cook <kees@kernel.org>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Mark Brown <broonie@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Ard Biesheuvel <ardb@kernel.org> Cc: Antonio Borneo <antonio.borneo@foss.st.com>, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Linus Walleij <linus.walleij@linaro.org>, 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-20241021_140310_752849_5CA99B10 X-CRM114-Status: GOOD ( 15.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
Fix KASAN crash when using KASAN_VMALLOC
|
expand
|
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c index ff555823cceb..89f1c97f3079 100644 --- a/arch/arm/mm/ioremap.c +++ b/arch/arm/mm/ioremap.c @@ -141,7 +141,7 @@ void __check_vmalloc_seq(struct mm_struct *mm) int seq; do { - seq = atomic_read(&init_mm.context.vmalloc_seq); + seq = atomic_read_acquire(&init_mm.context.vmalloc_seq); memcpy_pgd(mm, VMALLOC_START, VMALLOC_END); if (IS_ENABLED(CONFIG_KASAN_VMALLOC)) { unsigned long start =
The code for syncing vmalloc memory PGD pointers is using atomic_read() in pair with atomic_set_release() but the proper pairing is atomic_read_acquire() paired with atomic_set_release(). This is done to clearly instruct the compiler to not reorder the memcpy() or similar calls inside the section so that we do not observe changes to init_mm. memcpy() calls should be identified by the compiler as having unpredictable side effects, but let's try to be on the safe side. Cc: stable@vger.kernel.org Fixes: d31e23aff011 ("ARM: mm: make vmalloc_seq handling SMP safe") Suggested-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- arch/arm/mm/ioremap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)