Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2204096pxj; Thu, 20 May 2021 02:29:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzy3oxd+aCo7u7zaC2hWCZBvc1JL+Fmq9/Z6gm+YLUMqe3Hqu/zsHc6ZvPf+RmfeKDw7j0i X-Received: by 2002:a17:906:6b92:: with SMTP id l18mr3791758ejr.367.1621502996109; Thu, 20 May 2021 02:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621502996; cv=none; d=google.com; s=arc-20160816; b=tIe2jTSKCFS/LW7hH7g7Xn8xlqMNtJjZjktPVK0dPjLk1n15G8yAkH9YgZ8urK9hat 7Cb+oDVlDPq8dTTM90o69zYzDKh2naXPRF7azDEoUn0y9Rz7hjq4n9KOR96OEv2ER9yw q6xB9fDWUfGhfTbEwuNGHVO/iY3oiEIgdwtJNLUcPUe+f8IZGqRAcuABeF4ylDMw7nKx VRliKxs9RD4anbzYXy4B45IAA1pyTbK260EDwiOVmIDRGxTQFQNmrE3r1yPa4pFMGtiB keEckp1xE8H02RosX7db38HUMlnk1iud4byLE/RSEuKtGXQKSa6OW0tHH4rOd8wz4L/o B6GA== 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=RfyHdTds4pi2j4veyI3nrIOpR1LniMoKRoZzGZiTDMM=; b=i6iC97eODrZtpUNRmswt/EjaJuDVRlMBSXenPmpqg4wWQf+sS4vafpp+VIa3Ii8K4h 8Ko0l4/dcWsmF+T7Nons4gurtEOUw1QV0yvbHnUcyFG3Y3HG9ztzWudA1lU7h4ALl2v1 WEu0w1KhfLuEIMFG5h7XuJXL+ziPDv8fKwZ99IPn8gmhqIhf5hDnN9eCWSqueI8hW+0W 3pURoXbV7lpCd1rPJYsju59t3TdYxnDoHJRT5xZsu6vDWEk4mVA1gM+SNXN7roHi+1WF /JZilIfiSHmqdDvbTDlAmtNUrHFfmri5WWR/8kB2O1aSfwOeloVktBPzlvBOTBkHMMW/ We8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sOAI0Ojo; 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 s11si2081984ejz.348.2021.05.20.02.29.30; Thu, 20 May 2021 02:29:56 -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=sOAI0Ojo; 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 S231556AbhETJ2b (ORCPT + 99 others); Thu, 20 May 2021 05:28:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:54548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231773AbhETJ11 (ORCPT ); Thu, 20 May 2021 05:27:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EC699613B5; Thu, 20 May 2021 09:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621502766; bh=xI/vWqy5mhZi8yPITwZQzTyszkttjZqSS65GOhdovWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sOAI0OjoMUAyxB//AQ73U0toTPTfDL8UbUJSoyAYASoOVdbqNSGjCMwAky5SNqZQe v1ohPtRO9r5mDMb58docynULa6xtT64QdQuWudTA7yN7yK3CgcaKyV/fNKl3V+sP67 UnoPVJUL/8OzYpKc95yJl+lvr5lw13Qxl3TR8dII= 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 5.12 40/45] lib: stackdepot: turn depot_lock spinlock to raw_spinlock Date: Thu, 20 May 2021 11:22:28 +0200 Message-Id: <20210520092054.820707699@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092053.516042993@linuxfoundation.org> References: <20210520092053.516042993@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 49f67a0c6e5d..df9179f4f441 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -71,7 +71,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) { @@ -305,7 +305,7 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries, prealloc = page_address(page); } - spin_lock_irqsave(&depot_lock, flags); + raw_spin_lock_irqsave(&depot_lock, flags); found = find_stack(*bucket, entries, nr_entries, hash); if (!found) { @@ -329,7 +329,7 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries, 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