From nobody Thu Feb 12 04:48:17 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13040C77B73 for ; Thu, 27 Apr 2023 14:02:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243536AbjD0OCD (ORCPT ); Thu, 27 Apr 2023 10:02:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243218AbjD0OCB (ORCPT ); Thu, 27 Apr 2023 10:02:01 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75F1F44A9 for ; Thu, 27 Apr 2023 07:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682604073; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=9/4L3hOVGiJ1LyeLGTYoDeO4XIcCkzX13drT2+kZrLo=; b=LHnNQp3k1xcylHz4wGYyKbG/md0Jejo2YFz2ExmYmJ49dV4p1wj2HYXkctZv4yJHJbVB2M EGWbPC72Kzq1XB68Sqk8ipS4zDNTRzUSop9Ol6Vl5fQu2XuQ5GJRvL7KTZWrGpz1T/2WBP NN6jQ1hRLyEEEhKzKy6NNugwZmTQFbA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-557-vSq2VwLpMXiHJ7DzToE-FA-1; Thu, 27 Apr 2023 10:01:10 -0400 X-MC-Unique: vSq2VwLpMXiHJ7DzToE-FA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7197E38149C6; Thu, 27 Apr 2023 14:01:09 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.226.140]) by smtp.corp.redhat.com (Postfix) with SMTP id 198CD14152F6; Thu, 27 Apr 2023 14:01:06 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 27 Apr 2023 16:00:58 +0200 (CEST) Date: Thu, 27 Apr 2023 16:00:54 +0200 From: Oleg Nesterov To: Josh Poimboeuf , Peter Zijlstra , Thomas Gleixner Cc: Vernon Lovejoy , linux-kernel@vger.kernel.org Subject: [PATCH] x86/show_trace_log_lvl: ensure stack pointer is aligned, again Message-ID: <20230427140054.GA17800@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vernon Lovejoy The commit e335bb51cc15 ("x86/unwind: Ensure stack pointer is aligned") tried to align the stack pointer in show_trace_log_lvl(), otherwise the "stack < stack_info.end" check can't guarantee that the last read does not go past the end of the stack. However, we have the same problem with the initial value of the stack pointer, it can also be unaligned. So without this patch this trivial kernel module #include static int init(void) { asm volatile("sub $0x4,%rsp"); dump_stack(); asm volatile("add $0x4,%rsp"); return -EAGAIN; } module_init(init); MODULE_LICENSE("GPL"); crashes the kernel. Fixes: e335bb51cc15 ("x86/unwind: Ensure stack pointer is aligned") Signed-off-by: Vernon Lovejoy Signed-off-by: Oleg Nesterov --- arch/x86/kernel/dumpstack.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index 0bf6779187dd..71ab445a29c3 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c @@ -214,6 +214,7 @@ static void show_trace_log_lvl(struct task_struct *task= , struct pt_regs *regs, * - hardirq stack * - entry stack */ + stack =3D PTR_ALIGN(stack, sizeof(long)); for ( ; stack; stack =3D PTR_ALIGN(stack_info.next_sp, sizeof(long))) { const char *stack_name; =20 --=20 2.25.1.362.g51ebf55