From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11F9348A2D1 for ; Wed, 19 Aug 2026 17:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787160320; cv=none; b=e8Hiecxp+qXdtcxhfS3AqpdELxXvGX7H4Nixlj6q9pWDGhlf+/KltAd5Llj2g3F5H0IGj/qXy+/CDERyBjJFfftVHvq95ys56i60f7DbL/K2qpn2xfK5Oled7QaBbhHMKJBIJAH4GS1GkvlcQXAwoBGiNoem96sCQoLuPCXhuoU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787160320; c=relaxed/simple; bh=a5ltglB0UYvVP8aZZDalxtmFnWPej1Q5IpmVlwN/WrQ=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=P7kkAfO8A2ZSuWEzVAfZA2tb19yqFWLdQJyyssK7EArHx8T3l8IriuVPmDcpIkHPgWqIZairK5BjG3TJNj1VBu2bnRduQcV7pMZ071ALARFGuXNS7VYNk15fDhavUoLsjysleXGuT/8Veoa9K+/lB23cbz1535JbzJR5Yl1GzoQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com; spf=pass smtp.mailfrom=etsalapatis.com; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b=ehF1QlWs; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b="ehF1QlWs" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-381c51fde6bso1638038a91.2 for ; Wed, 19 Aug 2026 10:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsalapatis-com.20251104.gappssmtp.com; s=20251104; t=1787160317; x=1787765117; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=sRvfkPMHEHTPAPhUlGsquXh/ui1bgWvByjxen4MjHTE=; b=ehF1QlWsBr0+nc0iWThQcSPoXYSon0DFulcF+jgHqpMwtqkQlBTDyuYkBqp+hrsPDa ZkNMLX7QuI8FhQDG6Pv0zFXo19j5rlneHDar9GXB2rKs7l1uTNpLaDcAk5fhEEEHW3Oz DsJ3t0CUEVcZgFThVbEgbnwV29WzPPxZBcv1dH+a59Mzhard7k405tbLgRmhrHWPL4Th TxYYwTzjdXIhYtlKvLRgXU21Uj9KEKry/ySJ/tp2xLR1QyohSvFQ101QUn1WImsJpCMb tU7wcJ4TIEo7xw8EZnR8TeuQCwO6t3JFsP0mjkkx3VZ3FGcx8xbxuThrQHkEtGphM0Rw ULmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787160317; x=1787765117; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=sRvfkPMHEHTPAPhUlGsquXh/ui1bgWvByjxen4MjHTE=; b=aU3D+5hFyWMQA2oAZ4xuSArRnJQIquucI0WsVew5MC9NMDlxhjMnC4gRkzIVTuWUUQ IU2FNw/oZHyUP1q/nCtrOTOQiohsVU/oYC4ylfbvqI1z29Uawhj/PTzZxqEtUQNWMEsm mmWySbxtfsq94AZVVG1/Myh8AagGTYnudBaekSOaQ8PU6cm+g3SbHFw+ulLn7U2uQA66 ocj7Oycygs4QMPyGI5fwGl2YaPorygcnO2eCu/nh7YdxKAsGbTskNe3azuIHkj4KLyTI kPLtgLeOuM/XrFHsoEv+KYmCCPqCOqo+EGyS0P0pICokBE43NyyXsUKXFdPMHdGvGyIp 2CbQ== X-Gm-Message-State: AFuF++n045mOLKHKdECVEb04iBP7z6oFrQYqORmc4h4UnZRo0sFQG5Mp IQIxTKIvdFxLLpJBNZmL4MVlApAs0kfYDOzxWvtUfi6tqdrsYCX8z8ynQgcWM+4Vano= X-Gm-Gg: AR+sD11HLQIWBzvL6Ai9U0hDvkWNL2Kxk4ucPI6C9qMRfTSDBovEqZA9FX1Amgchr4A Zjc2zCOprOQy5jIiXbBZ6TGqGliR7fsomV2BgKAcstBZmFJJiCX1Bj9gEeQFyOEw/jqpXzzm0P0 eI5QgErrGN1/X+c1EqItJDLDX3GFILtgNqeNRPv2O+gujr+DY6YLp4qoCMebCKlSmd2vavuCKtg tSIeDwffVGLQqG8OLu7pg6fXST7jChAl69qWkv90NXTtHUlL0kSAh4l8lN1ZmCHURJjY0Ig0UhR NOn/wDhMJQ1io7xR33BJuwsHWEFyk6KMVuEm73TpaSjSOLa6TJmUvVdYmPr7kPBzM3j452qdnTD x7lnjIMHCitGyYx1HAJCkC6pcBwdprcc/Vbjeae/O7BI4oSfFZ5UpgNOyGOwSug/+uN4OFO8qsA AEwI/l1KmQY3HlxAZHjblSilZ3q7lzmOQgiw0Epmq2dIbCa2Rg5mrsdz42llkujPwuWOQuKJ4x2 1rJ+/Mx7Lir6kLtHg== X-Received: by 2002:a17:90b:3945:b0:37f:eafd:3505 with SMTP id 98e67ed59e1d1-39580eafaa7mr12619312a91.6.1787160316949; Wed, 19 Aug 2026 10:25:16 -0700 (PDT) Received: from localhost (107-190-31-17.cpe.teksavvy.com. [107.190.31.17]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3957fb60a2bsm3451585a91.17.2026.08.19.10.25.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 19 Aug 2026 10:25:16 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 19 Aug 2026 13:25:15 -0400 Message-Id: Cc: , "Alexei Starovoitov" , "Daniel Borkmann" , "Andrii Nakryiko" , "Eduard Zingerman" , "Kumar Kartikeya Dwivedi" , "Martin KaFai Lau" , "Song Liu" , "Yonghong Song" , "Jiri Olsa" , "Emil Tsalapatis" , "Ihor Solodrai" , "Yuan Chen" Subject: Re: [PATCH bpf-next v3 1/3] bpf, arena: fix range_tree_clear inconsistency on kmalloc_nolock failure From: "Emil Tsalapatis" To: , X-Mailer: aerc 0.21.0-0-g5549850facc2 References: <20260810134800.2875487-1-chenyuan_fl@163.com> <20260810134800.2875487-2-chenyuan_fl@163.com> In-Reply-To: <20260810134800.2875487-2-chenyuan_fl@163.com> On Mon Aug 10, 2026 at 9:47 AM EDT, chenyuan_fl wrote: > From: Yuan Chen > > range_tree_clear() pre-allocates the right-half node before modifying > the tree, so an allocation failure returns -ENOMEM without altering the > range tree. > > Signed-off-by: Yuan Chen Reviewed-by: Emil Tsalapatis > --- > kernel/bpf/range_tree.c | 16 +++++++++++----- > 1 file changed, 11 insertions(+), 5 deletions(-) > > diff --git a/kernel/bpf/range_tree.c b/kernel/bpf/range_tree.c > index 2f28886f3ff7..15b588377a76 100644 > --- a/kernel/bpf/range_tree.c > +++ b/kernel/bpf/range_tree.c > @@ -143,16 +143,22 @@ int range_tree_clear(struct range_tree *rt, u32 sta= rt, u32 len) > if (rn->rn_start < start && rn->rn_last > last) { > u32 old_last =3D rn->rn_last; > =20 > + /* > + * Pre-allocate the right-half node before modifying > + * the tree. If allocation fails we return -ENOMEM > + * without altering the range tree. > + */ > + new_rn =3D kmalloc_nolock(sizeof(struct range_node), > + __GFP_ACCOUNT, NUMA_NO_NODE); > + if (!new_rn) > + return -ENOMEM; > + > /* Overlaps with the entire clearing range */ > range_it_remove(rn, rt); > rn->rn_last =3D start - 1; > range_it_insert(rn, rt); > =20 > - /* Add a range */ > - new_rn =3D kmalloc_nolock(sizeof(struct range_node), __GFP_ACCOUNT, > - NUMA_NO_NODE); > - if (!new_rn) > - return -ENOMEM; > + /* Add right-half range */ > new_rn->rn_start =3D last + 1; > new_rn->rn_last =3D old_last; > range_it_insert(new_rn, rt);