Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp37161pxj; Thu, 20 May 2021 04:03:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwAGAjDxWaBS8VjBtWhNEFOA4NzWcU8zSWaG9JS6q3ujS6CQ+BoKWixV2fbgrIFQd29hsI X-Received: by 2002:a17:906:161b:: with SMTP id m27mr4047547ejd.89.1621508611436; Thu, 20 May 2021 04:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621508611; cv=none; d=google.com; s=arc-20160816; b=aGTGpfh6FM1wWJxDufL5ZdZlmS2ESfv9ImPE6B7H3m6ExdcnWh8/S2eztMggol4Rx1 PwcqbriRW2T+4joXeqgWZGVBN9+mBDW0V5ZYy9NhoYmWnDVpsYENaysZjppTo66IaucO 2j6EjAqfixejqTl8+0gNb8ddf+vusrurr/EEjzxfQ9ID9Yw3nqpIpBaRozrITXFClJgR TuduFfCQ4xDUSHy0oyfr2lWJqwklV8+5yTyGnd82YTUOUy+OAlXe9MYwSfj2dB15G62y Vt/jK2L7NqXKAEdgSc/CeubVPahQoImkl2NnT1/++6SkO/sNZwCAXoHOWT+iKFIVGmcw SJ6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DGuLUKvTReYFmKhagbd/O4NFHEyQnx0Nvq3+8I91BAI=; b=S+N/q30KQJTEa1R8dCQ4kcwqbeYAYvtMlfug2lpEit5+zuWfk3bQtdZgv+MV1Q/lPK gHMg3uFGIx4jVJSNRajD2K2iOq+d/oSUWRf5gKhkcQf0ncqw8p7DEDcm+V55Y5FNETPG 6X7EMwqln+70YNPsrvmHnYUYNNHGhvX5h1mFPlmbnqtFTDtNmf4xY+6MAYWdHh2HeJDr wJeVjyazLYxCiR0EsGfSyX1n8DTxHlPleQIX5BscpZFxX2VQNIxmdJSW1TRgDXWPaD2a rhOX0SmtkAkVHids+1Y8YyXJg/0lGBzlLAXo4XGfJPYYTCSCPOJFAapz5gAxLH0lPrwy KtGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gbkqpMnH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si2789704eji.59.2021.05.20.04.03.05; Thu, 20 May 2021 04:03:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gbkqpMnH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237845AbhETLCT (ORCPT + 99 others); Thu, 20 May 2021 07:02:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:44702 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237855AbhETKnt (ORCPT ); Thu, 20 May 2021 06:43:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6A74D61C91; Thu, 20 May 2021 09:56:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504618; bh=HoXhbdPkempNh0y+GrVdzvcto/dJ8wWErjeD512HHMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gbkqpMnHYM0xs1GyPUDrpz/RG0V3Piiv0eblO2eEfaR1V/2/hQcGnUp4+0sIhCljF ltgZpE/YKn6VjR38KIR5a8yFTFueCkCqneVe46EQwO/Iq9OSNPz+xfgcAXkxA2zOCb tKMiCaREc90IJOKathzTt3sRFxBU/Z7V1pR+0cbw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zqiang , Andrew Halaney , Alexander Potapenko , "Gustavo A. R. Silva" , Vijayanand Jitta , Vinayak Menon , Yogesh Lal , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 318/323] lib: stackdepot: turn depot_lock spinlock to raw_spinlock Date: Thu, 20 May 2021 11:23:30 +0200 Message-Id: <20210520092131.145691824@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zqiang [ Upstream commit 78564b9434878d686c5f88c4488b20cccbcc42bc ] In RT system, the spin_lock will be replaced by sleepable rt_mutex lock, in __call_rcu(), disable interrupts before calling kasan_record_aux_stack(), will trigger this calltrace: BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:951 in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 19, name: pgdatinit0 Call Trace: ___might_sleep.cold+0x1b2/0x1f1 rt_spin_lock+0x3b/0xb0 stack_depot_save+0x1b9/0x440 kasan_save_stack+0x32/0x40 kasan_record_aux_stack+0xa5/0xb0 __call_rcu+0x117/0x880 __exit_signal+0xafb/0x1180 release_task+0x1d6/0x480 exit_notify+0x303/0x750 do_exit+0x678/0xcf0 kthread+0x364/0x4f0 ret_from_fork+0x22/0x30 Replace spinlock with raw_spinlock. Link: https://lkml.kernel.org/r/20210329084009.27013-1-qiang.zhang@windriver.com Signed-off-by: Zqiang Reported-by: Andrew Halaney Cc: Alexander Potapenko Cc: Gustavo A. R. Silva Cc: Vijayanand Jitta Cc: Vinayak Menon Cc: Yogesh Lal Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- lib/stackdepot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 759ff419fe61..c519aa07d2e9 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -78,7 +78,7 @@ static void *stack_slabs[STACK_ALLOC_MAX_SLABS]; static int depot_index; static int next_slab_inited; static size_t depot_offset; -static DEFINE_SPINLOCK(depot_lock); +static DEFINE_RAW_SPINLOCK(depot_lock); static bool init_stack_slab(void **prealloc) { @@ -253,7 +253,7 @@ depot_stack_handle_t depot_save_stack(struct stack_trace *trace, prealloc = page_address(page); } - spin_lock_irqsave(&depot_lock, flags); + raw_spin_lock_irqsave(&depot_lock, flags); found = find_stack(*bucket, trace->entries, trace->nr_entries, hash); if (!found) { @@ -277,7 +277,7 @@ depot_stack_handle_t depot_save_stack(struct stack_trace *trace, WARN_ON(!init_stack_slab(&prealloc)); } - spin_unlock_irqrestore(&depot_lock, flags); + raw_spin_unlock_irqrestore(&depot_lock, flags); exit: if (prealloc) { /* Nobody used this memory, ok to free it. */ -- 2.30.2