Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2384998lqb; Mon, 27 May 2024 19:26:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV4C3V89DalCqLSgtmPC2t5p4tjS5UzIKX9l/ih/3RANoI7oo5nUL5eVwezOinNUfHjDu6i602kjsSCHXMWrlhI0gIR+QujwraNkHSOaQ== X-Google-Smtp-Source: AGHT+IEbGWJAQyo6/QsBW3MHBLbknpOvYel6ZK46pdOx8c5iUO6dEByvFwN2ENXHLgpSierX6Q9M X-Received: by 2002:a05:6808:f8b:b0:3c3:d47b:e4cf with SMTP id 5614622812f47-3d1a745ade9mr13720158b6e.39.1716863212918; Mon, 27 May 2024 19:26:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716863212; cv=pass; d=google.com; s=arc-20160816; b=hscTQqGux/agJKdrSwfApce+adMnNliaDv64sJnhr+9bU61Qtd/31ncrMz63KWPwcG in9vMUyAop6YO9Voaambx62UPAX2dpNVaiHyHnRfx2qf2AFA/bfaKVkCo670lfVfyJjv ZdUB7lDSrbozG42J3buk+OSGd7KJhu92gkiLt1no/XlU33gGqdVOrU4YGVEs19ZuVivK 2VkrJy7TJhPtjRUFweDrxD6fuO4gl6s/8M9m4fck9CQpZB+2OqRlb1x2qCMcd02z6YsC PshCG0NHrSMVT+wa1mETXJiBchu870aKVLTgUpasyI6a54q0WppHuYF2As2JGinMwPCy tvqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=i9TTFVEqmMf5Js7JBH1HfHraHeh/DO1qWhD12Ahw0Rk=; fh=44w+tjgVk/DcPJOvvBEjFJZUc/HfVqHiSLzQM2Nuk1Q=; b=BfUNE+eiFR7GZYday0IVnVxOZU1F2UzgtEVJ2hYcPF7yA3RTBt5NXw8biRbNyUv+Cv N69XtefgxaYF59Yzqw82g+rrbzuQHasle/nkPM9PSLxq2ydf5eL9RN4h4SasUSKkGDdq zdPhc2MUNiiK+ewIc9UTmlTfs17iC9zuxUcDjd6KV4aO/KeqYTB203KZjs0RgevGiiKe a8aUp+qGb4TrUjg8b/ERUrsbVJs02Z1co0/Bsv4GXSH0qe+dWIuu+v7sYTJwt7qTcSQI uU56QE2DdWnvhFnph5Jzw3kR5evSHk+1c0X7tIrj4ZIUwCNZXzkjKmxVpxVD1uh4l/V6 rqwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-191653-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191653-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-68221c6b1d2si7267314a12.126.2024.05.27.19.26.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 19:26:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191653-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-191653-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191653-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8F67928426D for ; Tue, 28 May 2024 02:26:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27E18101DE; Tue, 28 May 2024 02:26:28 +0000 (UTC) Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5FF7101C5; Tue, 28 May 2024 02:26:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716863187; cv=none; b=QKVJBxH1Ah3ciOJelney1efkAAnRUK1ISSuy6ogaL+9w3YgS3//X2LGwNk8+baCtR4cZvohEVtTY7JdchLQMdJtCoCzTZ//hrk5JyU31Uutnnl7bQUScLwZFAxzcFmB8QJMRSIHtroBc1WFZEC0ulGcUCpRTBuBRB9PFDghzUXU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716863187; c=relaxed/simple; bh=sJ7T7KFcp90vesE12nZApEMOYDYTcaHY8VsfRZpRCFg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=T1BKl8DL1vkgeYVy9rkLoR+O06A3LSIfs5DGgS23Opi3i3HWGhRw8EFPbOGx+plw+DoD6oBrl2vJPFNa26FJbU2XnXW7biZshMiPHw6HQCTYumM+8NGVmQFi+QvfqWDlaUW9S8IDTuxnhy/0ePL26uurjA4dZZL5/L1GRFgRDpo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: a9cfbaac1c9911ef9305a59a3cc225df-20240528 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.38,REQID:23330111-d458-421c-8338-26bc86d8450e,IP:20, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:5 X-CID-INFO: VERSION:1.1.38,REQID:23330111-d458-421c-8338-26bc86d8450e,IP:20,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:5 X-CID-META: VersionHash:82c5f88,CLOUDID:4bc1deb82b12753c767b28bc0c1f5f35,BulkI D:240528102617GGBWLTU8,BulkQuantity:0,Recheck:0,SF:66|24|17|19|44|102,TC:n il,Content:0,EDM:-3,IP:-2,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: a9cfbaac1c9911ef9305a59a3cc225df-20240528 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1625702118; Tue, 28 May 2024 10:26:17 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 5F90DE000EB9; Tue, 28 May 2024 10:26:17 +0800 (CST) X-ns-mid: postfix-665540C9-243563493 Received: from kylin-pc.. (unknown [172.25.130.133]) by mail.kylinos.cn (NSMail) with ESMTPA id 29B55E000EB9; Tue, 28 May 2024 10:26:16 +0800 (CST) From: Yunshui Jiang To: linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org Cc: marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, Yunshui Jiang Subject: [PATCH -v3] Bluetooth: 6lowpan: use DEV_STAT_INC() to avoid races Date: Tue, 28 May 2024 10:26:13 +0800 Message-Id: <20240528022613.1974961-1-jiangyunshui@kylinos.cn> X-Mailer: git-send-email 2.34.1 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 syzbot/KCSAN reported that races happen when multiple cpus updating dev->stats.tx_error concurrently. Adopt SMP safe DEV_STATS_INC() to update dev->stats fields. Signed-off-by: Yunshui Jiang --- net/bluetooth/6lowpan.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index 50cfec8ccac4..8eb2cf58c00e 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -295,8 +295,8 @@ static int recv_pkt(struct sk_buff *skb, struct net_d= evice *dev, goto drop; } =20 - dev->stats.rx_bytes +=3D skb->len; - dev->stats.rx_packets++; + DEV_STATS_ADD(dev, rx_bytes, skb->len); + DEV_STATS_INC(dev, rx_packets); =20 consume_skb(local_skb); consume_skb(skb); @@ -323,8 +323,8 @@ static int recv_pkt(struct sk_buff *skb, struct net_d= evice *dev, goto drop; } =20 - dev->stats.rx_bytes +=3D skb->len; - dev->stats.rx_packets++; + DEV_STATS_ADD(dev, rx_bytes, skb->len); + DEV_STATS_INC(dev, rx_packets); =20 consume_skb(local_skb); consume_skb(skb); @@ -336,7 +336,7 @@ static int recv_pkt(struct sk_buff *skb, struct net_d= evice *dev, return NET_RX_SUCCESS; =20 drop: - dev->stats.rx_dropped++; + DEV_STATS_INC(dev, rx_dropped); return NET_RX_DROP; } =20 @@ -445,13 +445,13 @@ static int send_pkt(struct l2cap_chan *chan, struct= sk_buff *skb, =20 err =3D l2cap_chan_send(chan, &msg, skb->len); if (err > 0) { - netdev->stats.tx_bytes +=3D err; - netdev->stats.tx_packets++; + DEV_STATS_ADD(netdev, tx_bytes, err); + DEV_STATS_INC(netdev, tx_packets); return 0; } =20 if (err < 0) - netdev->stats.tx_errors++; + DEV_STATS_INC(netdev, tx_errors); =20 return err; } --=20 2.34.1