linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* pull-request: can 2021-07-24
@ 2021-07-24 17:19 Marc Kleine-Budde
  2021-07-24 17:19 ` [net 1/6] arm64: dts: imx8mp: remove fallback compatible string for FlexCAN Marc Kleine-Budde
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2021-07-24 17:19 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel

Hello Jakub, hello David,

this is a pull request of 6 patches for net/master.

The first patch is by Joakim Zhang targets the imx8mp device tree. It
removes the imx6 fallback from the flexcan binding, as the imx6 is not
compatible with the imx8mp.

Ziyang Xuan contributes a patch to fix a use-after-free in the CAN
raw's raw_setsockopt().

The next two patches target the CAN J1939 protocol. The first one is
by Oleksij Rempel and clarifies the lifetime of session object in
j1939_session_deactivate(). Zhang Changzhong's patch fixes the timeout
value between consecutive TP.DT.

Stephane Grosjean contributes a patch for the peak_usb driver to fix
reading of the rxerr/txerr values.

The last patch is by me for the mcp251xfd driver. It stops the
timestamp worker in case of a fatal error in the IRQ handler.

regards,
Marc

---

The following changes since commit 5aa1959d18003472cc741dc490c3335c5bd804e2:

  Merge branch 'ionic-fixes' (2021-07-23 21:57:52 +0100)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git tags/linux-can-fixes-for-5.14-20210724

for you to fetch changes up to ef68a717960658e6a1e5f08adb0574326e9a12c2:

  can: mcp251xfd: mcp251xfd_irq(): stop timestamping worker in case error in IRQ (2021-07-24 19:02:32 +0200)

----------------------------------------------------------------
linux-can-fixes-for-5.14-20210724

----------------------------------------------------------------
Joakim Zhang (1):
      arm64: dts: imx8mp: remove fallback compatible string for FlexCAN

Marc Kleine-Budde (1):
      can: mcp251xfd: mcp251xfd_irq(): stop timestamping worker in case error in IRQ

Oleksij Rempel (1):
      can: j1939: j1939_session_deactivate(): clarify lifetime of session object

Stephane Grosjean (1):
      can: peak_usb: pcan_usb_handle_bus_evt(): fix reading rxerr/txerr values

Zhang Changzhong (1):
      can: j1939: j1939_xtp_rx_dat_one(): fix rxtimer value between consecutive TP.DT to 750ms

Ziyang Xuan (1):
      can: raw: raw_setsockopt(): fix raw_rcv panic for sock UAF

 arch/arm64/boot/dts/freescale/imx8mp.dtsi      |  4 ++--
 drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c |  1 +
 drivers/net/can/usb/peak_usb/pcan_usb.c        | 10 ++++++----
 net/can/j1939/transport.c                      | 11 ++++++++---
 net/can/raw.c                                  | 20 ++++++++++++++++++--
 5 files changed, 35 insertions(+), 11 deletions(-)



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [net 1/6] arm64: dts: imx8mp: remove fallback compatible string for FlexCAN
  2021-07-24 17:19 pull-request: can 2021-07-24 Marc Kleine-Budde
@ 2021-07-24 17:19 ` Marc Kleine-Budde
  2021-07-24 17:19 ` [net 2/6] can: raw: raw_setsockopt(): fix raw_rcv panic for sock UAF Marc Kleine-Budde
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2021-07-24 17:19 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Joakim Zhang, Fabio Estevam,
	Marc Kleine-Budde

From: Joakim Zhang <qiangqing.zhang@nxp.com>

FlexCAN on i.MX8MP is not derived from i.MX6Q, instead reuses from
i.MX8QM with extra ECC added and default is enabled, so that the FlexCAN
would be put into freeze mode without FLEXCAN_QUIRK_DISABLE_MECR quirk.

This patch removes "fsl,imx6q-flexcan" fallback compatible string since
it's not compatible with the i.MX6Q.

Link: https://lore.kernel.org/r/20210719073437.32078-1-qiangqing.zhang@nxp.com
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/arm64/boot/dts/freescale/imx8mp.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mp.dtsi b/arch/arm64/boot/dts/freescale/imx8mp.dtsi
index ca38d0d6c3c4..f4eaab3ecf03 100644
--- a/arch/arm64/boot/dts/freescale/imx8mp.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mp.dtsi
@@ -579,7 +579,7 @@ uart2: serial@30890000 {
 			};
 
 			flexcan1: can@308c0000 {
-				compatible = "fsl,imx8mp-flexcan", "fsl,imx6q-flexcan";
+				compatible = "fsl,imx8mp-flexcan";
 				reg = <0x308c0000 0x10000>;
 				interrupts = <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>;
 				clocks = <&clk IMX8MP_CLK_IPG_ROOT>,
@@ -594,7 +594,7 @@ flexcan1: can@308c0000 {
 			};
 
 			flexcan2: can@308d0000 {
-				compatible = "fsl,imx8mp-flexcan", "fsl,imx6q-flexcan";
+				compatible = "fsl,imx8mp-flexcan";
 				reg = <0x308d0000 0x10000>;
 				interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>;
 				clocks = <&clk IMX8MP_CLK_IPG_ROOT>,

base-commit: 5aa1959d18003472cc741dc490c3335c5bd804e2
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [net 2/6] can: raw: raw_setsockopt(): fix raw_rcv panic for sock UAF
  2021-07-24 17:19 pull-request: can 2021-07-24 Marc Kleine-Budde
  2021-07-24 17:19 ` [net 1/6] arm64: dts: imx8mp: remove fallback compatible string for FlexCAN Marc Kleine-Budde
@ 2021-07-24 17:19 ` Marc Kleine-Budde
  2021-07-24 17:19 ` [net 3/6] can: j1939: j1939_session_deactivate(): clarify lifetime of session object Marc Kleine-Budde
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2021-07-24 17:19 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Ziyang Xuan, linux-stable,
	Oliver Hartkopp, Marc Kleine-Budde

From: Ziyang Xuan <william.xuanziyang@huawei.com>

We get a bug during ltp can_filter test as following.

===========================================
[60919.264984] BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
[60919.265223] PGD 8000003dda726067 P4D 8000003dda726067 PUD 3dda727067 PMD 0
[60919.265443] Oops: 0000 [#1] SMP PTI
[60919.265550] CPU: 30 PID: 3638365 Comm: can_filter Kdump: loaded Tainted: G        W         4.19.90+ #1
[60919.266068] RIP: 0010:selinux_socket_sock_rcv_skb+0x3e/0x200
[60919.293289] RSP: 0018:ffff8d53bfc03cf8 EFLAGS: 00010246
[60919.307140] RAX: 0000000000000000 RBX: 000000000000001d RCX: 0000000000000007
[60919.320756] RDX: 0000000000000001 RSI: ffff8d5104a8ed00 RDI: ffff8d53bfc03d30
[60919.334319] RBP: ffff8d9338056800 R08: ffff8d53bfc29d80 R09: 0000000000000001
[60919.347969] R10: ffff8d53bfc03ec0 R11: ffffb8526ef47c98 R12: ffff8d53bfc03d30
[60919.350320] perf: interrupt took too long (3063 > 2500), lowering kernel.perf_event_max_sample_rate to 65000
[60919.361148] R13: 0000000000000001 R14: ffff8d53bcf90000 R15: 0000000000000000
[60919.361151] FS:  00007fb78b6b3600(0000) GS:ffff8d53bfc00000(0000) knlGS:0000000000000000
[60919.400812] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[60919.413730] CR2: 0000000000000010 CR3: 0000003e3f784006 CR4: 00000000007606e0
[60919.426479] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[60919.439339] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[60919.451608] PKRU: 55555554
[60919.463622] Call Trace:
[60919.475617]  <IRQ>
[60919.487122]  ? update_load_avg+0x89/0x5d0
[60919.498478]  ? update_load_avg+0x89/0x5d0
[60919.509822]  ? account_entity_enqueue+0xc5/0xf0
[60919.520709]  security_sock_rcv_skb+0x2a/0x40
[60919.531413]  sk_filter_trim_cap+0x47/0x1b0
[60919.542178]  ? kmem_cache_alloc+0x38/0x1b0
[60919.552444]  sock_queue_rcv_skb+0x17/0x30
[60919.562477]  raw_rcv+0x110/0x190 [can_raw]
[60919.572539]  can_rcv_filter+0xbc/0x1b0 [can]
[60919.582173]  can_receive+0x6b/0xb0 [can]
[60919.591595]  can_rcv+0x31/0x70 [can]
[60919.600783]  __netif_receive_skb_one_core+0x5a/0x80
[60919.609864]  process_backlog+0x9b/0x150
[60919.618691]  net_rx_action+0x156/0x400
[60919.627310]  ? sched_clock_cpu+0xc/0xa0
[60919.635714]  __do_softirq+0xe8/0x2e9
[60919.644161]  do_softirq_own_stack+0x2a/0x40
[60919.652154]  </IRQ>
[60919.659899]  do_softirq.part.17+0x4f/0x60
[60919.667475]  __local_bh_enable_ip+0x60/0x70
[60919.675089]  __dev_queue_xmit+0x539/0x920
[60919.682267]  ? finish_wait+0x80/0x80
[60919.689218]  ? finish_wait+0x80/0x80
[60919.695886]  ? sock_alloc_send_pskb+0x211/0x230
[60919.702395]  ? can_send+0xe5/0x1f0 [can]
[60919.708882]  can_send+0xe5/0x1f0 [can]
[60919.715037]  raw_sendmsg+0x16d/0x268 [can_raw]

It's because raw_setsockopt() concurrently with
unregister_netdevice_many(). Concurrent scenario as following.

	cpu0						cpu1
raw_bind
raw_setsockopt					unregister_netdevice_many
						unlist_netdevice
dev_get_by_index				raw_notifier
raw_enable_filters				......
can_rx_register
can_rcv_list_find(..., net->can.rx_alldev_list)

......

sock_close
raw_release(sock_a)

......

can_receive
can_rcv_filter(net->can.rx_alldev_list, ...)
raw_rcv(skb, sock_a)
BUG

After unlist_netdevice(), dev_get_by_index() return NULL in
raw_setsockopt(). Function raw_enable_filters() will add sock
and can_filter to net->can.rx_alldev_list. Then the sock is closed.
Followed by, we sock_sendmsg() to a new vcan device use the same
can_filter. Protocol stack match the old receiver whose sock has
been released on net->can.rx_alldev_list in can_rcv_filter().
Function raw_rcv() uses the freed sock. UAF BUG is triggered.

We can find that the key issue is that net_device has not been
protected in raw_setsockopt(). Use rtnl_lock to protect net_device
in raw_setsockopt().

Fixes: c18ce101f2e4 ("[CAN]: Add raw protocol")
Link: https://lore.kernel.org/r/20210722070819.1048263-1-william.xuanziyang@huawei.com
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 net/can/raw.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/net/can/raw.c b/net/can/raw.c
index ed4fcb7ab0c3..cd5a49380116 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -546,10 +546,18 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
 				return -EFAULT;
 		}
 
+		rtnl_lock();
 		lock_sock(sk);
 
-		if (ro->bound && ro->ifindex)
+		if (ro->bound && ro->ifindex) {
 			dev = dev_get_by_index(sock_net(sk), ro->ifindex);
+			if (!dev) {
+				if (count > 1)
+					kfree(filter);
+				err = -ENODEV;
+				goto out_fil;
+			}
+		}
 
 		if (ro->bound) {
 			/* (try to) register the new filters */
@@ -588,6 +596,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
 			dev_put(dev);
 
 		release_sock(sk);
+		rtnl_unlock();
 
 		break;
 
@@ -600,10 +609,16 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
 
 		err_mask &= CAN_ERR_MASK;
 
+		rtnl_lock();
 		lock_sock(sk);
 
-		if (ro->bound && ro->ifindex)
+		if (ro->bound && ro->ifindex) {
 			dev = dev_get_by_index(sock_net(sk), ro->ifindex);
+			if (!dev) {
+				err = -ENODEV;
+				goto out_err;
+			}
+		}
 
 		/* remove current error mask */
 		if (ro->bound) {
@@ -627,6 +642,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
 			dev_put(dev);
 
 		release_sock(sk);
+		rtnl_unlock();
 
 		break;
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [net 3/6] can: j1939: j1939_session_deactivate(): clarify lifetime of session object
  2021-07-24 17:19 pull-request: can 2021-07-24 Marc Kleine-Budde
  2021-07-24 17:19 ` [net 1/6] arm64: dts: imx8mp: remove fallback compatible string for FlexCAN Marc Kleine-Budde
  2021-07-24 17:19 ` [net 2/6] can: raw: raw_setsockopt(): fix raw_rcv panic for sock UAF Marc Kleine-Budde
@ 2021-07-24 17:19 ` Marc Kleine-Budde
  2021-07-24 17:19 ` [net 4/6] can: j1939: j1939_xtp_rx_dat_one(): fix rxtimer value between consecutive TP.DT to 750ms Marc Kleine-Budde
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2021-07-24 17:19 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Oleksij Rempel, Xiaochen Zou,
	Marc Kleine-Budde

From: Oleksij Rempel <o.rempel@pengutronix.de>

The j1939_session_deactivate() is decrementing the session ref-count and
potentially can free() the session. This would cause use-after-free
situation.

However, the code calling j1939_session_deactivate() does always hold
another reference to the session, so that it would not be free()ed in
this code path.

This patch adds a comment to make this clear and a WARN_ON, to ensure
that future changes will not violate this requirement. Further this
patch avoids dereferencing the session pointer as a precaution to avoid
use-after-free if the session is actually free()ed.

Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Link: https://lore.kernel.org/r/20210714111602.24021-1-o.rempel@pengutronix.de
Reported-by: Xiaochen Zou <xzou017@ucr.edu>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 net/can/j1939/transport.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index c3946c355882..bb1092c3e7e3 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -1075,11 +1075,16 @@ static bool j1939_session_deactivate_locked(struct j1939_session *session)
 
 static bool j1939_session_deactivate(struct j1939_session *session)
 {
+	struct j1939_priv *priv = session->priv;
 	bool active;
 
-	j1939_session_list_lock(session->priv);
+	j1939_session_list_lock(priv);
+	/* This function should be called with a session ref-count of at
+	 * least 2.
+	 */
+	WARN_ON_ONCE(kref_read(&session->kref) < 2);
 	active = j1939_session_deactivate_locked(session);
-	j1939_session_list_unlock(session->priv);
+	j1939_session_list_unlock(priv);
 
 	return active;
 }
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [net 4/6] can: j1939: j1939_xtp_rx_dat_one(): fix rxtimer value between consecutive TP.DT to 750ms
  2021-07-24 17:19 pull-request: can 2021-07-24 Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2021-07-24 17:19 ` [net 3/6] can: j1939: j1939_session_deactivate(): clarify lifetime of session object Marc Kleine-Budde
@ 2021-07-24 17:19 ` Marc Kleine-Budde
  2021-07-24 17:19 ` [net 5/6] can: peak_usb: pcan_usb_handle_bus_evt(): fix reading rxerr/txerr values Marc Kleine-Budde
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2021-07-24 17:19 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Zhang Changzhong, linux-stable,
	Oleksij Rempel, Marc Kleine-Budde

From: Zhang Changzhong <zhangchangzhong@huawei.com>

For receive side, the max time interval between two consecutive TP.DT
should be 750ms.

Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Link: https://lore.kernel.org/r/1625569210-47506-1-git-send-email-zhangchangzhong@huawei.com
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 net/can/j1939/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index bb1092c3e7e3..bdc95bd7a851 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -1874,7 +1874,7 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session,
 		if (!session->transmission)
 			j1939_tp_schedule_txtimer(session, 0);
 	} else {
-		j1939_tp_set_rxtimeout(session, 250);
+		j1939_tp_set_rxtimeout(session, 750);
 	}
 	session->last_cmd = 0xff;
 	consume_skb(se_skb);
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [net 5/6] can: peak_usb: pcan_usb_handle_bus_evt(): fix reading rxerr/txerr values
  2021-07-24 17:19 pull-request: can 2021-07-24 Marc Kleine-Budde
                   ` (3 preceding siblings ...)
  2021-07-24 17:19 ` [net 4/6] can: j1939: j1939_xtp_rx_dat_one(): fix rxtimer value between consecutive TP.DT to 750ms Marc Kleine-Budde
@ 2021-07-24 17:19 ` Marc Kleine-Budde
  2021-07-24 17:19 ` [net 6/6] can: mcp251xfd: mcp251xfd_irq(): stop timestamping worker in case error in IRQ Marc Kleine-Budde
  2021-07-24 18:40 ` pull-request: can 2021-07-24 patchwork-bot+netdevbpf
  6 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2021-07-24 17:19 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Stephane Grosjean, linux-stable,
	Marc Kleine-Budde

From: Stephane Grosjean <s.grosjean@peak-system.com>

This patch fixes an incorrect way of reading error counters in messages
received for this purpose from the PCAN-USB interface. These messages
inform about the increase or decrease of the error counters, whose values
are placed in bytes 1 and 2 of the message data (not 0 and 1).

Fixes: ea8b33bde76c ("can: pcan_usb: add support of rxerr/txerr counters")
Link: https://lore.kernel.org/r/20210625130931.27438-4-s.grosjean@peak-system.com
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/peak_usb/pcan_usb.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
index 1d6f77252f01..899a3d21b77f 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
@@ -117,7 +117,8 @@
 #define PCAN_USB_BERR_MASK	(PCAN_USB_ERR_RXERR | PCAN_USB_ERR_TXERR)
 
 /* identify bus event packets with rx/tx error counters */
-#define PCAN_USB_ERR_CNT		0x80
+#define PCAN_USB_ERR_CNT_DEC		0x00	/* counters are decreasing */
+#define PCAN_USB_ERR_CNT_INC		0x80	/* counters are increasing */
 
 /* private to PCAN-USB adapter */
 struct pcan_usb {
@@ -608,11 +609,12 @@ static int pcan_usb_handle_bus_evt(struct pcan_usb_msg_context *mc, u8 ir)
 
 	/* acccording to the content of the packet */
 	switch (ir) {
-	case PCAN_USB_ERR_CNT:
+	case PCAN_USB_ERR_CNT_DEC:
+	case PCAN_USB_ERR_CNT_INC:
 
 		/* save rx/tx error counters from in the device context */
-		pdev->bec.rxerr = mc->ptr[0];
-		pdev->bec.txerr = mc->ptr[1];
+		pdev->bec.rxerr = mc->ptr[1];
+		pdev->bec.txerr = mc->ptr[2];
 		break;
 
 	default:
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [net 6/6] can: mcp251xfd: mcp251xfd_irq(): stop timestamping worker in case error in IRQ
  2021-07-24 17:19 pull-request: can 2021-07-24 Marc Kleine-Budde
                   ` (4 preceding siblings ...)
  2021-07-24 17:19 ` [net 5/6] can: peak_usb: pcan_usb_handle_bus_evt(): fix reading rxerr/txerr values Marc Kleine-Budde
@ 2021-07-24 17:19 ` Marc Kleine-Budde
  2021-07-24 18:40 ` pull-request: can 2021-07-24 patchwork-bot+netdevbpf
  6 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2021-07-24 17:19 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Marc Kleine-Budde

In case an error occurred in the IRQ handler, the chip status is
dumped via devcoredump and all IRQs are disabled, but the chip stays
powered for further analysis.

The chip is in an undefined state and will not receive any CAN frames,
so shut down the timestamping worker, which reads the TBC register
regularly, too. This avoids any CRC read error messages if there is a
communication problem with the chip.

Fixes: efd8d98dfb90 ("can: mcp251xfd: add HW timestamp infrastructure")
Link: https://lore.kernel.org/r/20210724155131.471303-1-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
index 47c3f408a799..9ae48072b6c6 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
@@ -2300,6 +2300,7 @@ static irqreturn_t mcp251xfd_irq(int irq, void *dev_id)
 		   err, priv->regs_status.intf);
 	mcp251xfd_dump(priv);
 	mcp251xfd_chip_interrupts_disable(priv);
+	mcp251xfd_timestamp_stop(priv);
 
 	return handled;
 }
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: pull-request: can 2021-07-24
  2021-07-24 17:19 pull-request: can 2021-07-24 Marc Kleine-Budde
                   ` (5 preceding siblings ...)
  2021-07-24 17:19 ` [net 6/6] can: mcp251xfd: mcp251xfd_irq(): stop timestamping worker in case error in IRQ Marc Kleine-Budde
@ 2021-07-24 18:40 ` patchwork-bot+netdevbpf
  6 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-07-24 18:40 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: netdev, davem, kuba, linux-can, kernel

Hello:

This pull request was applied to netdev/net.git (refs/heads/master):

On Sat, 24 Jul 2021 19:19:41 +0200 you wrote:
> Hello Jakub, hello David,
> 
> this is a pull request of 6 patches for net/master.
> 
> The first patch is by Joakim Zhang targets the imx8mp device tree. It
> removes the imx6 fallback from the flexcan binding, as the imx6 is not
> compatible with the imx8mp.
> 
> [...]

Here is the summary with links:
  - pull-request: can 2021-07-24
    https://git.kernel.org/netdev/net/c/e394f1e3b139
  - [net,2/6] can: raw: raw_setsockopt(): fix raw_rcv panic for sock UAF
    https://git.kernel.org/netdev/net/c/54f93336d000
  - [net,3/6] can: j1939: j1939_session_deactivate(): clarify lifetime of session object
    https://git.kernel.org/netdev/net/c/0c71437dd50d
  - [net,4/6] can: j1939: j1939_xtp_rx_dat_one(): fix rxtimer value between consecutive TP.DT to 750ms
    https://git.kernel.org/netdev/net/c/c6eea1c8bda5
  - [net,5/6] can: peak_usb: pcan_usb_handle_bus_evt(): fix reading rxerr/txerr values
    https://git.kernel.org/netdev/net/c/590eb2b7d8cf
  - [net,6/6] can: mcp251xfd: mcp251xfd_irq(): stop timestamping worker in case error in IRQ
    https://git.kernel.org/netdev/net/c/ef68a7179606

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-07-24 18:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-24 17:19 pull-request: can 2021-07-24 Marc Kleine-Budde
2021-07-24 17:19 ` [net 1/6] arm64: dts: imx8mp: remove fallback compatible string for FlexCAN Marc Kleine-Budde
2021-07-24 17:19 ` [net 2/6] can: raw: raw_setsockopt(): fix raw_rcv panic for sock UAF Marc Kleine-Budde
2021-07-24 17:19 ` [net 3/6] can: j1939: j1939_session_deactivate(): clarify lifetime of session object Marc Kleine-Budde
2021-07-24 17:19 ` [net 4/6] can: j1939: j1939_xtp_rx_dat_one(): fix rxtimer value between consecutive TP.DT to 750ms Marc Kleine-Budde
2021-07-24 17:19 ` [net 5/6] can: peak_usb: pcan_usb_handle_bus_evt(): fix reading rxerr/txerr values Marc Kleine-Budde
2021-07-24 17:19 ` [net 6/6] can: mcp251xfd: mcp251xfd_irq(): stop timestamping worker in case error in IRQ Marc Kleine-Budde
2021-07-24 18:40 ` pull-request: can 2021-07-24 patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).