Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.231 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796178716; b=NnFRumHnRWmXZqVvgpj0CjNXxAfK9gprsXWxJ3e+nn7S6QfAxiemIXNOp23y3tWNE0nG /RlqALtz/6FZeTrCnOFeNLFA5HCZrPCLWEHm8ae7oYChBMktRE70uIgoEuq3MpVAGVJXi YyxxfcN1ddE2bVNNV3rQDCG6O7AiDUkFHPbREnbrKdG0dEOalidMKAuwOfnZIYMgMBFo4 97LAv9bH+xyE5Q98UBBMvb7jPo5tloNV1Yw4CsM7jbVnUhPt1s8YviyVvAwVRThaNkslx 8dZ9vuLejmIBJGZ70HagKSf2MXPyDEeCZlPbrn1kDqB56P5vQ8cMcLL21kb5cAEEu5A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796178716; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=aaIkrYrnFcFMoGz2ZYEqrmC7k+z+LdswUZZ6B9MFU+Q=; b=dv3/GSNU33b8x9MuMww+RSryAyrY6WjGgqQMZ01zKNw6Li3KLFZxFaTRjXt4XEJw+bJD Teo/k7B6fe8FHJCo9cyQBbPMXw4o0MmcmGlQOFxi3POdkG9c09YxcoZTmfDBpjfLLopva F/1XYYhIjNPY568zXKAsWakqjHr2pt/jt+KXF2AJ4ki3RsJ6dKhHnWI8r85eqrr4DQqY2 wR837wRREHcGhFL6U2UIMudmrWy8L0Uj+9ieO9F9/3cCrytfQCIwyYl3Kg/QLj6Rr173m GTnIfKWRfAqd5ItJyM/b25vxTWjBDFARU3nnnDDlvSc4Xd6WqlkV0uFZdeZHAPp077Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=YYIt5RCC; arc=none smtp.remote-ip=95.215.58.231 Received: from mta1.migadu.com (out-231.mta1.migadu.com [95.215.58.231]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80A70606A681 for ; Wed, 2 Dec 2026 02:31:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 80A70606A681 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=YYIt5RCC X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=ex+lPX5ZFqIAxqIcvZ4sbHjouDICvwpdsqq+NrIWjEM=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796178711; v=1; x=1796783511; b=YYIt5RCCZeEs4kOX5bIN98Xzj4b85LKb9KBFk6b+fLDc4Y2C6AXHLi2Ws6Vfm+UhphTZMYmg Bpuxbcu972jfuko/x6m0oqZOGMXsRQwZ0TNPJaXby0SDn6EQtup3M70wFNKt/TfhHxrVqQXjFUl anz2RR9CkJ95kZti50jsbYEY= X-Envelope-To: linux-kernel@vger.kernel.org Received: by mta11.migadu.com with ESMTPS id 62069be9d2853451; Wed, 02 Dec 2026 02:31:51 +0000 X-Mizu-Trace-ID: 62069be9d2853451 X-Migadu-Flow: FLOW_OUT Date: Wed, 2 Dec 2026 10:31:47 +0800 From: Baoquan He To: "Uladzislau Rezki (Sony)" Cc: linux-mm@kvack.org, Andrew Morton , LKML , "David Hildenbrand (Arm)" Subject: Re: [PATCH v2] mm/vmalloc: Bail out if in softirq context Message-ID: References: <20261201173727.90526-1-urezki@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261201173727.90526-1-urezki@gmail.com> On 12/01/26 at 06:37pm, Uladzislau Rezki (Sony) wrote: > vmalloc() is not allowed to be invoked from the NMI, > hard-irq and softirq contexts because doing so may > deadlock on internal locks. > > Commit 04aa71da5f35 ("mm/vmalloc: do not trigger BUG() > on BH disabled context") replaced the deprecated in_interrupt() > macro with explicit in_nmi() and in_hardirq() checks, but > unintentionally dropped the softirq context check. > > Example: > > > vzalloc() in a task > spin_lock(&vn->busy.lock) > <------ Hard irq > irq_exit() > process softirq on the same CPU > vmalloc() > spin_lock(&vn->busy.lock) > spins forever > > > Restore the original context restriction including BH-disabled > task context. > > Use WARN_ON_ONCE() and return NULL instead of BUG_ON(), so > invalid callers are reported without triggering a BUG. > > Cc: David Hildenbrand (Arm) > Fixes: 04aa71da5f35 ("mm/vmalloc: do not trigger BUG() on BH disabled context") > Signed-off-by: Uladzislau Rezki (Sony) > --- > mm/vmalloc.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index a4c22c569b1d..fe5bdb4fde52 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -3258,7 +3258,12 @@ struct vm_struct *__get_vm_area_node(unsigned long size, > struct vm_struct *area; > unsigned long requested_size = size; > > - BUG_ON(in_nmi() || in_hardirq()); > + /* > + * Reject interrupt contexts, including BH-disabled task context. > + */ > + if (WARN_ON_ONCE(in_nmi() || in_hardirq() || softirq_count())) > + return NULL; Do we need bail out for irqs_disabled() case? I saw kvmalloc() made this: commit 693c2e04e3f1 ("mm: kvmalloc: Bail if called with soft or hard IRQs disabled") > + > size = ALIGN(size, 1ul << shift); > if (unlikely(!size)) > return NULL; > -- > 2.47.3 >