From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.72 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796133018; b=dekAx3d+alN0y3eCK9Rqw15CMvts8b51i13Dkx0e9rmH9Ydb7pJAfuU6dxqx40TyOwRG aQCCKRCAurMx2mRMJbngnDLor5xFN3S6qTmh/FcQRK9gqIAAs9H3ezOJQcTC/iiJG2/BN d0NZ0DaLdAt32IzM38XQ7gePl44Mj/8UQ+iZOCR7ljaUo2J5wELv26/k/uip0ctNUtuXa NBZYK+bpCxDOpKT6cmNdPlG6AN29l9u7I+0himsCsCQqGi/ejGkacCHCbNzaGL+tcODkE gyS1Qe10+PJzFIUQGi4HruaGFGJVtqYqRJ44qUsLnq/DpeGwxscXv553Doo4SlgaS7w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796133018; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=KhN+KiSEJAHBRV9/9E+c8SEFjlKyXeDSFTgyZhb5KNY=; b=SJW6XcErPVC6eMDrbIDZaU+QVHqPaEe8eUl1arH+dNbJMED6vupwP2kzAc+wKIWBYtRD wWUlJkTQ8iJlao/C85FD9PO9w2I1GMDB3FCeA4hHzei5V/bfD8fHTEnOUrICHbsbcy5bw oO4cys0gw8byFk6AIrs58lffIFgT4Tmua1EDhjyK+PhzupAe8F2mdjXnspq4utLdTV1JX gSQeQK5e9wtaGqFRl6UqaYxtfmMnvmg5L9/iiYegpK25Nx9nPauP5uu7L1vYfN1ayXNu4 pHbHoMz7K2jDD66sytyb7NF/R8GO5hgK+Y1/q0wtKXQF2g6MVPN9VFnYHsyWwgx02Bg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b="EXv/r62o"; arc=none smtp.remote-ip=209.85.221.72 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (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 13513606A6AC for ; Tue, 1 Dec 2026 13:50:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 13513606A6AC Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=EXv/r62o Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-499ca65ae87so5650092f8f.1 for ; Tue, 01 Dec 2026 05:50:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796133016; x=1796737816; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=KhN+KiSEJAHBRV9/9E+c8SEFjlKyXeDSFTgyZhb5KNY=; b=EXv/r62ojst6Hb1gLRjpjiFXDVot105RTV1sPgWqV6gwdvNSvJMeysiCVbsTXwn4h2 gnN+HqglbrgvxkMzqwpmIMW24Du/nKZv/TvpIxfoy8s3hGTTK/+vU7yuC7o3o9J1AYay Ra3I6IrD8+bnOhsOlKPXL1WSHxK93NahHhFVwCOO/ZNPHh7NZb+MKUtHeBCyYBqyWVJ0 wftdKOsARztp47kVE6iUicV5Se8/OtTdsp/JcSxVzGD1Ne8HWGE/Am/+jqCsxw+/QVDc M9fpsRfADmt34mmPdQJvQrI5ujbN2JIgt9SdAkpn1bOakLzdDV2fJIpgfquq5S4AAwG8 v5gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796133016; x=1796737816; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KhN+KiSEJAHBRV9/9E+c8SEFjlKyXeDSFTgyZhb5KNY=; b=shT7LnskRRnnxTl7Wv/SEVDnGglVNAMS4sCeF8t9isdEPkUWOHee3YVcOizCYWXJ3e mexSYFeUw/Dj2/7T1RUwtaW+GFqojZl9SaNfolOLRYPWEAu2YLTdoTJXcDIvKzwRmXqa 1okSXC1JA9nKkR25Kn9tPY6fyJPbnbpJPtYj3HH0IJek93rn/pFbzyJSr75rgAddJOtR 08geHJyXwq+E6CoMeJDfGtfQ5JL0xPouZHdQvGhKbm3Ldw80wSigZD+zqWjiRnTeG92w 4CTJ46mlyT76DsU3kUYR7liP5sdyJTtp8TzQ1Ig3UtmV5X/UM5jhAWos/veWAEH4TabE GRWQ== X-Forwarded-Encrypted: i=1; AL+hErEnI5itMsOGCjLr9GQJ/BjmizLM+eg6BiOITMuE+JYbhXN1LvUoTTF2vlYpZH3ozQJCps20djlwcAAwZhM=@vger.kernel.org X-Gm-Message-State: APuU4Z9B6CvfJEFrvposKjKvnFAcz9u/E4VGkTi8q8h2WnavPMj9Ztqo YtI/ZmJeOTnQ7VBCX1mEMOR/BgJGpVtFEcCvA1JVgV9dDQn3F/Cp8gbGC1XV9tB4uujz1bEWEco 0bPJrn0YOXkqbtfklNw== X-Received: from wrvd9.prod.google.com ([2002:a5d:5389:0:b0:4a7:85c3:7bf9]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:2383:b0:492:aff5:da4d with SMTP id ffacd0b85a97d-4aa545e244fmr98725003f8f.7.1796133016291; Tue, 01 Dec 2026 05:50:16 -0800 (PST) Date: Tue, 1 Dec 2026 13:50:15 +0000 In-Reply-To: <20261127120553.1233-1-AeeSec@126.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 References: <20261127120553.1233-1-AeeSec@126.com> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261201135015.2200077-1-aliceryhl@google.com> Subject: Re: [PATCH] rust: rbtree: call rb_erase() before KBox::from_raw() in remove_current() From: Alice Ryhl To: Bilal Hashim Cc: Alice Ryhl , Miguel Ojeda , Boqun Feng , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Fri, Nov 27, 2026 at 08:05:53PM +0800, Bilal Hashim wrote: > In CursorMut::remove_current(), KBox::from_raw(this) is currently called > before bindings::rb_erase(&mut (*this).links, ...). Constructing and > moving a KBox asserts exclusive (noalias) ownership over the allocation, > which invalidates the raw pointer `this` and aliases with the subsequent > bindings::rb_erase() call that mutates the rb_node links in C. > > Move bindings::rb_erase() before KBox::from_raw(this), matching the order > already used in CursorMut::remove_neighbor(). > > Tested with LLVM=-22 and Rust KUnit doctests in QEMU (372/372 passed, > including all 11 rbtree doctests). > > Signed-off-by: Bilal Hashim Note that `KBox` doesn't actually emit `noalias` today, but it is of course still semantically wrong. Reviewed-by: Alice Ryhl Alice