| Message ID | 20241122221650.633981-5-dario.binacchi@amarulasolutions.com |
|---|---|
| State | New |
| Headers |
Return-Path:
<linux-amarula+bncBCQ4XFG47UFRBXEFQS5AMGQEQMHAVDQ@amarulasolutions.com>
X-Original-To: linux-amarula@patchwork.amarulasolutions.com
Delivered-To: linux-amarula@patchwork.amarulasolutions.com
Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com
[209.85.218.71])
by ganimede.amarulasolutions.com (Postfix) with ESMTPS id A5A2741386
for <linux-amarula@patchwork.amarulasolutions.com>;
Fri, 22 Nov 2024 23:17:01 +0100 (CET)
Received: by mail-ej1-f71.google.com with SMTP id
a640c23a62f3a-a9a1828916fsf247928666b.1
for <linux-amarula@patchwork.amarulasolutions.com>;
Fri, 22 Nov 2024 14:17:01 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1732313821; cv=pass;
d=google.com; s=arc-20240605;
b=Gcn1gpoARMbZ6kMptvb9BAn6PWpPermc/McI1we1gFD52TnFi+qn+n3duwoF6izJsg
Y4qhW0r/olnGkzjIpqHLbhkOHH1hvKZDIo/jaOYeRnhSD80+PihKvxVmChg3k1rksGQm
FNxOrqU/f6NqFsiDBknuHGfm0o6CiL23BIoNEWOps4YgxJ+hI6GZ6x3dCZDj6UeakoVy
vMjvNUMZvp4IaGkbX+Xt3yRNqB5pXxju9FHhdeC19JL4KATaCmFucKul1XV8rS+9NAOp
eqDLqqBKJBkdr06TGPcYzse4wqLBxNndh/CI2HlgfZOvwZh2ieiurZjtEI4AZsBoZ4Tc
ysIw==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20240605;
h=list-unsubscribe:list-archive:list-help:list-post:list-id
:mailing-list:precedence:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:dkim-signature;
bh=1c9RRYwt4bj0NCA3zcD5i9or13Ue5jmCo7cVGZSfabI=;
fh=BKG6yJ5RakZz8QWcqBUY5DK/fAKdPITDXQbmZPppJKA=;
b=lspAz3Bqxti6QFocrXevqu7f6yYha76llgoq2YMiXdeS1x+D0fW19BsNpx+UZ3wU33
Xq18K5KvE8A+6Fb30biKy0247zPbIVJBDcmcMxvU/cl9hxIjfaP9F8rXSTuhuut6he4i
Yvgn5Ggmu54tn8PEQuSH5linGonJJX/4Pn8HTXdbRXen3YqLacfxmZbJXWZ/dneiq8Dh
7CXJiiNSMWyY1NchWGmak/QSxSuUZ2RWxHUVSfxxZMaDEMVbqBAvhLelIf73wf/J6Z1l
rsxYP5499fIZw8fM52+aSd4HLgoJ5dsep528cSzeTYPgdLUvCA+j9+n7zBy/RTsoIXPI
ITqw==;
darn=patchwork.amarulasolutions.com
ARC-Authentication-Results: i=2; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b="mgTJk7/3";
spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender)
smtp.mailfrom=dario.binacchi@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=pass header.i=@amarulasolutions.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=amarulasolutions.com; s=google; t=1732313821; x=1732918621;
darn=patchwork.amarulasolutions.com;
h=list-unsubscribe:list-archive:list-help:list-post:list-id
:mailing-list:precedence:x-original-authentication-results
:x-original-sender:mime-version:references:in-reply-to:message-id
:date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;
bh=1c9RRYwt4bj0NCA3zcD5i9or13Ue5jmCo7cVGZSfabI=;
b=OURcvr7bZd8HdprQscvtZZiptzv7dVcWrg7MDG2aTrbc/qpT4/qF+TW41RQvxzcHR5
sFaxexRUXW8XMlkshiYCZKjtageUORFlfJq1ARodLaf5bvvqJqkbxwH2cPShpim4mirR
m7H3+kfIqkNhvgfp/I3DGzLlp1BsC2xoy3KCE=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1732313821; x=1732918621;
h=list-unsubscribe:list-archive:list-help:list-post
:x-spam-checked-in-group:list-id:mailing-list:precedence
:x-original-authentication-results:x-original-sender:mime-version
:references:in-reply-to:message-id:date:subject:cc:to:from
:x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=1c9RRYwt4bj0NCA3zcD5i9or13Ue5jmCo7cVGZSfabI=;
b=CHHRdlD6l/z1L5XkDLu49wjpV7wqbVX44XcKJSagA/r0EzJ7JkBHai4vpy7jiIvi+/
ATmm3sZ4ZUDFaeVATKXD2vOABKKjSAdDKYdsMhzJYReV68k6+x/6iL8w6MxRn8wyD1LX
dSkXP+zXgNSrLzzu1AyhvMw2hA/zk5Kgo+FE+qaJPFtTlIIqi6uPsBv2g2bEycXV6RoP
FMdZqJEqFqxjlHohvAST2xYQ5ji4m4ybfLoUG6eN2ugjFPxT2zR77k9u613s6O4UAzKR
/pvXi3eX7oThKIUEkMNyYmBTkOduvHTvSmwQ8KGSBis9T7i/2xFFn0V4gnsR1293JGom
tdCg==
X-Forwarded-Encrypted: i=2;
AJvYcCVh97uSMKneUsGAzoRCSB+2/GkDxzpfbTw6uLKjQoBKAfN9mBrWjJ3q3jFsgPgpNwjK30ZR2VUbiRm32zab@patchwork.amarulasolutions.com
X-Gm-Message-State: AOJu0YyDWlTaMRLqyvTXE5cNsbP2kWwVrywKatf66GCxhTvsefozrE5r
rPEBE1kWbo0fioidTROua2ui5lUy8EDDApt/hbA/8wiffG7AZ2rBL37S+HK0A2Q3mQ==
X-Google-Smtp-Source:
AGHT+IEYju3lqe1JldjnXm9CIBTLMfUkPoE0oOMZvO6HLx7hjKhSpb6HeoRvNTkcLcG9OErd2ZwN+A==
X-Received: by 2002:a17:906:4fd4:b0:aa4:cd1e:c91b with SMTP id
a640c23a62f3a-aa4ef969ef9mr970272266b.7.1732313821105;
Fri, 22 Nov 2024 14:17:01 -0800 (PST)
X-BeenThere: linux-amarula@amarulasolutions.com
Received: by 2002:a50:9f2c:0:b0:5cf:e18c:1d60 with SMTP id
4fb4d7f45d1cf-5d007e33dc7ls549784a12.1.-pod-prod-00-eu;
Fri, 22 Nov 2024 14:16:59 -0800 (PST)
X-Received: by 2002:a05:6402:34c7:b0:5d0:292c:1fc5 with SMTP id
4fb4d7f45d1cf-5d0292c202bmr3227919a12.13.1732313819279;
Fri, 22 Nov 2024 14:16:59 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1732313819; cv=none;
d=google.com; s=arc-20240605;
b=MkhMPGyS+yvFFp1RLj0Kz5GcainwTsLb+OXtMVDjAiuivK1GAsON0s3wzGgC4ceecv
JQU576wP6Hbc8MSukMHWKNysc8fu/tbHzPACLN0nBbNjK5GbvEglzZQl+4jzaFh1BdO4
z6EtIC39jx4CZigwRcRnq2MBqHRMVdJnulDb2JEHA3HQhhS4GzqG+W48YklAmYuU5KkO
YgmmklCCqfQ6rRy3JH9sMvZ2hmrz+FNRnVaZtCZ/cLpeTOkrts/UCP8CRiNRkmjnug6V
Vwj1mNZAwArKUCX6k3mP7NRX8DhRyEXGhYNB3LTaC48qRHryxspnD0iSDfMane0lC1Sh
4KUw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20240605;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:dkim-signature;
bh=yJP+d2oKTX52rq2v9NzXxSt1l/2jtdXfEIdax2O5les=;
fh=KPqUMTZ6D0oyaiGhwn0WF7Qj0FpxJTNWmT+VH7msReo=;
b=Z1bXWq0IxZVVsPqT+uxLH6z+/XUkxTD1eC97qabRjRVnuf5dQ0P90NwlpHCD8otEMQ
TtpJDrc6PUuUSrAbbYCrqxGSZlk5qBdWC7GbubTJO5YybB1UEsSgax2QcOh64SqEX79Y
i8ufBDZNkF7ImU5GDH6C+HMRZ8zcxPCTMyLQ+JP1mLEwYChiBUh1iObBD98kKTwe2aAk
jCvegzIahuu+XFDlVrBwR0G2qBuavl91W04zQ5dAeAX1rBJ/Pk+CLoqB38EKqhGIcUHh
3X82lj2mvH134BDJT547LfljEC0eGWkpNNMQZ0jcYgR2c/TCveTMbca0c5lU6xhPXDyQ
yVQQ==;
dara=google.com
ARC-Authentication-Results: i=1; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b="mgTJk7/3";
spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender)
smtp.mailfrom=dario.binacchi@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=pass header.i=@amarulasolutions.com
Received: from mail-sor-f41.google.com (mail-sor-f41.google.com.
[209.85.220.41])
by mx.google.com with SMTPS id
4fb4d7f45d1cf-5d01db4913bsor1652218a12.5.2024.11.22.14.16.59
for <linux-amarula@amarulasolutions.com>
(Google Transport Security);
Fri, 22 Nov 2024 14:16:59 -0800 (PST)
Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Gm-Gg: ASbGncuQ+lfoImTqKtqOwP3P22rm5NP6PkQeC8hsgGaX+7aZFR6UE5+2ybP4FP/nf+8
8HIvivWuGzUwb8ftyExvDebNN1SVmiy11UfPOhuMqfEYByrsm0FArCVqBNrlVEa8mPXTtitaT6M
mnPkZ0n3QnURzzsCSl8uf8Ek1uclWjdqN9srdXx0jFwey4bhaX0jBX2JAVgFanLIPTEDX3jTVJI
4lg/tF5J+odtq80BZB+O4cJI8VBHBdn331t7v7FfK7LQmOs84Myp+1xMRiZAd+fZaG80AKzjB6E
fe0sKgjh0iXuEHfQsjmnFRE8sIzhLl4ESKYZOKTtAReUqr5G6WrSBQD5O7IFRWtu/1IP8W6+2xA
aNl06EmwSCa/w9oop
X-Received: by 2002:a05:6402:2554:b0:5d0:ada:e44b with SMTP id
4fb4d7f45d1cf-5d01d57df0emr4922820a12.16.1732313818928;
Fri, 22 Nov 2024 14:16:58 -0800 (PST)
Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it
(host-82-54-94-193.retail.telecomitalia.it. [82.54.94.193])
by smtp.gmail.com with ESMTPSA id
a640c23a62f3a-aa50b52fcebsm148226466b.127.2024.11.22.14.16.58
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Fri, 22 Nov 2024 14:16:58 -0800 (PST)
From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
To: linux-kernel@vger.kernel.org
Cc: linux-amarula@amarulasolutions.com,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
Marc Kleine-Budde <mkl@pengutronix.de>,
Vincent Mailhol <mailhol.vincent@wanadoo.fr>,
linux-can@vger.kernel.org
Subject: [PATCH v2 04/12] can: hi311x: fix txerr and rxerr reporting
Date: Fri, 22 Nov 2024 23:15:45 +0100
Message-ID: <20241122221650.633981-5-dario.binacchi@amarulasolutions.com>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <20241122221650.633981-1-dario.binacchi@amarulasolutions.com>
References: <20241122221650.633981-1-dario.binacchi@amarulasolutions.com>
MIME-Version: 1.0
X-Original-Sender: dario.binacchi@amarulasolutions.com
X-Original-Authentication-Results: mx.google.com; dkim=pass
header.i=@amarulasolutions.com header.s=google header.b="mgTJk7/3";
spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender)
smtp.mailfrom=dario.binacchi@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=pass header.i=@amarulasolutions.com
Content-Type: text/plain; charset="UTF-8"
Precedence: list
Mailing-list: list linux-amarula@amarulasolutions.com;
contact linux-amarula+owners@amarulasolutions.com
List-ID: <linux-amarula.amarulasolutions.com>
X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com
X-Google-Group-Id: 476853432473
List-Post:
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>,
<mailto:linux-amarula@amarulasolutions.com>
List-Help:
<https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>,
<mailto:linux-amarula+help@amarulasolutions.com>
List-Archive:
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/>
List-Unsubscribe:
<mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>,
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe>
|
| Series |
Fix {rx,tx}_errors CAN statistics
|
|
Commit Message
Dario Binacchi
Nov. 22, 2024, 10:15 p.m. UTC
The commit a22bd630cfff ("can: hi311x: do not report txerr and rxerr
during bus-off") removed the reporting of rxerr and txerr even in case
of correct operation (i. e. not bus-off). The CAN frame is unnecessarily
set since netif_rx() has already been called. The patch fixes the issue
by postponing the netif_rx() call in case of txerr and rxerr reporting.
Fixes: a22bd630cfff ("can: hi311x: do not report txerr and rxerr during bus-off")
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---
Changes in v2:
- Added in v2
drivers/net/can/spi/hi311x.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On 22.11.2024 23:15:45, Dario Binacchi wrote: > The commit a22bd630cfff ("can: hi311x: do not report txerr and rxerr > during bus-off") removed the reporting of rxerr and txerr even in case > of correct operation (i. e. not bus-off). The CAN frame is unnecessarily > set since netif_rx() has already been called. The patch fixes the issue > by postponing the netif_rx() call in case of txerr and rxerr reporting. re-phrased to: can: hi311x: hi3110_can_ist(): fix potential use-after-free The commit a22bd630cfff ("can: hi311x: do not report txerr and rxerr during bus-off") removed the reporting of rxerr and txerr even in case of correct operation (i. e. not bus-off). The error count information added to the CAN frame after netif_rx() is a potential use after free, since there is no guarantee that the skb is in the same state. It might be freed or reused. Fix the issue by postponing the netif_rx() call in case of txerr and rxerr reporting. > Fixes: a22bd630cfff ("can: hi311x: do not report txerr and rxerr during bus-off") > Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> regards, Marc
diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c index 148d974ebb21..b67464df25ff 100644 --- a/drivers/net/can/spi/hi311x.c +++ b/drivers/net/can/spi/hi311x.c @@ -671,9 +671,9 @@ static irqreturn_t hi3110_can_ist(int irq, void *dev_id) tx_state = txerr >= rxerr ? new_state : 0; rx_state = txerr <= rxerr ? new_state : 0; can_change_state(net, cf, tx_state, rx_state); - netif_rx(skb); if (new_state == CAN_STATE_BUS_OFF) { + netif_rx(skb); can_bus_off(net); if (priv->can.restart_ms == 0) { priv->force_quit = 1; @@ -684,6 +684,7 @@ static irqreturn_t hi3110_can_ist(int irq, void *dev_id) cf->can_id |= CAN_ERR_CNT; cf->data[6] = txerr; cf->data[7] = rxerr; + netif_rx(skb); } }