<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/net/slip/slip.c, branch linux-4.4.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.4.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.4.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2020-06-11T07:21:38Z</updated>
<entry>
<title>slip: not call free_netdev before rtnl_unlock in slip_open</title>
<updated>2020-06-11T07:21:38Z</updated>
<author>
<name>yangerkun</name>
</author>
<published>2020-02-26T03:54:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fb586519dec413d455791267daf16925853faecd'/>
<id>urn:sha1:fb586519dec413d455791267daf16925853faecd</id>
<content type='text'>
commit f596c87005f7b1baeb7d62d9a9e25d68c3dfae10 upstream.

As the description before netdev_run_todo, we cannot call free_netdev
before rtnl_unlock, fix it by reorder the code.

Signed-off-by: yangerkun &lt;yangerkun@huawei.com&gt;
Reviewed-by: Oliver Hartkopp &lt;socketcan@hartkopp.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
[bwh: Backported to &lt;4.11: free_netdev() is called through sl_free_netdev()]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>slip: stop double free sl-&gt;dev in slip_open</title>
<updated>2020-03-11T06:51:14Z</updated>
<author>
<name>yangerkun</name>
</author>
<published>2020-02-28T13:40:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4b2e97b1409adc49bc6db169f8066d01e79ac4fb'/>
<id>urn:sha1:4b2e97b1409adc49bc6db169f8066d01e79ac4fb</id>
<content type='text'>
After include 3b5a39979daf ("slip: Fix memory leak in slip_open error path")
and e58c19124189 ("slip: Fix use-after-free Read in slip_open") with 4.4.y/4.9.y.
We will trigger a bug since we can double free sl-&gt;dev in slip_open. Actually,
we should backport cf124db566e6 ("net: Fix inconsistent teardown and release
of private netdev state.") too since it has delete free_netdev from sl_free_netdev.
Fix it by delete free_netdev from slip_open.

Signed-off-by: yangerkun &lt;yangerkun@huawei.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>can, slip: Protect tty-&gt;disc_data in write_wakeup and close with RCU</title>
<updated>2020-01-29T09:21:51Z</updated>
<author>
<name>Richard Palethorpe</name>
</author>
<published>2020-01-21T13:42:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6169e11e1f14dd272ec9c746050820e5cc2cf853'/>
<id>urn:sha1:6169e11e1f14dd272ec9c746050820e5cc2cf853</id>
<content type='text'>
[ Upstream commit 0ace17d56824165c7f4c68785d6b58971db954dd ]

write_wakeup can happen in parallel with close/hangup where tty-&gt;disc_data
is set to NULL and the netdevice is freed thus also freeing
disc_data. write_wakeup accesses disc_data so we must prevent close from
freeing the netdev while write_wakeup has a non-NULL view of
tty-&gt;disc_data.

We also need to make sure that accesses to disc_data are atomic. Which can
all be done with RCU.

This problem was found by Syzkaller on SLCAN, but the same issue is
reproducible with the SLIP line discipline using an LTP test based on the
Syzkaller reproducer.

A fix which didn't use RCU was posted by Hillf Danton.

Fixes: 661f7fda21b1 ("slip: Fix deadlock in write_wakeup")
Fixes: a8e83b17536a ("slcan: Port write_wakeup deadlock fix from slip")
Reported-by: syzbot+017e491ae13c0068598a@syzkaller.appspotmail.com
Signed-off-by: Richard Palethorpe &lt;rpalethorpe@suse.com&gt;
Cc: Wolfgang Grandegger &lt;wg@grandegger.com&gt;
Cc: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
Cc: Tyler Hall &lt;tylerwhall@gmail.com&gt;
Cc: linux-can@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: syzkaller@googlegroups.com
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>slip: Fix use-after-free Read in slip_open</title>
<updated>2019-12-05T14:27:14Z</updated>
<author>
<name>Jouni Hogander</name>
</author>
<published>2019-11-25T12:23:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ee58887f5002721023e56100393c4aacb00d3b23'/>
<id>urn:sha1:ee58887f5002721023e56100393c4aacb00d3b23</id>
<content type='text'>
[ Upstream commit e58c1912418980f57ba2060017583067f5f71e52 ]

Slip_open doesn't clean-up device which registration failed from the
slip_devs device list. On next open after failure this list is iterated
and freed device is accessed. Fix this by calling sl_free_netdev in error
path.

Here is the trace from the Syzbot:

__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x197/0x210 lib/dump_stack.c:118
print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
__kasan_report.cold+0x1b/0x41 mm/kasan/report.c:506
kasan_report+0x12/0x20 mm/kasan/common.c:634
__asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
sl_sync drivers/net/slip/slip.c:725 [inline]
slip_open+0xecd/0x11b7 drivers/net/slip/slip.c:801
tty_ldisc_open.isra.0+0xa3/0x110 drivers/tty/tty_ldisc.c:469
tty_set_ldisc+0x30e/0x6b0 drivers/tty/tty_ldisc.c:596
tiocsetd drivers/tty/tty_io.c:2334 [inline]
tty_ioctl+0xe8d/0x14f0 drivers/tty/tty_io.c:2594
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:509 [inline]
do_vfs_ioctl+0xdb6/0x13e0 fs/ioctl.c:696
ksys_ioctl+0xab/0xd0 fs/ioctl.c:713
__do_sys_ioctl fs/ioctl.c:720 [inline]
__se_sys_ioctl fs/ioctl.c:718 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Fixes: 3b5a39979daf ("slip: Fix memory leak in slip_open error path")
Reported-by: syzbot+4d5170758f3762109542@syzkaller.appspotmail.com
Cc: David Miller &lt;davem@davemloft.net&gt;
Cc: Oliver Hartkopp &lt;socketcan@hartkopp.net&gt;
Cc: Lukas Bulwahn &lt;lukas.bulwahn@gmail.com&gt;
Signed-off-by: Jouni Hogander &lt;jouni.hogander@unikie.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>slip: Fix memory leak in slip_open error path</title>
<updated>2019-11-25T14:53:41Z</updated>
<author>
<name>Jouni Hogander</name>
</author>
<published>2019-11-13T11:45:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=329cb706daabb0fff52b4ca5256213f429221fa1'/>
<id>urn:sha1:329cb706daabb0fff52b4ca5256213f429221fa1</id>
<content type='text'>
[ Upstream commit 3b5a39979dafea9d0cd69c7ae06088f7a84cdafa ]

Driver/net/can/slcan.c is derived from slip.c. Memory leak was detected
by Syzkaller in slcan. Same issue exists in slip.c and this patch is
addressing the leak in slip.c.

Here is the slcan memory leak trace reported by Syzkaller:

BUG: memory leak unreferenced object 0xffff888067f65500 (size 4096):
  comm "syz-executor043", pid 454, jiffies 4294759719 (age 11.930s)
  hex dump (first 32 bytes):
    73 6c 63 61 6e 30 00 00 00 00 00 00 00 00 00 00 slcan0..........
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
  backtrace:
    [&lt;00000000a06eec0d&gt;] __kmalloc+0x18b/0x2c0
    [&lt;0000000083306e66&gt;] kvmalloc_node+0x3a/0xc0
    [&lt;000000006ac27f87&gt;] alloc_netdev_mqs+0x17a/0x1080
    [&lt;0000000061a996c9&gt;] slcan_open+0x3ae/0x9a0
    [&lt;000000001226f0f9&gt;] tty_ldisc_open.isra.1+0x76/0xc0
    [&lt;0000000019289631&gt;] tty_set_ldisc+0x28c/0x5f0
    [&lt;000000004de5a617&gt;] tty_ioctl+0x48d/0x1590
    [&lt;00000000daef496f&gt;] do_vfs_ioctl+0x1c7/0x1510
    [&lt;0000000059068dbc&gt;] ksys_ioctl+0x99/0xb0
    [&lt;000000009a6eb334&gt;] __x64_sys_ioctl+0x78/0xb0
    [&lt;0000000053d0332e&gt;] do_syscall_64+0x16f/0x580
    [&lt;0000000021b83b99&gt;] entry_SYSCALL_64_after_hwframe+0x44/0xa9
    [&lt;000000008ea75434&gt;] 0xfffffffffffffff

Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
Cc: Oliver Hartkopp &lt;socketcan@hartkopp.net&gt;
Cc: Lukas Bulwahn &lt;lukas.bulwahn@gmail.com&gt;
Signed-off-by: Jouni Hogander &lt;jouni.hogander@unikie.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>ppp, slip: Validate VJ compression slot parameters completely</title>
<updated>2015-11-02T21:25:00Z</updated>
<author>
<name>Ben Hutchings</name>
</author>
<published>2015-11-01T16:22:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4ab42d78e37a294ac7bc56901d563c642e03c4ae'/>
<id>urn:sha1:4ab42d78e37a294ac7bc56901d563c642e03c4ae</id>
<content type='text'>
Currently slhc_init() treats out-of-range values of rslots and tslots
as equivalent to 0, except that if tslots is too large it will
dereference a null pointer (CVE-2015-7799).

Add a range-check at the top of the function and make it return an
ERR_PTR() on error instead of NULL.  Change the callers accordingly.

Compile-tested only.

Reported-by: 郭永刚 &lt;guoyonggang@360.cn&gt;
References: http://article.gmane.org/gmane.comp.security.oss.general/17908
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net: set name_assign_type in alloc_netdev()</title>
<updated>2014-07-15T23:12:48Z</updated>
<author>
<name>Tom Gundersen</name>
</author>
<published>2014-07-14T14:37:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c835a677331495cf137a7f8a023463afd9f032f8'/>
<id>urn:sha1:c835a677331495cf137a7f8a023463afd9f032f8</id>
<content type='text'>
Extend alloc_netdev{,_mq{,s}}() to take name_assign_type as argument, and convert
all users to pass NET_NAME_UNKNOWN.

Coccinelle patch:

@@
expression sizeof_priv, name, setup, txqs, rxqs, count;
@@

(
-alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs)
+alloc_netdev_mqs(sizeof_priv, name, NET_NAME_UNKNOWN, setup, txqs, rxqs)
|
-alloc_netdev_mq(sizeof_priv, name, setup, count)
+alloc_netdev_mq(sizeof_priv, name, NET_NAME_UNKNOWN, setup, count)
|
-alloc_netdev(sizeof_priv, name, setup)
+alloc_netdev(sizeof_priv, name, NET_NAME_UNKNOWN, setup)
)

v9: move comments here from the wrong commit

Signed-off-by: Tom Gundersen &lt;teg@jklm.no&gt;
Reviewed-by: David Herrmann &lt;dh.herrmann@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>slip: Fix deadlock in write_wakeup</title>
<updated>2014-06-17T04:29:12Z</updated>
<author>
<name>Tyler Hall</name>
</author>
<published>2014-06-16T02:23:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=661f7fda21b15ec52f57fcd397c03370acc28688'/>
<id>urn:sha1:661f7fda21b15ec52f57fcd397c03370acc28688</id>
<content type='text'>
Use schedule_work() to avoid potentially taking the spinlock in
interrupt context.

Commit cc9fa74e2a ("slip/slcan: added locking in wakeup function") added
necessary locking to the wakeup function and 367525c8c2/ddcde142be ("can:
slcan: Fix spinlock variant") converted it to spin_lock_bh() because the lock
is also taken in timers.

Disabling softirqs is not sufficient, however, as tty drivers may call
write_wakeup from interrupt context. This driver calls tty-&gt;ops-&gt;write() with
its spinlock held, which may immediately cause an interrupt on the same CPU and
subsequent spin_bug().

Simply converting to spin_lock_irq/irqsave() prevents this deadlock, but
causes lockdep to point out a possible circular locking dependency
between these locks:

(&amp;(&amp;sl-&gt;lock)-&gt;rlock){-.....}, at: slip_write_wakeup
(&amp;port_lock_key){-.....}, at: serial8250_handle_irq.part.13

The slip transmit is holding the slip spinlock when calling the tty write.
This grabs the port lock. On an interrupt, the handler grabs the port
lock and calls write_wakeup which grabs the slip lock. This could be a
problem if a serial interrupt occurs on another CPU during the slip
transmit.

To deal with these issues, don't grab the lock in the wakeup function by
deferring the writeout to a workqueue. Also hold the lock during close
when de-assigning the tty pointer to safely disarm the worker and
timers.

This bug is easily reproducible on the first transmit when slip is
used with the standard 8250 serial driver.

[&lt;c0410b7c&gt;] (spin_bug+0x0/0x38) from [&lt;c006109c&gt;] (do_raw_spin_lock+0x60/0x1d0)
 r5:eab27000 r4:ec02754c
[&lt;c006103c&gt;] (do_raw_spin_lock+0x0/0x1d0) from [&lt;c04185c0&gt;] (_raw_spin_lock+0x28/0x2c)
 r10:0000001f r9:eabb814c r8:eabb8140 r7:40070193 r6:ec02754c r5:eab27000
 r4:ec02754c r3:00000000
[&lt;c0418598&gt;] (_raw_spin_lock+0x0/0x2c) from [&lt;bf3a0220&gt;] (slip_write_wakeup+0x50/0xe0 [slip])
 r4:ec027540 r3:00000003
[&lt;bf3a01d0&gt;] (slip_write_wakeup+0x0/0xe0 [slip]) from [&lt;c026e420&gt;] (tty_wakeup+0x48/0x68)
 r6:00000000 r5:ea80c480 r4:eab27000 r3:bf3a01d0
[&lt;c026e3d8&gt;] (tty_wakeup+0x0/0x68) from [&lt;c028a8ec&gt;] (uart_write_wakeup+0x2c/0x30)
 r5:ed68ea90 r4:c06790d8
[&lt;c028a8c0&gt;] (uart_write_wakeup+0x0/0x30) from [&lt;c028dc44&gt;] (serial8250_tx_chars+0x114/0x170)
[&lt;c028db30&gt;] (serial8250_tx_chars+0x0/0x170) from [&lt;c028dffc&gt;] (serial8250_handle_irq+0xa0/0xbc)
 r6:000000c2 r5:00000060 r4:c06790d8 r3:00000000
[&lt;c028df5c&gt;] (serial8250_handle_irq+0x0/0xbc) from [&lt;c02933a4&gt;] (dw8250_handle_irq+0x38/0x64)
 r7:00000000 r6:edd2f390 r5:000000c2 r4:c06790d8
[&lt;c029336c&gt;] (dw8250_handle_irq+0x0/0x64) from [&lt;c028d2f4&gt;] (serial8250_interrupt+0x44/0xc4)
 r6:00000000 r5:00000000 r4:c06791c4 r3:c029336c
[&lt;c028d2b0&gt;] (serial8250_interrupt+0x0/0xc4) from [&lt;c0067fe4&gt;] (handle_irq_event_percpu+0xb4/0x2b0)
 r10:c06790d8 r9:eab27000 r8:00000000 r7:00000000 r6:0000001f r5:edd52980
 r4:ec53b6c0 r3:c028d2b0
[&lt;c0067f30&gt;] (handle_irq_event_percpu+0x0/0x2b0) from [&lt;c006822c&gt;] (handle_irq_event+0x4c/0x6c)
 r10:c06790d8 r9:eab27000 r8:c0673ae0 r7:c05c2020 r6:ec53b6c0 r5:edd529d4
 r4:edd52980
[&lt;c00681e0&gt;] (handle_irq_event+0x0/0x6c) from [&lt;c006b140&gt;] (handle_level_irq+0xe8/0x100)
 r6:00000000 r5:edd529d4 r4:edd52980 r3:00022000
[&lt;c006b058&gt;] (handle_level_irq+0x0/0x100) from [&lt;c00676f8&gt;] (generic_handle_irq+0x30/0x40)
 r5:0000001f r4:0000001f
[&lt;c00676c8&gt;] (generic_handle_irq+0x0/0x40) from [&lt;c000f57c&gt;] (handle_IRQ+0xd0/0x13c)
 r4:ea997b18 r3:000000e0
[&lt;c000f4ac&gt;] (handle_IRQ+0x0/0x13c) from [&lt;c00086c4&gt;] (armada_370_xp_handle_irq+0x4c/0x118)
 r8:000003ff r7:ea997b18 r6:ffffffff r5:60070013 r4:c0674dc0
[&lt;c0008678&gt;] (armada_370_xp_handle_irq+0x0/0x118) from [&lt;c0013840&gt;] (__irq_svc+0x40/0x70)
Exception stack(0xea997b18 to 0xea997b60)
7b00:                                                       00000001 20070013
7b20: 00000000 0000000b 20070013 eab27000 20070013 00000000 ed10103e eab27000
7b40: c06790d8 ea997b74 ea997b60 ea997b60 c04186c0 c04186c8 60070013 ffffffff
 r9:eab27000 r8:ed10103e r7:ea997b4c r6:ffffffff r5:60070013 r4:c04186c8
[&lt;c04186a4&gt;] (_raw_spin_unlock_irqrestore+0x0/0x54) from [&lt;c0288fc0&gt;] (uart_start+0x40/0x44)
 r4:c06790d8 r3:c028ddd8
[&lt;c0288f80&gt;] (uart_start+0x0/0x44) from [&lt;c028982c&gt;] (uart_write+0xe4/0xf4)
 r6:0000003e r5:00000000 r4:ed68ea90 r3:0000003e
[&lt;c0289748&gt;] (uart_write+0x0/0xf4) from [&lt;bf3a0d20&gt;] (sl_xmit+0x1c4/0x228 [slip])
 r10:ed388e60 r9:0000003c r8:ffffffdd r7:0000003e r6:ec02754c r5:ea717eb8
 r4:ec027000
[&lt;bf3a0b5c&gt;] (sl_xmit+0x0/0x228 [slip]) from [&lt;c0368d74&gt;] (dev_hard_start_xmit+0x39c/0x6d0)
 r8:eaf163c0 r7:ec027000 r6:ea717eb8 r5:00000000 r4:00000000

Signed-off-by: Tyler Hall &lt;tylerwhall@gmail.com&gt;
Cc: Oliver Hartkopp &lt;socketcan@hartkopp.net&gt;
Cc: Andre Naujoks &lt;nautsch2@gmail.com&gt;
Cc: David S. Miller &lt;davem@davemloft.net&gt;
Cc: linux-kernel@vger.kernel.org
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>slip: fix spinlock variant</title>
<updated>2014-04-28T03:35:12Z</updated>
<author>
<name>Oliver Hartkopp</name>
</author>
<published>2014-04-26T19:18:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ddcde142bed44490e338ed1124cb149976d355bb'/>
<id>urn:sha1:ddcde142bed44490e338ed1124cb149976d355bb</id>
<content type='text'>
With commit cc9fa74e2a ("slip/slcan: added locking in wakeup function") a
formerly missing locking was added to slip.c and slcan.c by Andre Naujoks.

Alexander Stein contributed the fix 367525c8c2 ("can: slcan: Fix spinlock
variant") as the kernel lock debugging advised to use spin_lock_bh() instead
of just using spin_lock().

This fix has to be applied to the same code section in slip.c for the same
reason too.

Signed-off-by: Oliver Hartkopp &lt;socketcan@hartkopp.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>slip/slcan: added locking in wakeup function</title>
<updated>2013-09-20T19:38:26Z</updated>
<author>
<name>Andre Naujoks</name>
</author>
<published>2013-09-13T17:37:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cc9fa74e2a195f7bab27fbbc4896d2fe3ec32150'/>
<id>urn:sha1:cc9fa74e2a195f7bab27fbbc4896d2fe3ec32150</id>
<content type='text'>
The locking is needed, since the the internal buffer for the CAN frames is
changed during the wakeup call. This could cause buffer inconsistencies
under high loads, especially for the outgoing short CAN packet skbuffs.

The needed locks led to deadlocks before commit
"5ede52538ee2b2202d9dff5b06c33bfde421e6e4 tty: Remove extra wakeup from pty
write() path", which removed the direct callback to the wakeup function from the
tty layer.

As slcan.c is based on slip.c the issue in the original code is fixed, too.

Signed-off-by: Andre Naujoks &lt;nautsch2@gmail.com&gt;
Acked-by: Oliver Hartkopp &lt;socketcan@hartkopp.net&gt;
Acked-by: Marc Kleine-Budde  &lt;mkl@pengutronix.de&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
