Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2616955lqb; Tue, 28 May 2024 05:47:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXhrRiL/HrU1AwmwfkW2sr1dEstMV/jX+MxKrWa4tLKRHnNqlEf0pbjY0ZuAKF3AdkbSOMeIBzEfjVi8u67ukPdhWzSu3pSjviVvlt0yA== X-Google-Smtp-Source: AGHT+IHQ3M5M6rN7sQvsvNmnsQLDb8N7dKwVx4Ocpicnc0IDAMZuerTo4L5hV8lV7Pu98LZbxg3U X-Received: by 2002:a05:6a00:410f:b0:6f3:ec06:4a20 with SMTP id d2e1a72fcca58-6f8f3186e75mr18174988b3a.16.1716900479209; Tue, 28 May 2024 05:47:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716900479; cv=pass; d=google.com; s=arc-20160816; b=tFLXuzh7bmLPeDurpwWFowzTnhjtmDhY1xVOGKJMku+rpWB+DJMb1SbGiVC51qmn1P gr0vY/46mTp/PvXV/4JTBnGx6ri9tuLzB7MPgZoBBoBszfBsqndMTnww2gyUytTVIQBJ 20U+MITwfG3vFEyKbUYdWU88SeevZQNles8/2i2C2sgsGc6iLMvIK/YMbfxgjrY8773M wzFpLq5WEyWDzqa/8fXQ3LbgM4WpXRHcKfvsgqGoP023z4MgdxRdopWDP6SE+aiWha9R PbqN7XOSHASSUcm2q4380VR9UFNd4/PWZkUX+2ZnI1vfC5R7dAzNzqbNOSyy9PGZeQa+ LRig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Xr0uc+573fKShcj/y7NVJYwsoBDBFjAO8/rYVJ9ofSg=; fh=WpOVNPgkY9mubNcuuQ0SzngYcN2YRSCv33rJ80OlhTA=; b=JjYgY7k92cST1xTVuKuAOhZhazgZW14fxwYrEb+NAyl5QrFgc7RZB/iCSa0hvx22IC 5AFV1K8M8g8mI5hWUDj/MZOfMtSyAbQTg8ZfUgMB4ULCz6wa4Z3LtobRTLenq/y2QUSr g5PnOWYqfJ/U2lw0w1Y972cpd6isnGqa+m0kPSL2VedVfvMnn7wlDBYkDW5SoOo9EyCh q2emzeU22FBGoVvLd/B9WaOnFO93ZE8SsRy+oBaDFOgiQ8vuJmuyDOPqD40s/3QB8egI zvedLjh2T66h6ucENivK4viFukhuItn8DVhYkW4tWhe7fYprvmkQls6nvfZa3dhALuCj 4Yww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OiGbJC2m; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-192329-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192329-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-682ca7bb1b9si7793569a12.244.2024.05.28.05.47.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 05:47:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192329-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OiGbJC2m; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-192329-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192329-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C876B284298 for ; Tue, 28 May 2024 12:47:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1507216D4F2; Tue, 28 May 2024 12:47:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="OiGbJC2m" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38D497316E for ; Tue, 28 May 2024 12:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716900474; cv=none; b=EXlrroNVTAcK9rPspoF44noYwu1LDha2GyAuWOanio8DKr+Zx406quTIM1teY470nQXuTuRepSXtIpl46qHIb/P/i5gXksgdzTcbb7QtUjMDtX1+dX5hqnFjB6Y7ESYFsGsEAiavpWDavdy7b8zJDoHcUZuWl4JRTetT01XyMGY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716900474; c=relaxed/simple; bh=RCCujihDmtcxfjM967k0N/kduY9TNazk02dOqNj4JR0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PbDYa4jz3sr+joklbc2cD97wD8P7y+3NagVLd7y2YGpCWZIaFhpzqoLbnWOK9v6co0mgjoFdjDb8RSiQRb+CYTNWCKVOm7DqOXmSxsJ9Fh3otBxopoj7QltuOGQ/h/4l4lgU1PsPMBtNlhDJeM3NEl33MT5pCYDDoaG7K84hadU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=OiGbJC2m; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3F82C3277B; Tue, 28 May 2024 12:47:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716900473; bh=RCCujihDmtcxfjM967k0N/kduY9TNazk02dOqNj4JR0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OiGbJC2mJADhEr+9eReKQ7DAtNBW5dm1ap89TAIA6JAosLCZ/JUg3PXdUhZDINO55 V3MLrvgjtZnBcBsqKU0EdXbPgI7GU7S/lfEbMdk1ruWqeRUf1fL7OtupG1kHdAFL5K 8d+b2cBcqKHY8muSnidgffTtMe0lrWDrDzV0Lr4Q= Date: Tue, 28 May 2024 14:47:57 +0200 From: Greg KH To: Tony W Wang-oc Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, jpoimboe@kernel.org, vlovejoy@redhat.com, oleg@redhat.com, linux-kernel@vger.kernel.org, CobeChen@zhaoxin.com, TimGuo@zhaoxin.com, LeoLiu-oc@zhaoxin.com Subject: Re: [PATCH] linux-4.19.y/printk: Avoid logbuf_lock deadlock in oops_end() Message-ID: <2024052839-tipped-fragility-2799@gregkh> References: <20240528101957.7277-1-TonyWWang-oc@zhaoxin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240528101957.7277-1-TonyWWang-oc@zhaoxin.com> On Tue, May 28, 2024 at 06:19:57PM +0800, Tony W Wang-oc wrote: > A CPU executing vprintk_emit might be interrupted by #PF exception, > this may leads to logbuf_lock deadlock: > > CPU x: CPU x: > ---- ---- > vprintk_emit() > logbuf_lock_irqsave() > printk_safe_enter_irqsave() > A: raw_spin_lock(&logbuf_lock) > vprintk_store() #PF > do_page_fault > ... > oops_end > bust_spinlocks(0) > console_unlock() > ... > printk_safe_enter_irqsave() > B: raw_spin_lock(&logbuf_lock) > > logbuf_lock is taken at A and the deadlock happends at B. > > Pass 1 to bust_spinlocks() in the oops_end() to avoid this deadlock. > > Signed-off-by: Tony W Wang-oc > --- > arch/x86/kernel/dumpstack.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c > index 7e698c45760c..b4c145ee9536 100644 > --- a/arch/x86/kernel/dumpstack.c > +++ b/arch/x86/kernel/dumpstack.c > @@ -336,7 +336,7 @@ void oops_end(unsigned long flags, struct pt_regs *regs, int signr) > if (regs && kexec_should_crash(current)) > crash_kexec(regs); > > - bust_spinlocks(0); > + bust_spinlocks(1); > die_owner = -1; > add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE); > die_nest_count--; > -- > 2.25.1 > This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.