<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/include/linux/can, branch v5.4.270</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.4.270</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.4.270'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2022-12-19T11:24:16Z</updated>
<entry>
<title>can: sja1000: fix size of OCR_MODE_MASK define</title>
<updated>2022-12-19T11:24:16Z</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=f843fdcac054800774db4069418f5ba7b2cf456e'/>
<id>urn:sha1:f843fdcac054800774db4069418f5ba7b2cf456e</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-07T12:47:41Z</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=4ac1feff6ea6495cbfd336f4438a6c6d140544a6'/>
<id>urn:sha1:4ac1feff6ea6495cbfd336f4438a6c6d140544a6</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:03:31Z</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=6676e510d1a9c6f5ae0031705ef6020dfe63372b'/>
<id>urn:sha1:6676e510d1a9c6f5ae0031705ef6020dfe63372b</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-18T18:20:19Z</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=5bde65abe166692dbe1d9ff0c7957aa954515056'/>
<id>urn:sha1:5bde65abe166692dbe1d9ff0c7957aa954515056</id>
<content type='text'>
[ Upstream commit 286228d382ba6320f04fa2e7c6fc8d4d92e428f4 ]

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;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>can: can_dropped_invalid_skb(): ensure an initialized headroom in outgoing CAN sk_buffs</title>
<updated>2020-01-14T19:08:28Z</updated>
<author>
<name>Oliver Hartkopp</name>
<email>socketcan@hartkopp.net</email>
</author>
<published>2019-12-07T18:34:18Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a0dbd93fb148764c5ccc099307bba0b68e7fda4d'/>
<id>urn:sha1:a0dbd93fb148764c5ccc099307bba0b68e7fda4d</id>
<content type='text'>
commit e7153bf70c3496bac00e7e4f395bb8d8394ac0ea upstream.

KMSAN sysbot detected a read access to an untinitialized value in the
headroom of an outgoing CAN related sk_buff. When using CAN sockets this
area is filled appropriately - but when using a packet socket this
initialization is missing.

The problematic read access occurs in the CAN receive path which can
only be triggered when the sk_buff is sent through a (virtual) CAN
interface. So we check in the sending path whether we need to perform
the missing initializations.

Fixes: d3b58c47d330d ("can: replace timestamp as unique skb attribute")
Reported-by: syzbot+b02ff0707a97e4e79ebb@syzkaller.appspotmail.com
Signed-off-by: Oliver Hartkopp &lt;socketcan@hartkopp.net&gt;
Tested-by: Oliver Hartkopp &lt;socketcan@hartkopp.net&gt;
Cc: linux-stable &lt;stable@vger.kernel.org&gt; # &gt;= v4.1
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: af_can: export can_sock_destruct()</title>
<updated>2019-11-13T09:42:33Z</updated>
<author>
<name>Oleksij Rempel</name>
<email>o.rempel@pengutronix.de</email>
</author>
<published>2019-11-07T10:55:42Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=975987e7015bb12a482df7f14fd524417d2c8e8f'/>
<id>urn:sha1:975987e7015bb12a482df7f14fd524417d2c8e8f</id>
<content type='text'>
In j1939 we need our own struct sock::sk_destruct callback. Export the
generic af_can can_sock_destruct() that allows us to chain-call it.

Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Signed-off-by: Oleksij Rempel &lt;o.rempel@pengutronix.de&gt;
</content>
</entry>
<entry>
<title>Merge tag 'linux-can-next-for-5.4-20190904' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next</title>
<updated>2019-09-05T10:17:50Z</updated>
<author>
<name>David S. Miller</name>
<email>davem@davemloft.net</email>
</author>
<published>2019-09-05T10:17:50Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=44c40910b66f786d33ffd2682ef38750eebb567c'/>
<id>urn:sha1:44c40910b66f786d33ffd2682ef38750eebb567c</id>
<content type='text'>
Marc Kleine-Budde says:

====================
pull-request: can-next 2019-09-04 j1939

this is a pull request for net-next/master consisting of 21 patches.

the first 12 patches are by me and target the CAN core infrastructure.
They clean up the names of variables , structs and struct members,
convert can_rx_register() to use max() instead of open coding it and
remove unneeded code from the can_pernet_exit() callback.

The next three patches are also by me and they introduce and make use of
the CAN midlayer private structure. It is used to hold protocol specific
per device data structures.

The next patch is by Oleksij Rempel, switches the
&amp;net-&gt;can.rcvlists_lock from a spin_lock() to a spin_lock_bh(), so that
it can be used from NAPI (soft IRQ) context.

The next 4 patches are by Kurt Van Dijck, he first updates his email
address via mailmap and then extends sockaddr_can to include j1939
members.

The final patch is the collective effort of many entities (The j1939
authors: Oliver Hartkopp, Bastian Stender, Elenita Hinds, kbuild test
robot, Kurt Van Dijck, Maxime Jayat, Robin van der Gracht, Oleksij
Rempel, Marc Kleine-Budde). It adds support of SAE J1939 protocol to the
CAN networking stack.

SAE J1939 is the vehicle bus recommended practice used for communication
and diagnostics among vehicle components. Originating in the car and
heavy-duty truck industry in the United States, it is now widely used in
other parts of the world.

P.S.: This pull request doesn't invalidate my last pull request:
      "pull-request: can-next 2019-09-03".
====================

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>can: add support of SAE J1939 protocol</title>
<updated>2019-09-04T12:22:33Z</updated>
<author>
<name>The j1939 authors</name>
<email>linux-can@vger.kernel.org</email>
</author>
<published>2018-10-08T09:48:36Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9d71dd0c70099914fcd063135da3c580865e924c'/>
<id>urn:sha1:9d71dd0c70099914fcd063135da3c580865e924c</id>
<content type='text'>
SAE J1939 is the vehicle bus recommended practice used for communication
and diagnostics among vehicle components. Originating in the car and
heavy-duty truck industry in the United States, it is now widely used in
other parts of the world.

J1939, ISO 11783 and NMEA 2000 all share the same high level protocol.
SAE J1939 can be considered the replacement for the older SAE J1708 and
SAE J1587 specifications.

Acked-by: Oliver Hartkopp &lt;socketcan@hartkopp.net&gt;
Signed-off-by: Bastian Stender &lt;bst@pengutronix.de&gt;
Signed-off-by: Elenita Hinds &lt;ecathinds@gmail.com&gt;
Signed-off-by: kbuild test robot &lt;lkp@intel.com&gt;
Signed-off-by: Kurt Van Dijck &lt;dev.kurt@vandijck-laurijssen.be&gt;
Signed-off-by: Maxime Jayat &lt;maxime.jayat@mobile-devices.fr&gt;
Signed-off-by: Robin van der Gracht &lt;robin@protonic.nl&gt;
Signed-off-by: Oleksij Rempel &lt;o.rempel@pengutronix.de&gt;
Signed-off-by: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
</content>
</entry>
<entry>
<title>can: introduce CAN_REQUIRED_SIZE macro</title>
<updated>2019-09-04T11:29:15Z</updated>
<author>
<name>Kurt Van Dijck</name>
<email>dev.kurt@vandijck-laurijssen.be</email>
</author>
<published>2018-10-08T09:48:33Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9868b5d44f3df9dd75247acd23dddff0a42f79be'/>
<id>urn:sha1:9868b5d44f3df9dd75247acd23dddff0a42f79be</id>
<content type='text'>
The size of this structure will be increased with J1939 support. To stay
binary compatible, the CAN_REQUIRED_SIZE macro is introduced for
existing CAN protocols.

Signed-off-by: Kurt Van Dijck &lt;dev.kurt@vandijck-laurijssen.be&gt;
Signed-off-by: Oleksij Rempel &lt;o.rempel@pengutronix.de&gt;
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: make use of preallocated can_ml_priv for per device struct can_dev_rcv_lists</title>
<updated>2019-09-04T11:29:15Z</updated>
<author>
<name>Marc Kleine-Budde</name>
<email>mkl@pengutronix.de</email>
</author>
<published>2018-10-08T07:02:39Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=8df9ffb888c021fa68f9075d545f2ec5eca37200'/>
<id>urn:sha1:8df9ffb888c021fa68f9075d545f2ec5eca37200</id>
<content type='text'>
This patch removes the old method of allocating the per device protocol
specific memory via a netdevice_notifier. This had the drawback, that
the allocation can fail, leading to a lot of null pointer checks in the
code. This also makes the live cycle management of this memory quite
complicated.

This patch switches from the allocating the struct can_dev_rcv_lists in
a NETDEV_REGISTER call to using the dev-&gt;ml_priv, which is allocated by
the driver since the previous patch.

Signed-off-by: Oleksij Rempel &lt;o.rempel@pengutronix.de&gt;
Acked-by: Oliver Hartkopp &lt;socketcan@hartkopp.net&gt;
Signed-off-by: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
</content>
</entry>
</feed>
