Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1953457lqz; Tue, 2 Apr 2024 02:49:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV4Ejqi4bKrAQY2jy1yYptf+Ok9v18eO4yoCbcsp5jK/roAzYlPI2BUFfdTQbkYx1uu1DgxQf7auzg+Rk6nLK9G7b3hwyNDGnx2Lf40JA== X-Google-Smtp-Source: AGHT+IFYROyE13KamWwyHtYQN+xieBq1pIxEHhkCAJXOHIvGaEP5my8wQM/mDHlkSSc4zyo9SUp0 X-Received: by 2002:a05:620a:371b:b0:78b:befc:4c2c with SMTP id de27-20020a05620a371b00b0078bbefc4c2cmr15334992qkb.58.1712051388090; Tue, 02 Apr 2024 02:49:48 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o12-20020a05620a0d4c00b00789e887c788si11140859qkl.772.2024.04.02.02.49.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 02:49:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=VbYEZPmW; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-127660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127660-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CDBFF1C222A8 for ; Tue, 2 Apr 2024 09:49:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29A9258AC1; Tue, 2 Apr 2024 09:49:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VbYEZPmW" Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0F8758113 for ; Tue, 2 Apr 2024 09:49:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712051381; cv=none; b=Q/V27fGy6hSKiS/jLbAZJ7UBudntc7tfwI+9d23/eNvgZ1j9chQtFamBInjX2S7+A32fRr7XfFtbxERMKU5YGK871wAo0Gm2tNFDjQ0/FjVGfgIYbG8wqA2eP74ULHfncmyuAwiLSi7zPuA2umPM+fgu7Jh/O8PPnO48weGTayI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712051381; c=relaxed/simple; bh=4/EtvWS0lZMV84j65Uy5L17yPmitKMCnx+1V6GM8jWc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=LWZ75R8Wa4a/lwYhZ8ka/MHMy/Y6YZIknnR+bfSronXLE6Z0lPat4DDrbAgp/5mBHt7VI3YHf/FrM7LFeG0FQVxGOdf3DEc7G6Kk1AyT0HcQUqs3DutN7I75zTa93yH9NGgLwHmMTQXprwMSI+xQRIcsV8rMTTTGLW1qlT4XVwg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VbYEZPmW; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3436fec6a70so186486f8f.2 for ; Tue, 02 Apr 2024 02:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712051378; x=1712656178; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=khWTrPazDRXs/RM2v0O9wjs2bqj7qxq5S67ky2y7oZw=; b=VbYEZPmWNXs/aGck0WtQb1eAzJbZPyoIxNAnkcL+fYKyT31jicFzEkcBMQZShdGz+D DeAuIy1wdPhBPcWF6r0aSXitYEN9UGg63bVy6fRVohbgu+feUFUtkNLDtC79gHIB9TLf lrCZjDqhbZKA7iunj2REuv+1wnJkel/D5bQ0MBtvCs6D1KPtHZ/7LsmbwX+Zs+W+VqDU RcMwvDFr/oRDZjmc9f7ob5n9HqxtJ4JH5BIHPPaAsrtUFjj/KpH4LK4qJK7AjU9fXDM8 I97M7LV4oJkk1aKtUlJmlcy1zIcks3gPjOzSiEY5QR/zUnXpcZuEJX3SEReGvkcycU73 D0dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712051378; x=1712656178; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=khWTrPazDRXs/RM2v0O9wjs2bqj7qxq5S67ky2y7oZw=; b=AgAf4DWKEOjFW0js1VmagGPj3KUl4hTpiZvRB+9+rvT9XRCUGuOGMXXsE3VxcjpF0M WhDs4DBltSEPvYViaqCEbJvNxgvP81HPrez3wA0XXR18a2kQz1uCcz2AHmVs5Uwl285p rKlP8qpOemyb9TUqx5KLdu0LInpxLrsGdHV+uRSq5OPzQPtl0zoq25R6BSltbKzYpWQg sVIoKwtaWyDRmfSG3na94ilB7eqDlfkOn3f0oL7NSsUk+Iyyc2nd18x7wSzAuaZYs9xZ hzT469zwykgIVnDq4cHZaWkC8ELJo5B/06gxvjzfQlKp8mOxGxJPd3Stz+MXkUYUc0DL 5bvQ== X-Forwarded-Encrypted: i=1; AJvYcCUffaFb6WEpBt0L7viTHSOVDgQILAZ/g1WVR8TB6faavw7L0e+GRwQnFZMLqys/wBinmEK4qBqZxH4agW/61czEU5imZzTdiR7llcfk X-Gm-Message-State: AOJu0YzTXo0eYmMNkpkN8A0JppgY5qgzRZDyFEiWaWcinhz7CIUdH3+u 8I1LE0H7wRb4L3NVhYh31XyioKZ73sUbz8i5u+SxPSpDL3RVgHUU7rmyFKwd+wBi5fIBUavai5G o3pGA3IdxIjsr3vP+rxupyH0XJnM= X-Received: by 2002:a5d:4d07:0:b0:341:cf9b:c8e with SMTP id z7-20020a5d4d07000000b00341cf9b0c8emr10357697wrt.50.1712051377736; Tue, 02 Apr 2024 02:49:37 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231222022741.8223-1-boy.wu@mediatek.com> In-Reply-To: From: Andrey Ryabinin Date: Tue, 2 Apr 2024 11:48:37 +0200 Message-ID: Subject: Re: [PATCH] arm: kasan: clear stale stack poison To: Mark Rutland Cc: "boy.wu" , Russell King , Matthias Brugger , AngeloGioacchino Del Regno , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Linus Walleij Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 2, 2024 at 11:36=E2=80=AFAM Mark Rutland = wrote: .. > It looks like you're specifically referring to what arm64 did in commit: > > 0d97e6d8024c71cc ("arm64: kasan: clear stale stack poison") > > Where the commit message explained the problem: > > | Functions which the compiler has instrumented for KASAN place poison on > | the stack shadow upon entry and remove this poison prior to returning. > | > | In the case of cpuidle, CPUs exit the kernel a number of levels deep in > | C code. Any instrumented functions on this critical path will leave > | portions of the stack shadow poisoned. > | > | If CPUs lose context and return to the kernel via a cold path, we > | restore a prior context saved in __cpu_suspend_enter are forgotten, and > | we never remove the poison they placed in the stack shadow area by > | functions calls between this and the actual exit of the kernel. > | > | Thus, (depending on stackframe layout) subsequent calls to instrumented > | functions may hit this stale poison, resulting in (spurious) KASAN > | splats to the console. > | > | To avoid this, clear any stale poison from the idle thread for a CPU > | prior to bringing a CPU online. > > ... which we then extended to check for CONFIG_KASAN_STACK in commit: > > d56a9ef84bd0e1e8 ("kasan, arm64: unpoison stack only with CONFIG_KASAN_= STACK") > > If you can fold in the description above (i.e. cite commit 0d97e6d8024c71= cc and > a copy of its commit message): > > Reviewed-by: Mark Rutland > Agreed with the above, feel free to add: Acked-by: Andrey Ryabinin