From patchwork Wed Oct 18 19:34:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mirsad Todorovac X-Patchwork-Id: 155100 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp5024105vqb; Wed, 18 Oct 2023 12:38:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEctOnqpCpZSL+W8TqEZXBrGVoE6shiMQryMbSNUwkDo3W6HvKhbfA3UIXpoC904OfcQ52+ X-Received: by 2002:a05:6a21:9989:b0:15c:b7ba:9137 with SMTP id ve9-20020a056a21998900b0015cb7ba9137mr191134pzb.2.1697657879925; Wed, 18 Oct 2023 12:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697657879; cv=none; d=google.com; s=arc-20160816; b=mK2Sf7pSuWWMejTJZ5H13SBVlrMMA04LmkxofERLsIEPfklPJ9/8WVL+bFWanueEgH wQxSX5zhWtymhLfgtExRviseYdP+hzBDWqQTr40dvIISCF34sXiS9UftUz4Xryz0nERn 8BTNq5RsIX3510mAHsox6JiAy+WTntc6KBS6J3zU694Wb6foFzeOCtHv+zaNryTpLYQU TnYDH3Bmdh+BRo1tu1kTDJtwxD5gg7MtuD/11o6PeLvRUCUG2u3rCL7MIoGobBNpQKbj PFr1KHfIzZDxDG3vsioD6Pz71A+LV2yz8qdrM+bZrik2Wv4x3rAqfOHp6KqlMETloYaY 5QbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=O2kO+0mw9oJYr23Z0lbhZAv0KkGdoCZhEyCQ7XlIMb8=; fh=7SsncGRbN74Z5AHCSqGaWZ8qQBPFU2OgoSp70ZMB+sA=; b=VgmhCQ8nxhFoNZjB6hAae6gCXo3XVgfVoe7pyT/cBEf5NsaRK1af9rrl7t2HrZyN1Z EiwLjmlvbRLBhXomZGEl8k7YxTQuu8bhZkfniKuCjJeKLSCHy5ZQ5gPMa4o2a7kVlFsH 4QjyhmsdSJG8BCrEaqxW7aR1nD8Ua3Yx3mbJjaTMgQ+GEZZ7zcjTPEzezBrJ+sDcx5kI ladALnxk7ty3ax7p5PspTjDS1u+vhJtZ7L8xr00heBAlSMuA03Hn0z5PSOZQ0DojYbHp mnpQVAFe1wAMyiNy3VF1C9b6TeX9LSPRiBOoD6+gqfmZkhuQhqsWIrUPPYABOnSY+uYh fB1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=mLQQq9xu; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=GDvTxLaY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bw25-20020a056a02049900b005aa6b242005si3013597pgb.24.2023.10.18.12.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 12:37:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=mLQQq9xu; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=GDvTxLaY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 87620810499C; Wed, 18 Oct 2023 12:37:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231390AbjJRThe (ORCPT + 24 others); Wed, 18 Oct 2023 15:37:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbjJRThd (ORCPT ); Wed, 18 Oct 2023 15:37:33 -0400 Received: from domac.alu.hr (domac.alu.unizg.hr [161.53.235.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC1BCAB; Wed, 18 Oct 2023 12:37:30 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by domac.alu.hr (Postfix) with ESMTP id 68D996017F; Wed, 18 Oct 2023 21:37:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1697657849; bh=VeXWLGEDckmd4sgvaB8SrsTUgqhJhGFE8mZwXOUw68A=; h=From:To:Cc:Subject:Date:From; b=mLQQq9xuLvSTlY6vSyOpn54Q8CmeK94Mpiho5ZneYkIBAYBBjX7D+Md8RWifYj1Ds t7ORZ6IuR0X3R5BTToGQ0GlpGCo9pilpXcF77W5hNqVGOgy6nPJcxvCEYOh76aK9ew ZQ9SrkGYxyrGfkhETGFTgwPobTeneFGI27SaNiKCxZ4qSriexlLL90EZ5QpznnuTbN KcA+ScqKA72PjuYgLegEZeJ6PyJjWT4c6Ojz/MI3veXAjUsU3ZTTUlcaEiApA9Zv68 Sjwn6LHGzYQo0G3EuwsJsIGanop1XRgCS+DrLiDNDTqZdVaD45Xh/V2jP/CeYRBXCx iOoc3pIyLbXaw== X-Virus-Scanned: Debian amavisd-new at domac.alu.hr Received: from domac.alu.hr ([127.0.0.1]) by localhost (domac.alu.hr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Y6TdbkOq1Vlm; Wed, 18 Oct 2023 21:37:26 +0200 (CEST) Received: from defiant.home (78-2-200-105.adsl.net.t-com.hr [78.2.200.105]) by domac.alu.hr (Postfix) with ESMTPSA id 670366017E; Wed, 18 Oct 2023 21:37:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1697657846; bh=VeXWLGEDckmd4sgvaB8SrsTUgqhJhGFE8mZwXOUw68A=; h=From:To:Cc:Subject:Date:From; b=GDvTxLaYbA1WLNXZu4oQ0ncc8ARIQ3PT1j9DybEIEK+gUcMlpQvb9ZQBza9Vwol89 dvMtbis6H6b171xCIhpPl3nD4HFQRGVNwv80EhGoLSI8dAIPPkERX5bkDYKlATFmaw l82iUrOjPQ2bSFy6lg0Pd9aLx01xDj/RkA5Qly9c4jNn/EUP4EsB2DR+MPcTCVIqEv 4qewo8EmeEw3OlwCIjJsVwCpI8XJR7pw7o84uX/tCBhB2ceYRQJq+nKPZTYat8gEKa z6bRl9/WwyLI4GTcmcp8N4VDdAUKGkMQAmelLuMlnCF0w10z6ji/qBnDMvTqcP2Abu pswXMMe56Z/zA== From: Mirsad Goran Todorovac To: Heiner Kallweit , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: nic_swsd@realtek.com, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mirsad Goran Todorovac , Marco Elver Subject: [PATCH v4 1/3] r8169: fix the KCSAN reported data-race in rtl_tx() while reading tp->cur_tx Date: Wed, 18 Oct 2023 21:34:34 +0200 Message-Id: <20231018193434.344176-1-mirsad.todorovac@alu.unizg.hr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 18 Oct 2023 12:37:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780122851528443675 X-GMAIL-MSGID: 1780123309140510775 KCSAN reported the following data-race: ================================================================== BUG: KCSAN: data-race in rtl8169_poll [r8169] / rtl8169_start_xmit [r8169] write (marked) to 0xffff888102474b74 of 4 bytes by task 5358 on cpu 29: rtl8169_start_xmit (drivers/net/ethernet/realtek/r8169_main.c:4254) r8169 dev_hard_start_xmit (./include/linux/netdevice.h:4889 ./include/linux/netdevice.h:4903 net/core/dev.c:3544 net/core/dev.c:3560) sch_direct_xmit (net/sched/sch_generic.c:342) __dev_queue_xmit (net/core/dev.c:3817 net/core/dev.c:4306) ip_finish_output2 (./include/linux/netdevice.h:3082 ./include/net/neighbour.h:526 ./include/net/neighbour.h:540 net/ipv4/ip_output.c:233) __ip_finish_output (net/ipv4/ip_output.c:311 net/ipv4/ip_output.c:293) ip_finish_output (net/ipv4/ip_output.c:328) ip_output (net/ipv4/ip_output.c:435) ip_send_skb (./include/net/dst.h:458 net/ipv4/ip_output.c:127 net/ipv4/ip_output.c:1486) udp_send_skb (net/ipv4/udp.c:963) udp_sendmsg (net/ipv4/udp.c:1246) inet_sendmsg (net/ipv4/af_inet.c:840 (discriminator 4)) sock_sendmsg (net/socket.c:730 net/socket.c:753) __sys_sendto (net/socket.c:2177) __x64_sys_sendto (net/socket.c:2185) do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120) read to 0xffff888102474b74 of 4 bytes by interrupt on cpu 21: rtl8169_poll (drivers/net/ethernet/realtek/r8169_main.c:4397 drivers/net/ethernet/realtek/r8169_main.c:4581) r8169 __napi_poll (net/core/dev.c:6527) net_rx_action (net/core/dev.c:6596 net/core/dev.c:6727) __do_softirq (kernel/softirq.c:553) __irq_exit_rcu (kernel/softirq.c:427 kernel/softirq.c:632) irq_exit_rcu (kernel/softirq.c:647) common_interrupt (arch/x86/kernel/irq.c:247 (discriminator 14)) asm_common_interrupt (./arch/x86/include/asm/idtentry.h:636) cpuidle_enter_state (drivers/cpuidle/cpuidle.c:291) cpuidle_enter (drivers/cpuidle/cpuidle.c:390) call_cpuidle (kernel/sched/idle.c:135) do_idle (kernel/sched/idle.c:219 kernel/sched/idle.c:282) cpu_startup_entry (kernel/sched/idle.c:378 (discriminator 1)) start_secondary (arch/x86/kernel/smpboot.c:210 arch/x86/kernel/smpboot.c:294) secondary_startup_64_no_verify (arch/x86/kernel/head_64.S:433) value changed: 0x002f4815 -> 0x002f4816 Reported by Kernel Concurrency Sanitizer on: CPU: 21 PID: 0 Comm: swapper/21 Tainted: G L 6.6.0-rc2-kcsan-00143-gb5cbe7c00aa0 #41 Hardware name: ASRock X670E PG Lightning/X670E PG Lightning, BIOS 1.21 04/26/2023 ================================================================== The write side of drivers/net/ethernet/realtek/r8169_main.c is: ================== 4251 /* rtl_tx needs to see descriptor changes before updated tp->cur_tx */ 4252 smp_wmb(); 4253 → 4254 WRITE_ONCE(tp->cur_tx, tp->cur_tx + frags + 1); 4255 4256 stop_queue = !netif_subqueue_maybe_stop(dev, 0, rtl_tx_slots_avail(tp), 4257 R8169_TX_STOP_THRS, 4258 R8169_TX_START_THRS); The read side is the function rtl_tx(): 4355 static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp, 4356 int budget) 4357 { 4358 unsigned int dirty_tx, bytes_compl = 0, pkts_compl = 0; 4359 struct sk_buff *skb; 4360 4361 dirty_tx = tp->dirty_tx; 4362 4363 while (READ_ONCE(tp->cur_tx) != dirty_tx) { 4364 unsigned int entry = dirty_tx % NUM_TX_DESC; 4365 u32 status; 4366 4367 status = le32_to_cpu(tp->TxDescArray[entry].opts1); 4368 if (status & DescOwn) 4369 break; 4370 4371 skb = tp->tx_skb[entry].skb; 4372 rtl8169_unmap_tx_skb(tp, entry); 4373 4374 if (skb) { 4375 pkts_compl++; 4376 bytes_compl += skb->len; 4377 napi_consume_skb(skb, budget); 4378 } 4379 dirty_tx++; 4380 } 4381 4382 if (tp->dirty_tx != dirty_tx) { 4383 dev_sw_netstats_tx_add(dev, pkts_compl, bytes_compl); 4384 WRITE_ONCE(tp->dirty_tx, dirty_tx); 4385 4386 netif_subqueue_completed_wake(dev, 0, pkts_compl, bytes_compl, 4387 rtl_tx_slots_avail(tp), 4388 R8169_TX_START_THRS); 4389 /* 4390 * 8168 hack: TxPoll requests are lost when the Tx packets are 4391 * too close. Let's kick an extra TxPoll request when a burst 4392 * of start_xmit activity is detected (if it is not detected, 4393 * it is slow enough). -- FR 4394 * If skb is NULL then we come here again once a tx irq is 4395 * triggered after the last fragment is marked transmitted. 4396 */ → 4397 if (tp->cur_tx != dirty_tx && skb) 4398 rtl8169_doorbell(tp); 4399 } 4400 } Obviously from the code, an earlier detected data-race for tp->cur_tx was fixed in the line 4363: 4363 while (READ_ONCE(tp->cur_tx) != dirty_tx) { but the same solution is required for protecting the other access to tp->cur_tx: → 4397 if (READ_ONCE(tp->cur_tx) != dirty_tx && skb) 4398 rtl8169_doorbell(tp); The write in the line 4254 is protected with WRITE_ONCE(), but the read in the line 4397 might have suffered read tearing under some compiler optimisations. The fix eliminated the KCSAN data-race report for this bug. It is yet to be evaluated what happens if tp->cur_tx changes between the test in line 4363 and line 4397. This test should certainly not be cached by the compiler in some register for such a long time, while asynchronous writes to tp->cur_tx might have occurred in line 4254 in the meantime. Fixes: 94d8a98e6235c ("r8169: reduce number of workaround doorbell rings") Cc: Heiner Kallweit Cc: nic_swsd@realtek.com Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Marco Elver Cc: netdev@vger.kernel.org Link: https://lore.kernel.org/lkml/dc7fc8fa-4ea4-e9a9-30a6-7c83e6b53188@alu.unizg.hr/ Signed-off-by: Mirsad Goran Todorovac Acked-by: Marco Elver Reviewed-by: Simon Horman --- v4: fixed the Fixes: tag for 2/3. v3: fixed the Fixes: tag for 3/3. v2: fixed double Signed-off-by: tag drivers/net/ethernet/realtek/r8169_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 6351a2dc13bc..281aaa851847 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4394,7 +4394,7 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp, * If skb is NULL then we come here again once a tx irq is * triggered after the last fragment is marked transmitted. */ - if (tp->cur_tx != dirty_tx && skb) + if (READ_ONCE(tp->cur_tx) != dirty_tx && skb) rtl8169_doorbell(tp); } } From patchwork Wed Oct 18 19:34:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mirsad Todorovac X-Patchwork-Id: 155101 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp5024892vqb; Wed, 18 Oct 2023 12:39:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCywcJBLop8jBxTIoYyxbpUYFPuQ+OEIkBjATojbfgtGX3zl/BPcTUwM4i/J5T1OFNQPqC X-Received: by 2002:a17:903:246:b0:1c3:6d97:e89e with SMTP id j6-20020a170903024600b001c36d97e89emr395216plh.58.1697657956394; Wed, 18 Oct 2023 12:39:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697657956; cv=none; d=google.com; s=arc-20160816; b=xqOHgGB4G6tVOmo6Le09OFN6+OVDoAoUhgSczSKE3NSC99WCJI/uQZSDE7Cgw8GLUq 5w0jcX9hrENQVv8W5lzAs068Me3S8lA/UeCjVRCLoZhUeHdieDrYBAufed+LNdqdCzvk Bh7rXsMMx8PgqWrcWbmLyrSVc3Ty8QMmSgDwVxn6SkenLDtbgPFrhEn0Ioqoaq8QNNFf 3fTCLUEBtZU3tkIyhIrYcPlMMdKgioZdSU717d7zB+dMRpmNWoaGVY62HxWwo0D2F9Q6 AStTkRo2Ogb7zDKgddf8apq5o4q+kOdS6oX4n5LOeXOxeo3KnjQYa8+BX1xt6Nj2q9et 3qOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=7oFlyaHTqFCcAXS1nwIcVD8nbST3SIKP8l4Dx0rSwUU=; fh=7SsncGRbN74Z5AHCSqGaWZ8qQBPFU2OgoSp70ZMB+sA=; b=KqqX1D3PHdWrM06oXW676bg1bbrMzqkYDK/A2flyVPE1x6UyrurM1sCintJBQB+83F yyDRfJL1Rvh6RFaF/kQyG6e7T385Z1EfcS822w865SCGYDjaalMNYvYmzmY5iEMyBzsw dwmR+Zk8RPDaTxjVkFfw3tm1mHelAjpqo43D/SxiCOrp27lhBLI+7tWkwNujI3/le4B1 iwCDwtREHU3TTaExRLWxes0S2ymlWXo/zwM/OW0AWfLZ51tG0yxee6MiQ3XrLreIcJGp Bh8QjXMnUw7jixxznrDWdvBUOZJQ88m9vIdYUlEIv4Jj9ZsgFOQzUjdsQMV5hunXBzoM VAiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=eZAGDQgA; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=KAjmb4Vf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id d15-20020a170902654f00b001c589ba4a04si523327pln.24.2023.10.18.12.39.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 12:39:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=eZAGDQgA; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=KAjmb4Vf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1AEBE81143F4; Wed, 18 Oct 2023 12:39:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231199AbjJRTio (ORCPT + 24 others); Wed, 18 Oct 2023 15:38:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbjJRTin (ORCPT ); Wed, 18 Oct 2023 15:38:43 -0400 Received: from domac.alu.hr (domac.alu.unizg.hr [IPv6:2001:b68:2:2800::3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B401295; Wed, 18 Oct 2023 12:38:41 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by domac.alu.hr (Postfix) with ESMTP id 6E7396017F; Wed, 18 Oct 2023 21:38:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1697657920; bh=iNVr9y16p7gMqjvxGWT5RJitpyKhZMLfuTLhxHG7Y6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eZAGDQgAN8tryLy/FbQwbshgMTDjqgUPgPc2goAQX1UP1Jvu+xf+zNahwa5FjIlS3 V1EObg0bbBuImiITDYJSUJQp9Qltt2J7yh/cmiV+y4dg2vC+8V+C4asVXWNV8KcNgw RnoLq5r3c7aUy4dCW0kosOw9MXeDMQ4QbJudzBCzSdmQC+t08QVvoX0B6Ch538GIXy 1E9FqtNKugHj6DLCe+opbFlaHKo2MupXyH9RXRKQZPm00Ntntg5zbmwKTFuOGMjFNW us2NmCVhsGm33MsFNXsxQPQT39/tVdgm1/g/R7tv1YndKpDuaH3iOgI4x//srb+fDl wLSGVM/6s1ThA== X-Virus-Scanned: Debian amavisd-new at domac.alu.hr Received: from domac.alu.hr ([127.0.0.1]) by localhost (domac.alu.hr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RzrchXTX35UN; Wed, 18 Oct 2023 21:38:37 +0200 (CEST) Received: from defiant.home (78-2-200-105.adsl.net.t-com.hr [78.2.200.105]) by domac.alu.hr (Postfix) with ESMTPSA id DEE486017E; Wed, 18 Oct 2023 21:38:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1697657917; bh=iNVr9y16p7gMqjvxGWT5RJitpyKhZMLfuTLhxHG7Y6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KAjmb4VfbvWBVJMZNlms/aLuN2a1xKmndkzGRsgvCfCLNqi4FIT/dcId3JyOy6bZA nXgWpd3CPhhga/b1TkTJ92X+lzoUF+aF3S6Vg3tK7t/BSy5v9e3PVr6C/kAMOnSXJa dyZgSo2/xNSSWc5cBvuETDDrYvXbgGaA39IrB+i2w2SZPE+UTuJ6UV43zk6Y6VXZ8C eXSM3Goj+b6TBm4nZMhyivc4K3ZmCQrTmhP8VhODQH9eFqDRtqfwwoL2pGmW/xex7f /NlhFasDiZV0rc1lHnf0c9m2n5E7zNqkHmSQFj47vmFKZ2XV3TPvHqhZG8gSaZQoWl 7QRj7vQxmb5DQ== From: Mirsad Goran Todorovac To: Heiner Kallweit , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: nic_swsd@realtek.com, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mirsad Goran Todorovac , Marco Elver Subject: [PATCH v4 2/3] r8169: fix the KCSAN reported data-race in rtl_tx while reading TxDescArray[entry].opts1 Date: Wed, 18 Oct 2023 21:34:36 +0200 Message-Id: <20231018193434.344176-2-mirsad.todorovac@alu.unizg.hr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018193434.344176-1-mirsad.todorovac@alu.unizg.hr> References: <20231018193434.344176-1-mirsad.todorovac@alu.unizg.hr> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 18 Oct 2023 12:39:12 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780123389546793155 X-GMAIL-MSGID: 1780123389546793155 KCSAN reported the following data-race: ================================================================== BUG: KCSAN: data-race in rtl8169_poll (drivers/net/ethernet/realtek/r8169_main.c:4368 drivers/net/ethernet/realtek/r8169_main.c:4581) r8169 race at unknown origin, with read to 0xffff888140d37570 of 4 bytes by interrupt on cpu 21: rtl8169_poll (drivers/net/ethernet/realtek/r8169_main.c:4368 drivers/net/ethernet/realtek/r8169_main.c:4581) r8169 __napi_poll (net/core/dev.c:6527) net_rx_action (net/core/dev.c:6596 net/core/dev.c:6727) __do_softirq (kernel/softirq.c:553) __irq_exit_rcu (kernel/softirq.c:427 kernel/softirq.c:632) irq_exit_rcu (kernel/softirq.c:647) sysvec_apic_timer_interrupt (arch/x86/kernel/apic/apic.c:1074 (discriminator 14)) asm_sysvec_apic_timer_interrupt (./arch/x86/include/asm/idtentry.h:645) cpuidle_enter_state (drivers/cpuidle/cpuidle.c:291) cpuidle_enter (drivers/cpuidle/cpuidle.c:390) call_cpuidle (kernel/sched/idle.c:135) do_idle (kernel/sched/idle.c:219 kernel/sched/idle.c:282) cpu_startup_entry (kernel/sched/idle.c:378 (discriminator 1)) start_secondary (arch/x86/kernel/smpboot.c:210 arch/x86/kernel/smpboot.c:294) secondary_startup_64_no_verify (arch/x86/kernel/head_64.S:433) value changed: 0xb0000042 -> 0x00000000 Reported by Kernel Concurrency Sanitizer on: CPU: 21 PID: 0 Comm: swapper/21 Tainted: G L 6.6.0-rc2-kcsan-00143-gb5cbe7c00aa0 #41 Hardware name: ASRock X670E PG Lightning/X670E PG Lightning, BIOS 1.21 04/26/2023 ================================================================== The read side is in drivers/net/ethernet/realtek/r8169_main.c ========================================= 4355 static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp, 4356 int budget) 4357 { 4358 unsigned int dirty_tx, bytes_compl = 0, pkts_compl = 0; 4359 struct sk_buff *skb; 4360 4361 dirty_tx = tp->dirty_tx; 4362 4363 while (READ_ONCE(tp->cur_tx) != dirty_tx) { 4364 unsigned int entry = dirty_tx % NUM_TX_DESC; 4365 u32 status; 4366 → 4367 status = le32_to_cpu(tp->TxDescArray[entry].opts1); 4368 if (status & DescOwn) 4369 break; 4370 4371 skb = tp->tx_skb[entry].skb; 4372 rtl8169_unmap_tx_skb(tp, entry); 4373 4374 if (skb) { 4375 pkts_compl++; 4376 bytes_compl += skb->len; 4377 napi_consume_skb(skb, budget); 4378 } 4379 dirty_tx++; 4380 } 4381 4382 if (tp->dirty_tx != dirty_tx) { 4383 dev_sw_netstats_tx_add(dev, pkts_compl, bytes_compl); 4384 WRITE_ONCE(tp->dirty_tx, dirty_tx); 4385 4386 netif_subqueue_completed_wake(dev, 0, pkts_compl, bytes_compl, 4387 rtl_tx_slots_avail(tp), 4388 R8169_TX_START_THRS); 4389 /* 4390 * 8168 hack: TxPoll requests are lost when the Tx packets are 4391 * too close. Let's kick an extra TxPoll request when a burst 4392 * of start_xmit activity is detected (if it is not detected, 4393 * it is slow enough). -- FR 4394 * If skb is NULL then we come here again once a tx irq is 4395 * triggered after the last fragment is marked transmitted. 4396 */ 4397 if (READ_ONCE(tp->cur_tx) != dirty_tx && skb) 4398 rtl8169_doorbell(tp); 4399 } 4400 } tp->TxDescArray[entry].opts1 is reported to have a data-race and READ_ONCE() fixes this KCSAN warning. 4366 → 4367 status = le32_to_cpu(READ_ONCE(tp->TxDescArray[entry].opts1)); 4368 if (status & DescOwn) 4369 break; 4370 Cc: Heiner Kallweit Cc: nic_swsd@realtek.com Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Marco Elver Cc: netdev@vger.kernel.org Link: https://lore.kernel.org/lkml/dc7fc8fa-4ea4-e9a9-30a6-7c83e6b53188@alu.unizg.hr/ Signed-off-by: Mirsad Goran Todorovac Acked-by: Marco Elver Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reviewed-by: Simon Horman --- v4: fixed the Fixes: tag for 2/3. v3: fixed the Fixes: tag for 3/3. v2: fixed double Signed-off-by: tag drivers/net/ethernet/realtek/r8169_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 81be6085a480..361b90007148 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4364,7 +4364,7 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp, unsigned int entry = dirty_tx % NUM_TX_DESC; u32 status; - status = le32_to_cpu(tp->TxDescArray[entry].opts1); + status = le32_to_cpu(READ_ONCE(tp->TxDescArray[entry].opts1)); if (status & DescOwn) break; From patchwork Wed Oct 18 19:34:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mirsad Todorovac X-Patchwork-Id: 155102 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp5025563vqb; Wed, 18 Oct 2023 12:40:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF70l7lnDH4htoEuYLEoCAbgCxyU8zjjuUMZURXueuBQOx8Zv5+mWyRQgUu76fkR8LUva6E X-Received: by 2002:a05:6a20:7d8c:b0:14e:3ba7:2933 with SMTP id v12-20020a056a207d8c00b0014e3ba72933mr174917pzj.54.1697658044528; Wed, 18 Oct 2023 12:40:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697658044; cv=none; d=google.com; s=arc-20160816; b=fy+5w98QllnI8wEziiFyR3G0GNQzXzO4x7/+IJ8gaAdi7ZfiADZ+RqfhgnUsoJVVCW S7sbYx9XAc7e5RPehvFmFITGzE3P5UQKxanAELBWv1SvIPTsER2eM+TsQZLNj2S+De7K 3l+1uTilVRWjLEtkYDtMP+GoEQXCADrYYkRQOjkRm+kS+r8oLY1faUfkl2TR30/00c4O WJ7X1bCDhuApsUoTZuwDJYI5CSoeh3pzqMTwtpS1DcgDwjJkmqyhAYyDakZ023RAT3+Q 3R8H17EVP2ME9LHJUolcXB5J8sqOBtEBd7Fq5oa04JcbTpD36U75giXIhctF7pOr7NM/ UOzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=3pPdVGLSkwwljWTWlrN3ZcwGoTE2M22YQAM/14KVxkI=; fh=7SsncGRbN74Z5AHCSqGaWZ8qQBPFU2OgoSp70ZMB+sA=; b=e9XgMbQupKySpy7+hlEbIWh3vMmnoVw1GifwK5ZSxO4tx/FxM1jTqJYL7ojobeLPca QrCjC6h79PDSJ82Dw4H+2OdeIdpx4zUXQmJ3WksIUIOO+BipBzBsKfu/PrzeZgfruVa8 uUpTzrYjASZaSZhSEvymfyNKAbBlzJKi3YSG32fkiTXWj4D30bXbCFuRy9TDj0Ng9njh YcWLNnqUWRlA9cBb8PhbxEUgmlFyH4xDkeDhBU2KsjOGkuxnD+/kgZ7zy2Fv1/cJORAY CLuJbuQ9C659zZ3k5qM34EMJDhQBagiYur5D/3LU24F3LN+B+m4EI+9XVDJi/ptXOkAO /CHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=dfZf95LG; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=jOC0B18+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id g23-20020a1709029f9700b001ca85c6e508si503301plq.558.2023.10.18.12.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 12:40:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=dfZf95LG; dkim=fail header.i=@alu.unizg.hr header.s=mail header.b=jOC0B18+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alu.unizg.hr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 1B26F811138C; Wed, 18 Oct 2023 12:40:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231527AbjJRTkH (ORCPT + 24 others); Wed, 18 Oct 2023 15:40:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbjJRTkG (ORCPT ); Wed, 18 Oct 2023 15:40:06 -0400 Received: from domac.alu.hr (domac.alu.unizg.hr [IPv6:2001:b68:2:2800::3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82A64B8; Wed, 18 Oct 2023 12:40:03 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by domac.alu.hr (Postfix) with ESMTP id 45E4E6017F; Wed, 18 Oct 2023 21:40:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1697658002; bh=yHUVPeb4z5L9hxdZIS5zlH2jdyA3lCA5q2OYsWtloEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dfZf95LGAaefimWoWFU0iTdbOnjgmytzxlELRZlbeCYDqbAt0VHdLS8VMM2zF/rra HQ+x5Av10A8NGBLyQyxmYVTkuUElUU+8q9Ubcm800O8Yetw45J+CShJLeYdAjhaGm1 DktazET8ZLR1IJqaM/PwhpVpaEJGGhWWRfhNZkGnjelk/zoeVYxcpmOO6lzVJ2z9vt FegWOsgoRFc0SZN9VZDzGwj5rNttS2TkXlRPpFYnsaqrdgkhj5jJrds1/E+I2NaJcq AsXIIHNqUgKvPQ3kHeWIAIpeJDg2HlzUhdHdLtHnxbiKdfsLkEKxz20vLvOpvJ9yWR 8+J1fXV0MImzQ== X-Virus-Scanned: Debian amavisd-new at domac.alu.hr Received: from domac.alu.hr ([127.0.0.1]) by localhost (domac.alu.hr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P42qQ7aCOfnS; Wed, 18 Oct 2023 21:39:59 +0200 (CEST) Received: from defiant.home (78-2-200-105.adsl.net.t-com.hr [78.2.200.105]) by domac.alu.hr (Postfix) with ESMTPSA id 954556017E; Wed, 18 Oct 2023 21:39:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alu.unizg.hr; s=mail; t=1697657999; bh=yHUVPeb4z5L9hxdZIS5zlH2jdyA3lCA5q2OYsWtloEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jOC0B18+SbmBPaxXA1oOWbP+ZSwW/Zu0q/nWQJI0YSuVDXnzawgiBDK8ov4EGmhGY M+T7OtqFxreZPKT6ZerzTj3XQyv8TNufVYTZ8gC68bai/srAYg1COTc+LmdQgKFIBf wt7SkTd+QC3rlc9XhpyYPU2wJZumkKPDwK07I5cNuVzDfEinEp0gOvKfxbLQz53rkr RUO0/jp4joCF4QdRyolyiWHU4P4GVR8zv2dcYofSCmjQfKbpoh/QRMYBN2FxFLHOsu HdOr2bg/A4w+KDzmv0yyUMQSU1w8reayWBXplhbvotUGNoq6fdZb8FGnoG7zdEjeFY hMBAeuQ7GZu9Q== From: Mirsad Goran Todorovac To: Heiner Kallweit , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: nic_swsd@realtek.com, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mirsad Goran Todorovac , Marco Elver Subject: [PATCH v4 3/3] r8169: fix the KCSAN reported data race in rtl_rx while reading desc->opts1 Date: Wed, 18 Oct 2023 21:34:38 +0200 Message-Id: <20231018193434.344176-3-mirsad.todorovac@alu.unizg.hr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018193434.344176-1-mirsad.todorovac@alu.unizg.hr> References: <20231018193434.344176-1-mirsad.todorovac@alu.unizg.hr> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 18 Oct 2023 12:40:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780123481732771518 X-GMAIL-MSGID: 1780123481732771518 KCSAN reported the following data-race bug: ================================================================== BUG: KCSAN: data-race in rtl8169_poll (drivers/net/ethernet/realtek/r8169_main.c:4430 drivers/net/ethernet/realtek/r8169_main.c:4583) r8169 race at unknown origin, with read to 0xffff888117e43510 of 4 bytes by interrupt on cpu 21: rtl8169_poll (drivers/net/ethernet/realtek/r8169_main.c:4430 drivers/net/ethernet/realtek/r8169_main.c:4583) r8169 __napi_poll (net/core/dev.c:6527) net_rx_action (net/core/dev.c:6596 net/core/dev.c:6727) __do_softirq (kernel/softirq.c:553) __irq_exit_rcu (kernel/softirq.c:427 kernel/softirq.c:632) irq_exit_rcu (kernel/softirq.c:647) sysvec_apic_timer_interrupt (arch/x86/kernel/apic/apic.c:1074 (discriminator 14)) asm_sysvec_apic_timer_interrupt (./arch/x86/include/asm/idtentry.h:645) cpuidle_enter_state (drivers/cpuidle/cpuidle.c:291) cpuidle_enter (drivers/cpuidle/cpuidle.c:390) call_cpuidle (kernel/sched/idle.c:135) do_idle (kernel/sched/idle.c:219 kernel/sched/idle.c:282) cpu_startup_entry (kernel/sched/idle.c:378 (discriminator 1)) start_secondary (arch/x86/kernel/smpboot.c:210 arch/x86/kernel/smpboot.c:294) secondary_startup_64_no_verify (arch/x86/kernel/head_64.S:433) value changed: 0x80003fff -> 0x3402805f Reported by Kernel Concurrency Sanitizer on: CPU: 21 PID: 0 Comm: swapper/21 Tainted: G L 6.6.0-rc2-kcsan-00143-gb5cbe7c00aa0 #41 Hardware name: ASRock X670E PG Lightning/X670E PG Lightning, BIOS 1.21 04/26/2023 ================================================================== drivers/net/ethernet/realtek/r8169_main.c: ========================================== 4429 → 4430 status = le32_to_cpu(desc->opts1); 4431 if (status & DescOwn) 4432 break; 4433 4434 /* This barrier is needed to keep us from reading 4435 * any other fields out of the Rx descriptor until 4436 * we know the status of DescOwn 4437 */ 4438 dma_rmb(); 4439 4440 if (unlikely(status & RxRES)) { 4441 if (net_ratelimit()) 4442 netdev_warn(dev, "Rx ERROR. status = %08x\n", Marco Elver explained that dma_rmb() doesn't prevent the compiler to tear up the access to desc->opts1 which can be written to concurrently. READ_ONCE() should prevent that from happening: 4429 → 4430 status = le32_to_cpu(READ_ONCE(desc->opts1)); 4431 if (status & DescOwn) 4432 break; 4433 As the consequence of this fix, this KCSAN warning was eliminated. Fixes: 6202806e7c03a ("r8169: drop member opts1_mask from struct rtl8169_private") Suggested-by: Marco Elver Cc: Heiner Kallweit Cc: nic_swsd@realtek.com Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Link: https://lore.kernel.org/lkml/dc7fc8fa-4ea4-e9a9-30a6-7c83e6b53188@alu.unizg.hr/ Signed-off-by: Mirsad Goran Todorovac Acked-by: Marco Elver Reviewed-by: Simon Horman --- v4: fixed the Fixes: tag for 2/3. v3: fixed the Fixes: tag for 3/3. v2: fixed double Signed-off-by: tag drivers/net/ethernet/realtek/r8169_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 281aaa851847..81be6085a480 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4427,7 +4427,7 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, int budget dma_addr_t addr; u32 status; - status = le32_to_cpu(desc->opts1); + status = le32_to_cpu(READ_ONCE(desc->opts1)); if (status & DescOwn) break;