Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp699921rwr; Thu, 27 Apr 2023 07:08:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5WMqtbWccwp41zcx2gHWxxIEeavW3DZj5v4VQ7TjyeA2Z/2RAfNQh5YHkmXBhLzzHhuKzW X-Received: by 2002:a05:6a00:22cb:b0:63b:5257:6837 with SMTP id f11-20020a056a0022cb00b0063b52576837mr2270190pfj.1.1682604492603; Thu, 27 Apr 2023 07:08:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682604492; cv=none; d=google.com; s=arc-20160816; b=KLIpExU4cnbfGDDM9negSd9kt5ZjonffxYrJWpuVg/5HETqQ/8N+Fs1khGRVdsPWD8 RvaWTTlmLmlB9P7emCKRy/X53NoiqVXL1+9FpKoBhGPssGopHML+hJ4JZr83eUl68Z36 TcB2awUtNU9OJkGjMs1oF+eV5vQRxJYYavHFj/0vx5vEwsVs92icWGEQi+kfqC2+sW4u C0OvdUdrXOiAs/QaCcwRGQO8EwhQG/1jSmdIX1I4IPNvy/NwxhBxabN3eETSfzJEqQ+h pU9ltHEmz4BgoBONGz+dZpkGgNF7JqNlaEkCeroSLqZMDQABrerkMvYI8mgnhZ9/XAjb cPHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=9/4L3hOVGiJ1LyeLGTYoDeO4XIcCkzX13drT2+kZrLo=; b=PKUH2tFd+NPlSS5iUAV8SX0Whg7u/pv/r4qGA1nVor0bIQ73yVANX6MDSENQNgQqks 5LsTiGI+UaYVpUNvg8ZvMJG+9kivGybqnUpDCy8aA44jhBFUv7wbdINtea6wesQo+2Th Xm16Xj4jqZSBBCD3eqsGy96Tt3hwpKQGudGiscIR0cJJ/8P2mecdUohGuelLfTBcFSA2 bABegdFmDSeIMReNo2s67QyyLxUUaRq2Y9J8ddMn4ETgmyiu+t6ovLTRv5IGLqM3BjAk i41ZG3fVPt+4uGf/5l3ae3eE23JNGxkd47fO/yEiS3HYJ16QYa7FevZcdCfgOpbX55IV m5Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LHnNQp3k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u130-20020a627988000000b006303ebae0eesi19199761pfc.378.2023.04.27.07.07.29; Thu, 27 Apr 2023 07:08:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LHnNQp3k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243459AbjD0OCC (ORCPT + 99 others); Thu, 27 Apr 2023 10:02:02 -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-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 = PTR_ALIGN(stack, sizeof(long)); for ( ; stack; stack = PTR_ALIGN(stack_info.next_sp, sizeof(long))) { const char *stack_name; -- 2.25.1.362.g51ebf55