Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp746247lqp; Wed, 22 May 2024 20:35:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUIIw2yfVPGMpoKE//O136V3SlbTKM/VREiAo84qavAoWQ+qDqepIOxSagbeSUM5e9VJmp6GcnflIYZ3ZNJF54xpz6LPt0TIWiXqRSCiw== X-Google-Smtp-Source: AGHT+IHM6h7YLR09OxuuLBOESv2a4PVEEfd7Bzu+CEIOE+Gx0/uGoIcLSXvAnyHyLz/MUCf5oiXq X-Received: by 2002:ae9:f109:0:b0:790:ac28:fc46 with SMTP id af79cd13be357-794994b20c8mr445210685a.50.1716435348636; Wed, 22 May 2024 20:35:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716435348; cv=pass; d=google.com; s=arc-20160816; b=d1bRZxndh4GSAusB2OgT2527mApUKray+pTrw/gHXjVi00nJ+8GsueYMhse7HcCe+N WtzdldU74p5z3jh9StXw/nw6GXkhgGcx6K33HXBjFCG9gS5tUsxUzT11ARZrh2NwTX7W VSOe7y+On0tahgY1X7wSUn09Ngqrxx016ZKynSWOlC+rCI43iTKb6mmAMYrFjGl/2ta7 0R8gSBGQFbfVhc5xMGl7yliP/o7aT5GWfeUatExexhyDZMhx1k9l11RHNeRCgMLcqf7T LJQSYHuWSl59BBbN+f4j3uot7TD7nqV60CemUsn0rgJfvJm10/JQrYh5GIK02hsspLtS MKBg== 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=Edz+spRadCuEuTc5xuLHlUq7tEO+Mg+jzXkLSG4gVIo=; fh=NG+2HcCuINbUNwqzE3YiHBQgrGiVnfrSY9bzMIZGeAE=; b=tk7e0EpE5sr+/ml6dRO2SUxMHKN8YWl+Jhm4ts2qQbt2f2Y6cDmY+HkP1QgEe8Gtyo jb8Mm2f9RZiEVWTAiBpuI9bTZrOWzQF9y6JKFV5hbmQZXv70bbH9gVkNjFAd2JzUOB0w FykHQLAWNXhtd9C0qwkEH47avz6/1pvyE+jwrBpqnLDM5/EgdKcvkYJHASxMed8oTr5r YCuZ6m2zwM9ZcPl6wOVdIdvpU7UEZykZpmmGiEgyxekCWmAmBMPd2SJjJJpwvRhxzEqC xcg9/a/OOhXJsVXrLckr/nCp+i34X3Njic/D31H66CrwVLUkUCtFSlWQrfDH0jinG0a9 lXVg==; 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-186957-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186957-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf277333si215016285a.23.2024.05.22.20.35.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 20:35:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186957-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-186957-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186957-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5D33A1C208E4 for ; Thu, 23 May 2024 03:35:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D1F55026B; Thu, 23 May 2024 03:35:38 +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 48364282E2; Thu, 23 May 2024 03:35:30 +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=1716435338; cv=none; b=JLHX7oiTNA3PvLe8Rphk8KQvG6LSB8jkYOrCd+2Ky4agj0phMmdtqeYoGmyY6LlC7rPRXOlVZT6MpKMvNJz3ElFF8iuJySJVJ81/Q82wJQns/qZyuZXTEMtbTRredSjGMeAF9KuC+A0IfKv1/QsovxpplJMO2U6WAX1LREDSo58= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716435338; c=relaxed/simple; bh=1ecCdekXvw0Q7fYMCuFXZvMAgocCTlyHdeTnVgBbGsc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=XbUQ3j+8pZul4VTk8w4wOtlJyysMbCh80Rw8ZhFHn+aq6rV4kzbw2ZJ6zQmX36nL4vl53opqJtHyZW556umKQEbrSUy/vFmaoo7M/0K598cFhX8YFFUc9q2uucg3fTjSZqb8zplophDjCcKbUKD12/QOHtv/mG7a6ndVo2EYJ10= 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: 7e16bede18b511ef9305a59a3cc225df-20240523 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.38,REQID:9c1f3f2c-37cd-4dbb-a4e0-ec9ef964244c,IP:10, 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:9c1f3f2c-37cd-4dbb-a4e0-ec9ef964244c,IP:10,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:047024193c2cce1267aed56d352d254c,BulkI D:240523113247WF7YM8BT,BulkQuantity:1,Recheck:0,SF:44|66|24|17|19|102,TC:n il,Content:0,EDM:-3,IP:-2,URL:0,File:nil,RT:nil,Bulk:40,QS:nil,BEC:nil,COL :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: 7e16bede18b511ef9305a59a3cc225df-20240523 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1714773553; Thu, 23 May 2024 11:35:25 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 360CEE000EBB; Thu, 23 May 2024 11:35:25 +0800 (CST) X-ns-mid: postfix-664EB97D-24684865 Received: from kylin-pc.. (unknown [172.25.130.133]) by mail.kylinos.cn (NSMail) with ESMTPA id 16CC1E000EBB; Thu, 23 May 2024 11:35:22 +0800 (CST) From: yunshui To: bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: martin.lau@linux.dev, daniel@iogearbox.net, john.fastabend@gmail.com, edumazet@google.com, yunshui , syzbot Subject: [PATCH] net: filter: use DEV_STAT_INC() Date: Thu, 23 May 2024 11:35:20 +0800 Message-Id: <20240523033520.4029314-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. Reported-by: syzbot Signed-off-by: yunshui --- net/core/filter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index 2510464692af..9968db21a29d 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -2274,12 +2274,12 @@ static int __bpf_redirect_neigh_v6(struct sk_buff= *skb, struct net_device *dev, =20 err =3D bpf_out_neigh_v6(net, skb, dev, nh); if (unlikely(net_xmit_eval(err))) - dev->stats.tx_errors++; + DEV_STATS_INC(dev, tx_errors); else ret =3D NET_XMIT_SUCCESS; goto out_xmit; out_drop: - dev->stats.tx_errors++; + DEV_STATS_INC(dev, tx_errors); kfree_skb(skb); out_xmit: return ret; @@ -2380,12 +2380,12 @@ static int __bpf_redirect_neigh_v4(struct sk_buff= *skb, struct net_device *dev, =20 err =3D bpf_out_neigh_v4(net, skb, dev, nh); if (unlikely(net_xmit_eval(err))) - dev->stats.tx_errors++; + DEV_STATS_INC(dev, tx_errors); else ret =3D NET_XMIT_SUCCESS; goto out_xmit; out_drop: - dev->stats.tx_errors++; + DEV_STATS_INC(dev, tx_errors); kfree_skb(skb); out_xmit: return ret; --=20 2.34.1