From patchwork Fri Apr 19 20:49:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bethany Jamison X-Patchwork-Id: 1925675 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLmx01Zzxz1yZP for ; Sat, 20 Apr 2024 06:49:55 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rxvB6-0002Lx-5a; Fri, 19 Apr 2024 20:49:48 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rxvB3-0002LY-Ev for kernel-team@lists.ubuntu.com; Fri, 19 Apr 2024 20:49:45 +0000 Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id D74F93F331 for ; Fri, 19 Apr 2024 20:49:44 +0000 (UTC) Received: by mail-io1-f71.google.com with SMTP id ca18e2360f4ac-7da686b1638so53073439f.0 for ; Fri, 19 Apr 2024 13:49:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713559783; x=1714164583; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=04Bs13OcZNxRnADQqA9fZC5MUFfhGRpWKrrA+DMKmxc=; b=SWiCniyz8NqqvJtH8+XGI0YIZi1ISBuP16nNB+TKCtimUbvY6wAnKwEq0PGsam3uXL 2lVRgLkEagRZ/4ziqgTqKuhzwGeuzlXqMJGC6xtv8JtO949CDP2haAG75sf47fA72xsw xQP4StxwuA2BlKjmLGVu1ZYu4GRICBzyVKkiq14uqM+MEBAAyKUKUmXGbvOY4kKrB/D+ WUpM6Y76hWkzYOG0zR1UHxK4k79vjJ84C/lDEcrsDVBjVc0F2Kepoklr7XrntElpZsRl 1MvV5K+gDuPpyMmxThHQvho3lq5kL3CNK0HxXrcAo6J2c+egTeqvHqZ8OBQUec8T0khd aIeA== X-Gm-Message-State: AOJu0YyYcXg8sgZ8NtO2cIbvrNR8KUX/jn/nY1cKa79eWWCvlRt03Ydr ueARDvB0j1JB248AcQYekXLm2+WijrLvqMDBLWpHgmYWqgS87Qx3tAJ35T3Ep3T1THX16qzKspI 1CYI8AfWN+kUNt+Vl2qjl+jFngvJlopz43kG6BJ4YqHHVINZLGYI3fzLTGzBdd71Wj0QV9eg9Wh 9Bt703nuE9zBv+ X-Received: by 2002:a6b:651a:0:b0:7d5:d609:a65 with SMTP id z26-20020a6b651a000000b007d5d6090a65mr3038554iob.6.1713559783611; Fri, 19 Apr 2024 13:49:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEa4yZMp9qCKeUAiDIQjjcwsQVcEotefsGL2hkPdbtvyY52sE4rUNauQph81NjhxpnZWb+ynQ== X-Received: by 2002:a6b:651a:0:b0:7d5:d609:a65 with SMTP id z26-20020a6b651a000000b007d5d6090a65mr3038521iob.6.1713559782090; Fri, 19 Apr 2024 13:49:42 -0700 (PDT) Received: from smtp.gmail.com (104-218-69-129.dynamic.lnk.ne.allofiber.net. [104.218.69.129]) by smtp.gmail.com with ESMTPSA id g4-20020a056602150400b007d65ee260d0sm1082075iow.6.2024.04.19.13.49.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 13:49:41 -0700 (PDT) From: Bethany Jamison To: kernel-team@lists.ubuntu.com Subject: [SRU][M][PATCH 1/1] powerpc/kasan: Limit KASAN thread size increase to 32KB Date: Fri, 19 Apr 2024 15:49:39 -0500 Message-Id: <20240419204939.46696-2-bethany.jamison@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240419204939.46696-1-bethany.jamison@canonical.com> References: <20240419204939.46696-1-bethany.jamison@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Michael Ellerman [ Upstream commit f1acb109505d983779bbb7e20a1ee6244d2b5736 ] KASAN is seen to increase stack usage, to the point that it was reported to lead to stack overflow on some 32-bit machines (see link). To avoid overflows the stack size was doubled for KASAN builds in commit 3e8635fb2e07 ("powerpc/kasan: Force thread size increase with KASAN"). However with a 32KB stack size to begin with, the doubling leads to a 64KB stack, which causes build errors: arch/powerpc/kernel/switch.S:249: Error: operand out of range (0x000000000000fe50 is not between 0xffffffffffff8000 and 0x0000000000007fff) Although the asm could be reworked, in practice a 32KB stack seems sufficient even for KASAN builds - the additional usage seems to be in the 2-3KB range for a 64-bit KASAN build. So only increase the stack for KASAN if the stack size is < 32KB. Fixes: 18f14afe2816 ("powerpc/64s: Increase default stack size to 32KB") Reported-by: Spoorthy Reported-by: Benjamin Gray Reviewed-by: Benjamin Gray Link: https://lore.kernel.org/linuxppc-dev/bug-207129-206035@https.bugzilla.kernel.org%2F/ Signed-off-by: Michael Ellerman Link: https://msgid.link/20240212064244.3924505-1-mpe@ellerman.id.au Signed-off-by: Sasha Levin (cherry picked from commit 4cc31fa07445879a13750cb061bb8c2654975fcb linux-6.6.y) CVE-2024-26710 Signed-off-by: Bethany Jamison --- arch/powerpc/include/asm/thread_info.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h index bf5dde1a41147..15c5691dd2184 100644 --- a/arch/powerpc/include/asm/thread_info.h +++ b/arch/powerpc/include/asm/thread_info.h @@ -14,7 +14,7 @@ #ifdef __KERNEL__ -#ifdef CONFIG_KASAN +#if defined(CONFIG_KASAN) && CONFIG_THREAD_SHIFT < 15 #define MIN_THREAD_SHIFT (CONFIG_THREAD_SHIFT + 1) #else #define MIN_THREAD_SHIFT CONFIG_THREAD_SHIFT