Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp387881pxj; Thu, 20 May 2021 11:37:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwizHJMX3K0ZtszaYkDwN58oegQQG5ltw+b5IEGlr5bxyqUFIvWkri/z1+hOwtmt0uFobHU X-Received: by 2002:a5d:8d87:: with SMTP id b7mr6087155ioj.46.1621535840843; Thu, 20 May 2021 11:37:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621535840; cv=none; d=google.com; s=arc-20160816; b=NYLy85QX2f3bKlmmoG3LHftTN9ILXXkfz4MY8acAMGay16AjBIluHe5IBwdQYFC+tn 6XEsb4AVyCw4zn41sBf5ij9kqZCXQ84XUurM4G3BaQj240247FXKDG/X2Bq1s5D/JPqe YxFY6zI3m4s6GnjKtBNV95Fia/HeyBPSBGPjAYGlMTYRBxZ8U1n9EUiaLCZKCo0Rd+/p TsCVt/YfM1VL8VdlhFiXe4y90rx/wa5x0FDhwgwOsbBDWCxkirV8oi7mzbWYQqB3l74P sFSYOykBw5qdFDZE0xf/JA38NwgpVw77e7QvLbqQV6Fg/8Vh4dnWA9VKAlZDA4LQnJPw wILA== 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=K0JBY3qXBJHPZu60veghUrI8PCLI22bBgGu3EX7MU68=; b=n2UvY62sgjz1gOFmddI24TguPRq1VXuSHVJz+XlOPjKxHjdqdNO5W9CcaF2BpB+bDq YxejYze2gzPm8zJ3mURd15OSZPD8vIgPiPQazL+zjm5eDlsz1jlDQ20cP06Th6xRHsxa K9cUCWmFk4jglDKjsO8hOjhVzvPdLRrJ5iQko77eIoYDEzTwDhYV6fRw8brl92m1nA9i 1ZKOtxrDad/m0/xgvnCRvu2CI/zmz8BbsWi4rhzXSq+GyfmtIkhVWMi+N71eRd4IwRe6 lgtDrrUTGYVbxshnfKM81lrKQN+8F8a97I6u7N4HhQRLChDcogtMa7uLrpPjjUqmq6KL Bk7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MINH2yVA; 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 s21si3390322jaj.47.2021.05.20.11.37.07; Thu, 20 May 2021 11:37:20 -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=MINH2yVA; 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 S236870AbhETKYk (ORCPT + 99 others); Thu, 20 May 2021 06:24:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:48888 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236033AbhETKOJ (ORCPT ); Thu, 20 May 2021 06:14:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B342A61982; Thu, 20 May 2021 09:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503867; bh=tBJpSCR/JXQD4SNlixszfDXQT0C1jlLrFAXRes16CAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MINH2yVAx1ZkvwU8pbPTMmLBvpeNDUeXRJn48UtSebjuGqf1SVPPhYsciwZFrjjgN +b4FIJHxapEJ7zavi8G9gSvdmTG5ZI34eTse9xyMj3Bq8cPfFovk9EbfGrDZ5axQrk 4jnwW62AAStgtX+6GE/7fAaCTGJqfuOi8Ly9RsxY= 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.19 416/425] lib: stackdepot: turn depot_lock spinlock to raw_spinlock Date: Thu, 20 May 2021 11:23:05 +0200 Message-Id: <20210520092145.080834105@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 3376a3291186..d0f1b7d0ce2e 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) { @@ -266,7 +266,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) { @@ -290,7 +290,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