<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/include/linux/can, branch v5.10.178</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.10.178</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.10.178'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2022-12-19T11:27:32Z</updated>
<entry>
<title>can: sja1000: fix size of OCR_MODE_MASK define</title>
<updated>2022-12-19T11:27:32Z</updated>
<author>
<name>Heiko Schocher</name>
<email>hs@denx.de</email>
</author>
<published>2022-11-23T07:16:36Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=683837f2f69d5ebd5e770d5096e3f65c237db4f9'/>
<id>urn:sha1:683837f2f69d5ebd5e770d5096e3f65c237db4f9</id>
<content type='text'>
[ Upstream commit 26e8f6a75248247982458e8237b98c9fb2ffcf9d ]

bitfield mode in ocr register has only 2 bits not 3, so correct
the OCR_MODE_MASK define.

Signed-off-by: Heiko Schocher &lt;hs@denx.de&gt;
Link: https://lore.kernel.org/all/20221123071636.2407823-1-hs@denx.de
Signed-off-by: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>net: introduce CAN specific pointer in the struct net_device</title>
<updated>2021-04-07T13:00:07Z</updated>
<author>
<name>Oleksij Rempel</name>
<email>o.rempel@pengutronix.de</email>
</author>
<published>2021-02-23T07:01:26Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=1a5751d58b14195f763b8c1d9ef33fb8a93e95e7'/>
<id>urn:sha1:1a5751d58b14195f763b8c1d9ef33fb8a93e95e7</id>
<content type='text'>
[ Upstream commit 4e096a18867a5a989b510f6999d9c6b6622e8f7b ]

Since 20dd3850bcf8 ("can: Speed up CAN frame receiption by using
ml_priv") the CAN framework uses per device specific data in the AF_CAN
protocol. For this purpose the struct net_device-&gt;ml_priv is used. Later
the ml_priv usage in CAN was extended for other users, one of them being
CAN_J1939.

Later in the kernel ml_priv was converted to an union, used by other
drivers. E.g. the tun driver started storing it's stats pointer.

Since tun devices can claim to be a CAN device, CAN specific protocols
will wrongly interpret this pointer, which will cause system crashes.
Mostly this issue is visible in the CAN_J1939 stack.

To fix this issue, we request a dedicated CAN pointer within the
net_device struct.

Reported-by: syzbot+5138c4dd15a0401bec7b@syzkaller.appspotmail.com
Fixes: 20dd3850bcf8 ("can: Speed up CAN frame receiption by using ml_priv")
Fixes: ffd956eef69b ("can: introduce CAN midlayer private and allocate it automatically")
Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Fixes: 497a5757ce4e ("tun: switch to net core provided statistics counters")
Signed-off-by: Oleksij Rempel &lt;o.rempel@pengutronix.de&gt;
Link: https://lore.kernel.org/r/20210223070127.4538-1-o.rempel@pengutronix.de
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>can: skb: can_skb_set_owner(): fix ref counting if socket was closed before setting skb ownership</title>
<updated>2021-03-17T16:06:11Z</updated>
<author>
<name>Oleksij Rempel</name>
<email>o.rempel@pengutronix.de</email>
</author>
<published>2021-02-26T09:24:56Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4224890edff1b4679dc8ddeaa69b43efce5366ba'/>
<id>urn:sha1:4224890edff1b4679dc8ddeaa69b43efce5366ba</id>
<content type='text'>
commit e940e0895a82c6fbaa259f2615eb52b57ee91a7e upstream.

There are two ref count variables controlling the free()ing of a socket:
- struct sock::sk_refcnt - which is changed by sock_hold()/sock_put()
- struct sock::sk_wmem_alloc - which accounts the memory allocated by
  the skbs in the send path.

In case there are still TX skbs on the fly and the socket() is closed,
the struct sock::sk_refcnt reaches 0. In the TX-path the CAN stack
clones an "echo" skb, calls sock_hold() on the original socket and
references it. This produces the following back trace:

| WARNING: CPU: 0 PID: 280 at lib/refcount.c:25 refcount_warn_saturate+0x114/0x134
| refcount_t: addition on 0; use-after-free.
| Modules linked in: coda_vpu(E) v4l2_jpeg(E) videobuf2_vmalloc(E) imx_vdoa(E)
| CPU: 0 PID: 280 Comm: test_can.sh Tainted: G            E     5.11.0-04577-gf8ff6603c617 #203
| Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
| Backtrace:
| [&lt;80bafea4&gt;] (dump_backtrace) from [&lt;80bb0280&gt;] (show_stack+0x20/0x24) r7:00000000 r6:600f0113 r5:00000000 r4:81441220
| [&lt;80bb0260&gt;] (show_stack) from [&lt;80bb593c&gt;] (dump_stack+0xa0/0xc8)
| [&lt;80bb589c&gt;] (dump_stack) from [&lt;8012b268&gt;] (__warn+0xd4/0x114) r9:00000019 r8:80f4a8c2 r7:83e4150c r6:00000000 r5:00000009 r4:80528f90
| [&lt;8012b194&gt;] (__warn) from [&lt;80bb09c4&gt;] (warn_slowpath_fmt+0x88/0xc8) r9:83f26400 r8:80f4a8d1 r7:00000009 r6:80528f90 r5:00000019 r4:80f4a8c2
| [&lt;80bb0940&gt;] (warn_slowpath_fmt) from [&lt;80528f90&gt;] (refcount_warn_saturate+0x114/0x134) r8:00000000 r7:00000000 r6:82b44000 r5:834e5600 r4:83f4d540
| [&lt;80528e7c&gt;] (refcount_warn_saturate) from [&lt;8079a4c8&gt;] (__refcount_add.constprop.0+0x4c/0x50)
| [&lt;8079a47c&gt;] (__refcount_add.constprop.0) from [&lt;8079a57c&gt;] (can_put_echo_skb+0xb0/0x13c)
| [&lt;8079a4cc&gt;] (can_put_echo_skb) from [&lt;8079ba98&gt;] (flexcan_start_xmit+0x1c4/0x230) r9:00000010 r8:83f48610 r7:0fdc0000 r6:0c080000 r5:82b44000 r4:834e5600
| [&lt;8079b8d4&gt;] (flexcan_start_xmit) from [&lt;80969078&gt;] (netdev_start_xmit+0x44/0x70) r9:814c0ba0 r8:80c8790c r7:00000000 r6:834e5600 r5:82b44000 r4:82ab1f00
| [&lt;80969034&gt;] (netdev_start_xmit) from [&lt;809725a4&gt;] (dev_hard_start_xmit+0x19c/0x318) r9:814c0ba0 r8:00000000 r7:82ab1f00 r6:82b44000 r5:00000000 r4:834e5600
| [&lt;80972408&gt;] (dev_hard_start_xmit) from [&lt;809c6584&gt;] (sch_direct_xmit+0xcc/0x264) r10:834e5600 r9:00000000 r8:00000000 r7:82b44000 r6:82ab1f00 r5:834e5600 r4:83f27400
| [&lt;809c64b8&gt;] (sch_direct_xmit) from [&lt;809c6c0c&gt;] (__qdisc_run+0x4f0/0x534)

To fix this problem, only set skb ownership to sockets which have still
a ref count &gt; 0.

Fixes: 0ae89beb283a ("can: add destructor for self generated skbs")
Cc: Oliver Hartkopp &lt;socketcan@hartkopp.net&gt;
Cc: Andre Naujoks &lt;nautsch2@gmail.com&gt;
Link: https://lore.kernel.org/r/20210226092456.27126-1-o.rempel@pengutronix.de
Suggested-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: Oleksij Rempel &lt;o.rempel@pengutronix.de&gt;
Reviewed-by: Oliver Hartkopp &lt;socketcan@hartkopp.net&gt;
Signed-off-by: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>can: can_create_echo_skb(): fix echo skb generation: always use skb_clone()</title>
<updated>2020-11-03T21:30:31Z</updated>
<author>
<name>Oleksij Rempel</name>
<email>o.rempel@pengutronix.de</email>
</author>
<published>2019-12-18T08:39:02Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=286228d382ba6320f04fa2e7c6fc8d4d92e428f4'/>
<id>urn:sha1:286228d382ba6320f04fa2e7c6fc8d4d92e428f4</id>
<content type='text'>
All user space generated SKBs are owned by a socket (unless injected into the
key via AF_PACKET). If a socket is closed, all associated skbs will be cleaned
up.

This leads to a problem when a CAN driver calls can_put_echo_skb() on a
unshared SKB. If the socket is closed prior to the TX complete handler,
can_get_echo_skb() and the subsequent delivering of the echo SKB to all
registered callbacks, a SKB with a refcount of 0 is delivered.

To avoid the problem, in can_get_echo_skb() the original SKB is now always
cloned, regardless of shared SKB or not. If the process exists it can now
safely discard its SKBs, without disturbing the delivery of the echo SKB.

The problem shows up in the j1939 stack, when it clones the incoming skb, which
detects the already 0 refcount.

We can easily reproduce this with following example:

testj1939 -B -r can0: &amp;
cansend can0 1823ff40#0123

WARNING: CPU: 0 PID: 293 at lib/refcount.c:25 refcount_warn_saturate+0x108/0x174
refcount_t: addition on 0; use-after-free.
Modules linked in: coda_vpu imx_vdoa videobuf2_vmalloc dw_hdmi_ahb_audio vcan
CPU: 0 PID: 293 Comm: cansend Not tainted 5.5.0-rc6-00376-g9e20dcb7040d #1
Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
Backtrace:
[&lt;c010f570&gt;] (dump_backtrace) from [&lt;c010f90c&gt;] (show_stack+0x20/0x24)
[&lt;c010f8ec&gt;] (show_stack) from [&lt;c0c3e1a4&gt;] (dump_stack+0x8c/0xa0)
[&lt;c0c3e118&gt;] (dump_stack) from [&lt;c0127fec&gt;] (__warn+0xe0/0x108)
[&lt;c0127f0c&gt;] (__warn) from [&lt;c01283c8&gt;] (warn_slowpath_fmt+0xa8/0xcc)
[&lt;c0128324&gt;] (warn_slowpath_fmt) from [&lt;c0539c0c&gt;] (refcount_warn_saturate+0x108/0x174)
[&lt;c0539b04&gt;] (refcount_warn_saturate) from [&lt;c0ad2cac&gt;] (j1939_can_recv+0x20c/0x210)
[&lt;c0ad2aa0&gt;] (j1939_can_recv) from [&lt;c0ac9dc8&gt;] (can_rcv_filter+0xb4/0x268)
[&lt;c0ac9d14&gt;] (can_rcv_filter) from [&lt;c0aca2cc&gt;] (can_receive+0xb0/0xe4)
[&lt;c0aca21c&gt;] (can_receive) from [&lt;c0aca348&gt;] (can_rcv+0x48/0x98)
[&lt;c0aca300&gt;] (can_rcv) from [&lt;c09b1fdc&gt;] (__netif_receive_skb_one_core+0x64/0x88)
[&lt;c09b1f78&gt;] (__netif_receive_skb_one_core) from [&lt;c09b2070&gt;] (__netif_receive_skb+0x38/0x94)
[&lt;c09b2038&gt;] (__netif_receive_skb) from [&lt;c09b2130&gt;] (netif_receive_skb_internal+0x64/0xf8)
[&lt;c09b20cc&gt;] (netif_receive_skb_internal) from [&lt;c09b21f8&gt;] (netif_receive_skb+0x34/0x19c)
[&lt;c09b21c4&gt;] (netif_receive_skb) from [&lt;c0791278&gt;] (can_rx_offload_napi_poll+0x58/0xb4)

Fixes: 0ae89beb283a ("can: add destructor for self generated skbs")
Signed-off-by: Oleksij Rempel &lt;o.rempel@pengutronix.de&gt;
Link: http://lore.kernel.org/r/20200124132656.22156-1-o.rempel@pengutronix.de
Acked-by: Oliver Hartkopp &lt;socketcan@hartkopp.net&gt;
Signed-off-by: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
</content>
</entry>
<entry>
<title>can: remove obsolete version strings</title>
<updated>2020-10-12T08:06:39Z</updated>
<author>
<name>Oliver Hartkopp</name>
<email>socketcan@hartkopp.net</email>
</author>
<published>2020-10-12T07:43:54Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f726f3d37163f714034aa5fd1f92a1a73df4297f'/>
<id>urn:sha1:f726f3d37163f714034aa5fd1f92a1a73df4297f</id>
<content type='text'>
As pointed out by Jakub Kicinski here:
http://lore.kernel.org/r/20201009175751.5c54097f@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com
this patch removes the obsolete version information of the different
CAN protocols and the AF_CAN core module.

Signed-off-by: Oliver Hartkopp &lt;socketcan@hartkopp.net&gt;
Link: https://lore.kernel.org/r/20201012074354.25839-2-socketcan@hartkopp.net
Signed-off-by: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
</content>
</entry>
<entry>
<title>can: dev: add a helper function to calculate the duration of one bit</title>
<updated>2020-10-07T21:17:45Z</updated>
<author>
<name>Vincent Mailhol</name>
<email>mailhol.vincent@wanadoo.fr</email>
</author>
<published>2020-10-02T15:41:49Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=1c47fa6b31c2683f03bc2f9174902bb7dcd35d83'/>
<id>urn:sha1:1c47fa6b31c2683f03bc2f9174902bb7dcd35d83</id>
<content type='text'>
Rename macro CAN_CALC_SYNC_SEG to CAN_SYNC_SEG and make it available
through include/linux/can/dev.h

Add an helper function can_bit_time() which returns the duration (in
time quanta) of one CAN bit.

Rationale for this patch: the sync segment and the bit time are two
concepts which are defined in the CAN ISO standard. Device drivers for
CAN might need those.

Please refer to ISO 11898-1:2015, section 11.3.1.1 "Bit time" for
additional information.

Signed-off-by: Vincent Mailhol &lt;mailhol.vincent@wanadoo.fr&gt;
Link: https://lore.kernel.org/r/20201002154219.4887-6-mailhol.vincent@wanadoo.fr
[mkl: Let can_bit_time() return an unsinged int, make argument const]
Signed-off-by: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
</content>
</entry>
<entry>
<title>can: dev: fix type of get_can_dlc() and get_canfd_dlc() macros</title>
<updated>2020-10-06T20:44:27Z</updated>
<author>
<name>Vincent Mailhol</name>
<email>mailhol.vincent@wanadoo.fr</email>
</author>
<published>2020-10-02T15:41:46Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f55a52bb2cdbc5a92ca209d0ada90a490a188f58'/>
<id>urn:sha1:f55a52bb2cdbc5a92ca209d0ada90a490a188f58</id>
<content type='text'>
The macros get_can_dlc() and get_canfd_dlc() are not visible in
userland. As such, type u8 should be preferred over type __u8.

Reference: https://lkml.org/lkml/2020/10/1/708
Signed-off-by: Vincent Mailhol &lt;mailhol.vincent@wanadoo.fr&gt;
Link: https://lore.kernel.org/r/20201002154219.4887-3-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
</content>
</entry>
<entry>
<title>can: rx-offload: can_rx_offload_add_manual(): add new initialization function</title>
<updated>2020-09-21T08:13:19Z</updated>
<author>
<name>Marc Kleine-Budde</name>
<email>mkl@pengutronix.de</email>
</author>
<published>2020-09-15T22:35:22Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=728fc9ff73d3f25220f6b8a52aaf063ec51ef294'/>
<id>urn:sha1:728fc9ff73d3f25220f6b8a52aaf063ec51ef294</id>
<content type='text'>
This patch adds a new initialization function:
can_rx_offload_add_manual()

It should be used to add support rx-offload to a driver, if the callback
mechanism should not be used. Use e.g. can_rx_offload_queue_sorted() to queue
skbs into rx-offload.

Link: https://lore.kernel.org/r/20200915223527.1417033-33-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
</content>
</entry>
<entry>
<title>can: dev: can_put_echo_skb(): propagate error in case of errors</title>
<updated>2020-09-21T08:13:16Z</updated>
<author>
<name>Marc Kleine-Budde</name>
<email>mkl@pengutronix.de</email>
</author>
<published>2020-09-15T22:35:01Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=80a71815d8cd1be6481ad16fad3167f095045a06'/>
<id>urn:sha1:80a71815d8cd1be6481ad16fad3167f095045a06</id>
<content type='text'>
The function can_put_echo_skb() can fail for several reasons. It may
fail due to OOM, but when it fails it's usually due to locking problems
in the driver.

In order to help developing and debugging of new drivers propagate error
value in case of errors.

Link: https://lore.kernel.org/r/20200915223527.1417033-12-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
</content>
</entry>
<entry>
<title>can: include: fix spelling mistakes</title>
<updated>2020-09-21T08:13:15Z</updated>
<author>
<name>Marc Kleine-Budde</name>
<email>mkl@pengutronix.de</email>
</author>
<published>2020-09-15T22:34:53Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=49347755a84052fd1317c3897c7cea954c8f89fe'/>
<id>urn:sha1:49347755a84052fd1317c3897c7cea954c8f89fe</id>
<content type='text'>
This patch fixes spelling erros found by "codespell" in the
include/linux/can subtree.

Link: https://lore.kernel.org/r/20200915223527.1417033-4-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
</content>
</entry>
</feed>
