05 May, 2016

1 commit

  • Replace all trans_start updates with netif_trans_update helper.
    change was done via spatch:

    struct net_device *d;
    @@
    - d->trans_start = jiffies
    + netif_trans_update(d)

    Compile tested only.

    Cc: user-mode-linux-devel@lists.sourceforge.net
    Cc: linux-xtensa@linux-xtensa.org
    Cc: linux1394-devel@lists.sourceforge.net
    Cc: linux-rdma@vger.kernel.org
    Cc: netdev@vger.kernel.org
    Cc: MPT-FusionLinux.pdl@broadcom.com
    Cc: linux-scsi@vger.kernel.org
    Cc: linux-can@vger.kernel.org
    Cc: linux-parisc@vger.kernel.org
    Cc: linux-omap@vger.kernel.org
    Cc: linux-hams@vger.kernel.org
    Cc: linux-usb@vger.kernel.org
    Cc: linux-wireless@vger.kernel.org
    Cc: linux-s390@vger.kernel.org
    Cc: devel@driverdev.osuosl.org
    Cc: b.a.t.m.a.n@lists.open-mesh.org
    Cc: linux-bluetooth@vger.kernel.org
    Signed-off-by: Florian Westphal
    Acked-by: Felipe Balbi
    Acked-by: Mugunthan V N
    Acked-by: Antonio Quartulli
    Signed-off-by: David S. Miller

    Florian Westphal
     

03 Nov, 2015

1 commit

  • 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: 郭永刚
    References: http://article.gmane.org/gmane.comp.security.oss.general/17908
    Signed-off-by: Ben Hutchings
    Signed-off-by: David S. Miller

    Ben Hutchings
     

16 Jul, 2014

1 commit

  • 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
    Reviewed-by: David Herrmann
    Signed-off-by: David S. Miller

    Tom Gundersen
     

14 Jul, 2014

1 commit


17 Jun, 2014

1 commit

  • 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->ops->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:

    (&(&sl->lock)->rlock){-.....}, at: slip_write_wakeup
    (&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.

    [] (spin_bug+0x0/0x38) from [] (do_raw_spin_lock+0x60/0x1d0)
    r5:eab27000 r4:ec02754c
    [] (do_raw_spin_lock+0x0/0x1d0) from [] (_raw_spin_lock+0x28/0x2c)
    r10:0000001f r9:eabb814c r8:eabb8140 r7:40070193 r6:ec02754c r5:eab27000
    r4:ec02754c r3:00000000
    [] (_raw_spin_lock+0x0/0x2c) from [] (slip_write_wakeup+0x50/0xe0 [slip])
    r4:ec027540 r3:00000003
    [] (slip_write_wakeup+0x0/0xe0 [slip]) from [] (tty_wakeup+0x48/0x68)
    r6:00000000 r5:ea80c480 r4:eab27000 r3:bf3a01d0
    [] (tty_wakeup+0x0/0x68) from [] (uart_write_wakeup+0x2c/0x30)
    r5:ed68ea90 r4:c06790d8
    [] (uart_write_wakeup+0x0/0x30) from [] (serial8250_tx_chars+0x114/0x170)
    [] (serial8250_tx_chars+0x0/0x170) from [] (serial8250_handle_irq+0xa0/0xbc)
    r6:000000c2 r5:00000060 r4:c06790d8 r3:00000000
    [] (serial8250_handle_irq+0x0/0xbc) from [] (dw8250_handle_irq+0x38/0x64)
    r7:00000000 r6:edd2f390 r5:000000c2 r4:c06790d8
    [] (dw8250_handle_irq+0x0/0x64) from [] (serial8250_interrupt+0x44/0xc4)
    r6:00000000 r5:00000000 r4:c06791c4 r3:c029336c
    [] (serial8250_interrupt+0x0/0xc4) from [] (handle_irq_event_percpu+0xb4/0x2b0)
    r10:c06790d8 r9:eab27000 r8:00000000 r7:00000000 r6:0000001f r5:edd52980
    r4:ec53b6c0 r3:c028d2b0
    [] (handle_irq_event_percpu+0x0/0x2b0) from [] (handle_irq_event+0x4c/0x6c)
    r10:c06790d8 r9:eab27000 r8:c0673ae0 r7:c05c2020 r6:ec53b6c0 r5:edd529d4
    r4:edd52980
    [] (handle_irq_event+0x0/0x6c) from [] (handle_level_irq+0xe8/0x100)
    r6:00000000 r5:edd529d4 r4:edd52980 r3:00022000
    [] (handle_level_irq+0x0/0x100) from [] (generic_handle_irq+0x30/0x40)
    r5:0000001f r4:0000001f
    [] (generic_handle_irq+0x0/0x40) from [] (handle_IRQ+0xd0/0x13c)
    r4:ea997b18 r3:000000e0
    [] (handle_IRQ+0x0/0x13c) from [] (armada_370_xp_handle_irq+0x4c/0x118)
    r8:000003ff r7:ea997b18 r6:ffffffff r5:60070013 r4:c0674dc0
    [] (armada_370_xp_handle_irq+0x0/0x118) from [] (__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
    [] (_raw_spin_unlock_irqrestore+0x0/0x54) from [] (uart_start+0x40/0x44)
    r4:c06790d8 r3:c028ddd8
    [] (uart_start+0x0/0x44) from [] (uart_write+0xe4/0xf4)
    r6:0000003e r5:00000000 r4:ed68ea90 r3:0000003e
    [] (uart_write+0x0/0xf4) from [] (sl_xmit+0x1c4/0x228 [slip])
    r10:ed388e60 r9:0000003c r8:ffffffdd r7:0000003e r6:ec02754c r5:ea717eb8
    r4:ec027000
    [] (sl_xmit+0x0/0x228 [slip]) from [] (dev_hard_start_xmit+0x39c/0x6d0)
    r8:eaf163c0 r7:ec027000 r6:ea717eb8 r5:00000000 r4:00000000

    Signed-off-by: Tyler Hall
    Cc: Oliver Hartkopp
    Cc: Andre Naujoks
    Cc: David S. Miller
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: David S. Miller

    Tyler Hall
     

28 Apr, 2014

1 commit

  • 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
    Signed-off-by: David S. Miller

    Oliver Hartkopp
     

21 Sep, 2013

1 commit

  • 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
    Acked-by: Oliver Hartkopp
    Acked-by: Marc Kleine-Budde
    Signed-off-by: David S. Miller

    Andre Naujoks
     

19 Jan, 2013

1 commit

  • The option allows you to remove TTY and compile without errors. This
    saves space on systems that won't support TTY interfaces anyway.
    bloat-o-meter output is below.

    The bulk of this patch consists of Kconfig changes adding "depends on
    TTY" to various serial devices and similar drivers that require the TTY
    layer. Ideally, these dependencies would occur on a common intermediate
    symbol such as SERIO, but most drivers "select SERIO" rather than
    "depends on SERIO", and "select" does not respect dependencies.

    bloat-o-meter output comparing our previous minimal to new minimal by
    removing TTY. The list is filtered to not show removed entries with awk
    '$3 != "-"' as the list was very long.

    add/remove: 0/226 grow/shrink: 2/14 up/down: 6/-35356 (-35350)
    function old new delta
    chr_dev_init 166 170 +4
    allow_signal 80 82 +2
    static.__warned 143 142 -1
    disallow_signal 63 62 -1
    __set_special_pids 95 94 -1
    unregister_console 126 121 -5
    start_kernel 546 541 -5
    register_console 593 588 -5
    copy_from_user 45 40 -5
    sys_setsid 128 120 -8
    sys_vhangup 32 19 -13
    do_exit 1543 1526 -17
    bitmap_zero 60 40 -20
    arch_local_irq_save 137 117 -20
    release_task 674 652 -22
    static.spin_unlock_irqrestore 308 260 -48

    Signed-off-by: Joe Millenbach
    Reviewed-by: Jamey Sharp
    Reviewed-by: Josh Triplett
    Signed-off-by: Greg Kroah-Hartman

    Joe Millenbach
     

07 Jun, 2012

1 commit

  • Adding casts of objects to the same type is unnecessary
    and confusing for a human reader.

    For example, this cast:

    int y;
    int *p = (int *)&y;

    I used the coccinelle script below to find and remove these
    unnecessary casts. I manually removed the conversions this
    script produces of casts with __force, __iomem and __user.

    @@
    type T;
    T *p;
    @@

    - (T *)p
    + p

    Signed-off-by: Joe Perches
    Signed-off-by: David S. Miller

    Joe Perches
     

29 Mar, 2012

1 commit


01 Feb, 2012

1 commit


27 Aug, 2011

1 commit