From patchwork Fri Feb 4 17:57:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12735413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A56E4C433EF for ; Fri, 4 Feb 2022 17:57:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 393C56B007D; Fri, 4 Feb 2022 12:57:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 31C8C6B007E; Fri, 4 Feb 2022 12:57:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E3D26B0080; Fri, 4 Feb 2022 12:57:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0070.hostedemail.com [216.40.44.70]) by kanga.kvack.org (Postfix) with ESMTP id 101266B007D for ; Fri, 4 Feb 2022 12:57:10 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C764C5B5C6 for ; Fri, 4 Feb 2022 17:57:09 +0000 (UTC) X-FDA: 79105853778.15.9E2F09D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id 725451A0006 for ; Fri, 4 Feb 2022 17:57:09 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BD18861B48; Fri, 4 Feb 2022 17:57:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA326C340E9; Fri, 4 Feb 2022 17:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1643997428; bh=D1pLLIbAAt2KQpwLnzj66vfNlI8SvQaQIa3Kfuug6OQ=; h=Date:To:From:In-Reply-To:Subject:From; b=bbYy4YgyVo9Y8dwGWdyZQuOjT/0svZfvuTTJRLbVT6L72QntPieBiJ6vajDaUFQdE KAOoLZsvsUiytCnmbfEAQpQz04JrEc80MQ1rwAIrj8adK4XSKeCImPi+jV0uC7p7u3 +xi2OecCJ12p9SbjnwQ8bhjYPI8Ag2xwenPjEXKs= Received: by hp1 (sSMTP sendmail emulation); Fri, 04 Feb 2022 09:57:06 -0800 Date: Fri, 04 Feb 2022 09:57:06 -0800 To: zealci@zte.com.cn,vvs@virtuozzo.com,unixbhaskar@gmail.com,stable@vger.kernel.org,shakeelb@google.com,rdunlap@infradead.org,manfred@colorfullife.com,dbueso@suse.de,cgel.zte@gmail.com,arnd@arndb.de,chi.minghao@zte.com.cn,akpm@linux-foundation.org,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220203204836.88dcebe504f440686cc63a60@linux-foundation.org> Subject: [patch 07/10] ipc/sem: do not sleep with a spin lock held Message-Id: <20220204175706.AA326C340E9@smtp.kernel.org> X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 725451A0006 X-Stat-Signature: mpg86pj9ppe544anb1hz9amwphntftnm Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=bbYy4Ygy; dmarc=none; spf=pass (imf19.hostedemail.com: domain of akpm@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@kernel.org X-Rspam-User: nil X-HE-Tag: 1643997429-200810 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Minghao Chi Subject: ipc/sem: do not sleep with a spin lock held We can't call kvfree() with a spin lock held, so defer it. Link: https://lkml.kernel.org/r/20211223031207.556189-1-chi.minghao@zte.com.cn Fixes: fc37a3b8b438 ("[PATCH] ipc sem: use kvmalloc for sem_undo allocation") Reported-by: Zeal Robot Signed-off-by: Minghao Chi Reviewed-by: Shakeel Butt Reviewed-by: Manfred Spraul Cc: Arnd Bergmann Cc: Yang Guang Cc: Davidlohr Bueso Cc: Randy Dunlap Cc: Bhaskar Chowdhury Cc: Vasily Averin Cc: Signed-off-by: Andrew Morton --- ipc/sem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/ipc/sem.c~ipc-sem-do-not-sleep-with-a-spin-lock-held +++ a/ipc/sem.c @@ -1964,6 +1964,7 @@ static struct sem_undo *find_alloc_undo( */ un = lookup_undo(ulp, semid); if (un) { + spin_unlock(&ulp->lock); kvfree(new); goto success; } @@ -1976,9 +1977,8 @@ static struct sem_undo *find_alloc_undo( ipc_assert_locked_object(&sma->sem_perm); list_add(&new->list_id, &sma->list_id); un = new; - -success: spin_unlock(&ulp->lock); +success: sem_unlock(sma, -1); out: return un;