Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4096148ybl; Mon, 3 Feb 2020 12:30:06 -0800 (PST) X-Google-Smtp-Source: APXvYqyG4sS6zl9dGLaaobqH8EAs4lAdghHM92dUpVWl56Sy0UTz+udTWP3BjRbFEuwA1VWQWZhO X-Received: by 2002:a9d:7498:: with SMTP id t24mr5869287otk.290.1580761806384; Mon, 03 Feb 2020 12:30:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580761806; cv=none; d=google.com; s=arc-20160816; b=mhIIFEZRkqSXvrj8l8MnRMFXIEjGXYr0iv0NIwL7bp2VGn7kdHdIW3DK6QjTbtLWXQ JrErkPvu1yXKaClrNv5UizWMMMImvbWNCSYgpUWuztMWdveGmwW8OKnnsMPaFDBhJyWc mmXs8WZAxUyvEIdJn4HSUsjyVpBovW6g+Wxbo1hC1Qtxu+XWBAjbE70Jx3p+l4rl5t89 Fcyto8rEzWj0zw4/MK0V/Qaf7C6818nJAM/a0/sm7KumsjDrQkiO+An/3wcUNPDZYhSH eoh5bit5v3VPSc0vloOWeTkndmgEN5wH9Ct9Nclho+bE00Qvp7bKl25bioJ1NQpCbm1x 7oiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=siQycGYY8uLdiyJo1UqDxauAjdTPEMqBtw7U2dZ5LhI=; b=PxsLKGLrV4RSZonDqxMm6NbaU3vNz2hm9bZZsXb/rGCmzupFYMLRpR4IpzRtYwELID watz5dtHG/2ykklzY+f80I1JLaeBdlu8q5NuLIXjDrtS9m+0JEb+VEny9xz1aa6qjNmA 7/OtQ0hFM7lalOw6Yf0fwJ2nhtn6YSECEewaGb43rygkQRRp0yCaRkfLN2R8Jjgn8wHq ksTc2QKTL9KFbv/G+TeZtKFRwJ346OJI4sBtSuy1U1apUMX4E4BoPrOvhW3kGYIliFG5 8LBYx+6gFU1pIC4SibysXt4853O+CrLEiI5N8dxNZXkR6oYXEX/Q1Zt8CKqHrLBE1akL RtmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lrRwlB1o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si10201700otk.42.2020.02.03.12.29.54; Mon, 03 Feb 2020 12:30:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lrRwlB1o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727102AbgBCU24 (ORCPT + 99 others); Mon, 3 Feb 2020 15:28:56 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38406 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726325AbgBCU24 (ORCPT ); Mon, 3 Feb 2020 15:28:56 -0500 Received: by mail-pf1-f196.google.com with SMTP id x185so8147551pfc.5; Mon, 03 Feb 2020 12:28:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=siQycGYY8uLdiyJo1UqDxauAjdTPEMqBtw7U2dZ5LhI=; b=lrRwlB1okgYyiQFnN8726aVdL4ZvGDPMB2bCyV7nkABshDDfBQFEiqUIatekSfjzPq ymoMpIxnDZ6RB1jHFZB1k1hMNp+PmneFQ52vu+SOwQunzS4e9EHPRW8BoEXbC7gTu9iZ BjAo4K0Prv89IZrg0I+yQxep/AnIclR9ElrAOHJEeaV3TV6eg5r33iD2DtQ1w++V7gT1 XIZe6rFezKbT79+LmemzMNLWoloFllvWVM9NmYwyyvyXkVD9XbqRunhq85J13lXpZCGl 0be6Qz+ECXdGzUYGA93mgMlDNajAugsnUOs7/ijAvMvO07wJsmXRMQAKTmtYKcMSLJNO lBOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=siQycGYY8uLdiyJo1UqDxauAjdTPEMqBtw7U2dZ5LhI=; b=VKOB1Yhq9qFo2H4Y+Msn0L5HwjbzFNGUG5sHN01PBWdZO3HI2k3u662MYjyilH3MZo 5lGaVwDslKHnmLOHA+P0oS5Cy412At/eJvVPYafJVT+roQ6tg+V62S/k2vLjlgz88usu RedvE2NBj/F2tecWjSmnAAae997usUx3JuSAjRf5K4tPjVHTPbRfN2uKhq95MQHSorWg utgJmoR1Jz/vL9pV4yy8X0P+D1A9yN76BY3wI4ajYb/MfuXGalh57W/FI1wUq1FzP38I 9ADjOQLVFzdgwrO8QIGYetX72VEt8VszwKwYdZCvhsDEZDMBTIwTw83BldwIakpdGDhb Q/pg== X-Gm-Message-State: APjAAAVFyzMsq+sQ+G3jdXF3Yprnazolygr24hl09VY9l9pXkEGKRGgr AbhWRa13yV58eSJ7lRRSM1R/imTz X-Received: by 2002:a62:8601:: with SMTP id x1mr26557329pfd.0.1580761734660; Mon, 03 Feb 2020 12:28:54 -0800 (PST) Received: from ?IPv6:2620:15c:2c1:200:55c7:81e6:c7d8:94b? ([2620:15c:2c1:200:55c7:81e6:c7d8:94b]) by smtp.gmail.com with ESMTPSA id iq22sm345701pjb.9.2020.02.03.12.28.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Feb 2020 12:28:53 -0800 (PST) Subject: Re: [PATCH] skbuff: fix a data race in skb_queue_len() To: Qian Cai , Eric Dumazet Cc: davem@davemloft.net, kuba@kernel.org, elver@google.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <648d6673-bbd8-6634-0174-f9b77194ecfd@gmail.com> From: Eric Dumazet Message-ID: <126aa227-2383-efdd-742c-6ccf85ae7ba4@gmail.com> Date: Mon, 3 Feb 2020 12:28:52 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/3/20 12:19 PM, Qian Cai wrote: > > >> On Feb 3, 2020, at 2:42 PM, Eric Dumazet wrote: >> >> We do not want to add READ_ONCE() for all uses of skb_queue_len() >> >> This could hide some real bugs, and could generate slightly less >> efficient code in the cases we have the lock held. > > Good point. I should have thought about that. How about introducing 2 new helpers. > > skb_queue_len_once() > unix_recvq_full_once() > > which will have a READ_ONCE() there, and then unix_dgram_sendmsg() could use that instead? > We added recently skb_queue_empty_lockless() helper, to use in these contexts. The fact that we use READ_ONCE() is more of an implementation detail I think. Also, addressing load-stearing issues without making sure the write side is using WRITE_ONCE() might be not enough (even if KCSAN warnings disappear)