From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f41.google.com (mail-yx1-f41.google.com [74.125.224.41]) (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 E17D144B675 for ; Fri, 27 Feb 2026 16:13:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772208836; cv=none; b=PKsmaWkDoGypxmtmhW/HjS5Bfzm1YFKPaMkxiTIR1aKdHslZXv79Kohzj9bHAVcJT1Bo42L/lJEoUQGedmRfMlZ7VkaPrSCjn1h4HORSiEmVP8tqXfWiVKx93RLtkW72SUt7yHVnzwma0ZVimZO0f04phbfKOzFtS1JEAj62dW4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772208836; c=relaxed/simple; bh=5N7k/OGyvNvB2Is+dOCWjZ2rAb+AlvIrewr8O6YU0Ek=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NmWb5L0jlv7WRXYZIbmhQqG5EyJTlf6oAG7N8QE4EULq+kVSipYbtXqyFWCzRyL9bHiLd6pO3yMrMhGU75W5LyZ0CIIAgOmvQFyVXcrrKUAsEFWVodwlOGMihLYce8CK2jvDxYltrWIxbk25l4XZ0yKMX8bUjQ1SytNbD1jg79M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=V4fhsAcx; arc=none smtp.client-ip=74.125.224.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V4fhsAcx" Received: by mail-yx1-f41.google.com with SMTP id 956f58d0204a3-64c9cabfe5dso2810277d50.0 for ; Fri, 27 Feb 2026 08:13:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772208833; x=1772813633; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=wvGYMuq+DTIEbhPW+4wAK7O2eq7RAD+irx86VxuI7fQ=; b=V4fhsAcxMwwry68HpJP9ylasEEtzcHFJ+urc45TPzEBjGOA3fdiFxdKu6duVN94h+5 8+SrKQdd4nuiXcWUAzfNrFzEHEOfILeMOvsuN4z96v1Bjp/JODmMczRxN/YEFP3xA8t8 7Xsfs+2ixr0XCXuCvUD0lK/mT+p0DIrJYl7If6vPFCrWliIQV6RePXY0C/0hV7n2+BTx Cp73f0/U6LwBlMd9LR+o9gO49p+/vxYx1uq9mU9G/WRMWjiToA9JXHO+j3o9lJ5eVChJ /b6zpn34X7CHO8gV/kgszsQzpJACeHr0Tus3awFfvzuOSSXnavmNv6e5nVNwoM84ii/h 8iWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772208833; x=1772813633; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wvGYMuq+DTIEbhPW+4wAK7O2eq7RAD+irx86VxuI7fQ=; b=ly0K3Yk8u3r7YNqb7ZD6sn42P2csD/X3JOroChRwl4l/E7S6TcOGRVZZDOo03dQuR+ lIxVMgML+y5QWKCpdZc4kPQSgtLKgN+pY6QeMUJc8Q7JDeydfuwUSgKqNx83Xg3C3p0u yTqFcMDV1bqCcNKlQK1VFh3yd1DsZEBSQio6gJAmxhZdGikbJKZpXQOO6Y05+F087Xgl 7ySJlPCwDteQrf+Wdd5Pf0tzZYXQ+N3jiBUv7d6ls+ddo8OgtqJZaGJpE7wfpfRsrbC5 VMLP4fWDnd1EXdw+8TuTr0+yUtbKbOcdKvtD40M71Cp+xR2+JWT7op8Lz8m/DM+lNZwF Fy+w== X-Forwarded-Encrypted: i=1; AJvYcCUNfKqDDfdTXr88YVTNvh/DVuxcB3WGdb8bYU8eCUTIV+ghEdpq92Rg5uwZV1HicCZQDmFaW0WhZhRsd90=@vger.kernel.org X-Gm-Message-State: AOJu0YwYOg+L7Fpu0ugm0YmHz0jjY/aYTUeTRSYdSbK3PgjdcjqyX74Q vLkMSFBEOQCtS0JRp2zEte/TbRUviokIRQatyoY+9P7uZClspy0lyT3lMUbxSQ== X-Gm-Gg: ATEYQzziHLzFwGBXjq8E7m+ftjHbF+VSGBNHrhUIWK2knlYqTDuh3KEwALEp/SyO+2/ i2xRNuDfNYu97y5MiQ531M8PKArKQ9jq2Gdz7asaymf1j2SLNgfCblnc8oM9FElNgu8jpd6/khS Tp4r4jxrFP7x0LknTu3QqlyA36w6RpXvWyzhCpo+vlW3EmpK576Res1bYX8qOqq3PUY0gpnTqoV lbg3bAZfccdgWnaiSkF6HjZ/PrMrFTnMpvIFWRkFhuoz9yjklEcAMyRSzRp6tEU+vfLWTdjhMS4 TQNwAQadBXpthSONXR3doich8iWRXx24TuQd+KkLvKacI3a7AzECg3knKvtiq/7qwb+HiUroug1 elix2eqWf36uriJ90aE5cIwmnOtQgnis4D5JWNcIVaigmPTux/a1TBWfA+xoZMOn5XqllJYQW0g qXI2vtPuiyVH92EElyF4iYOz8GCkCUVqn/JhOyjfV1pVQA8Q== X-Received: by 2002:a53:ee51:0:b0:64a:d18e:7e81 with SMTP id 956f58d0204a3-64cc2ebf559mr1746274d50.12.1772208832782; Fri, 27 Feb 2026 08:13:52 -0800 (PST) Received: from devvm11784.nha0.facebook.com ([2a03:2880:25ff:e::]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-64cb7657698sm2527943d50.23.2026.02.27.08.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Feb 2026 08:13:52 -0800 (PST) Date: Fri, 27 Feb 2026 08:13:50 -0800 From: Bobby Eshleman To: Mina Almasry Cc: Stanislav Fomichev , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Kaiyuan Zhang , Stanislav Fomichev , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Bobby Eshleman Subject: Re: [PATCH net] net: devmem: use READ_ONCE/WRITE_ONCE on binding->dev Message-ID: References: <20260223-devmem-membar-fix-v1-1-37dcae1e49f8@meta.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Feb 25, 2026 at 09:31:48AM -0800, Mina Almasry wrote: > On Wed, Feb 25, 2026 at 7:14 AM Bobby Eshleman wrote: > > > > On Tue, Feb 24, 2026 at 05:49:42PM -0800, Stanislav Fomichev wrote: > > > On 02/23, Bobby Eshleman wrote: > > > > From: Bobby Eshleman > > > > > > > > binding->dev is protected on the write-side in > > > > mp_dmabuf_devmem_uninstall() against concurrent writes, but due to the > > > > concurrent bare read in net_devmem_get_binding() it should be wrapped in > > > > a READ_ONCE/WRITE_ONCE pair to make sure no compiler optimizations play > > > > with the underlying register in unforeseen ways. > > > > > > > > Fixes: bd61848900bf ("net: devmem: Implement TX path") > > > > Signed-off-by: Bobby Eshleman > > Looks correct to me, and AFAIU Stan is right, we might as well > annotate all the reads of ->dev as technically there could be a dmabuf > uninstall happing concurrently on another CPU. I also think it's > probably good to annotate potential races. > > The ->dev write in dmabuf binding doesn't need WRITE_ONCE annotation I > guess because it's initialization, it can't race with any reads. > > This makes me wonder what other fields in dmabuf need annotations. I > hope I didn't miss many more. > > I would add this is really not a critical bug because > net_devmem_get_binding() is in TX path, and it is more than fine here > if we fail this check if there is an unbind happening in paraller with > sendmsg(), but it's probably good to annotate potential races anyway. > > -- > Thanks, > Mina I also noticed in tools/memory-model/Documentation/access-marking.txt section "Lock-Protected Writes With Lockless Reads" it is recommended to also use ASSERT_EXCLUSIVE_WRITER(), with explanation: "The purpose of the ASSERT_EXCLUSIVE_WRITER() is to allow KCSAN to check for a buggy concurrent write, whether marked or not." Do we think it is worth adding here? I'd think so but didn't want to throw it in without checking. Best, Bobby