23 Sep, 2016

1 commit


17 Sep, 2016

1 commit


20 Aug, 2016

1 commit

  • We've already set sk to sock->sk and dereferenced it, so if it's NULL
    we would have crashed already. Moreover, if it was NULL we would have
    crashed anyway when jumping to 'out' and trying to unlock the sock.
    Furthermore, if we had assigned a different value to 'sk' we would
    have been calling lock_sock() and release_sock() on different sockets.

    My conclusion is that these two lines are complete nonsense and only
    serve to confuse the reader.

    Signed-off-by: Vegard Nossum
    Signed-off-by: David S. Miller

    Vegard Nossum
     

26 Jul, 2016

1 commit

  • I ran into this:

    kasan: CONFIG_KASAN_INLINE enabled
    kasan: GPF could be caused by NULL-ptr deref or user memory access
    general protection fault: 0000 [#1] PREEMPT SMP KASAN
    CPU: 2 PID: 2012 Comm: trinity-c3 Not tainted 4.7.0-rc7+ #19
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
    task: ffff8800b745f2c0 ti: ffff880111740000 task.ti: ffff880111740000
    RIP: 0010:[] [] irttp_connect_request+0x36/0x710
    RSP: 0018:ffff880111747bb8 EFLAGS: 00010286
    RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000069dd8358
    RDX: 0000000000000009 RSI: 0000000000000027 RDI: 0000000000000048
    RBP: ffff880111747c00 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000069dd8358 R11: 1ffffffff0759723 R12: 0000000000000000
    R13: ffff88011a7e4780 R14: 0000000000000027 R15: 0000000000000000
    FS: 00007fc738404700(0000) GS:ffff88011af00000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007fc737fdfb10 CR3: 0000000118087000 CR4: 00000000000006e0
    Stack:
    0000000000000200 ffff880111747bd8 ffffffff810ee611 ffff880119f1f220
    ffff880119f1f4f8 ffff880119f1f4f0 ffff88011a7e4780 ffff880119f1f232
    ffff880119f1f220 ffff880111747d58 ffffffff82bca542 0000000000000000
    Call Trace:
    [] irda_connect+0x562/0x1190
    [] SYSC_connect+0x202/0x2a0
    [] SyS_connect+0x9/0x10
    [] do_syscall_64+0x19c/0x410
    [] entry_SYSCALL64_slow_path+0x25/0x25
    Code: 41 89 ca 48 89 e5 41 57 41 56 41 55 41 54 41 89 d7 53 48 89 fb 48 83 c7 48 48 89 fa 41 89 f6 48 c1 ea 03 48 83 ec 20 4c 8b 65 10 b6 04 02 84 c0 74 08 84 c0 0f 8e 4c 04 00 00 80 7b 48 00 74
    RIP [] irttp_connect_request+0x36/0x710
    RSP
    ---[ end trace 4cda2588bc055b30 ]---

    The problem is that irda_open_tsap() can fail and leave self->tsap = NULL,
    and then irttp_connect_request() almost immediately dereferences it.

    Cc: stable@vger.kernel.org
    Signed-off-by: Vegard Nossum
    Signed-off-by: David S. Miller

    Vegard Nossum
     

15 Dec, 2015

1 commit

  • 郭永刚 reported that one could simply crash the kernel as root by
    using a simple program:

    int socket_fd;
    struct sockaddr_in addr;
    addr.sin_port = 0;
    addr.sin_addr.s_addr = INADDR_ANY;
    addr.sin_family = 10;

    socket_fd = socket(10,3,0x40000000);
    connect(socket_fd , &addr,16);

    AF_INET, AF_INET6 sockets actually only support 8-bit protocol
    identifiers. inet_sock's skc_protocol field thus is sized accordingly,
    thus larger protocol identifiers simply cut off the higher bits and
    store a zero in the protocol fields.

    This could lead to e.g. NULL function pointer because as a result of
    the cut off inet_num is zero and we call down to inet_autobind, which
    is NULL for raw sockets.

    kernel: Call Trace:
    kernel: [] ? inet_autobind+0x2e/0x70
    kernel: [] inet_dgram_connect+0x54/0x80
    kernel: [] SYSC_connect+0xd9/0x110
    kernel: [] ? ptrace_notify+0x5b/0x80
    kernel: [] ? syscall_trace_enter_phase2+0x108/0x200
    kernel: [] SyS_connect+0xe/0x10
    kernel: [] tracesys_phase2+0x84/0x89

    I found no particular commit which introduced this problem.

    CVE: CVE-2015-8543
    Cc: Cong Wang
    Reported-by: 郭永刚
    Signed-off-by: Hannes Frederic Sowa
    Signed-off-by: David S. Miller

    Hannes Frederic Sowa
     

04 Nov, 2015

1 commit


11 May, 2015

1 commit


03 Mar, 2015

1 commit

  • After TIPC doesn't depend on iocb argument in its internal
    implementations of sendmsg() and recvmsg() hooks defined in proto
    structure, no any user is using iocb argument in them at all now.
    Then we can drop the redundant iocb argument completely from kinds of
    implementations of both sendmsg() and recvmsg() in the entire
    networking stack.

    Cc: Christoph Hellwig
    Suggested-by: Al Viro
    Signed-off-by: Ying Xue
    Signed-off-by: David S. Miller

    Ying Xue
     

24 Nov, 2014

2 commits


14 Nov, 2014

1 commit


13 Nov, 2014

1 commit

  • Use the normal kernel debugging mechanism which also
    enables dynamic_debug at the same time.

    Other miscellanea:

    o Remove sysctl for irda_debug
    o Remove function tracing like uses (use ftrace instead)
    o Coalesce formats
    o Realign arguments
    o Remove unnecessary OOM messages

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

    Joe Perches
     

12 Nov, 2014

1 commit

  • And use the more common mechanisms directly.

    Other miscellanea:

    o Coalesce formats
    o Add missing newlines
    o Realign arguments
    o Remove unnecessary OOM message logging as
    there's a generic stack dump already on OOM.

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

    Joe Perches
     

06 Nov, 2014

1 commit

  • This encapsulates all of the skb_copy_datagram_iovec() callers
    with call argument signature "skb, offset, msghdr->msg_iov, length".

    When we move to iov_iters in the networking, the iov_iter object will
    sit in the msghdr.

    Having a helper like this means there will be less places to touch
    during that transformation.

    Based upon descriptions and patch from Al Viro.

    Signed-off-by: David S. Miller

    David S. Miller
     

03 Nov, 2014

1 commit

  • The sk_prot is irda's own set of protocol handlers, so irda should
    statically know what that function is anyway, without using an indirect
    pointer. And as it happens, we know *exactly* what that pointer is
    statically: it's NULL, because irda doesn't define a disconnect
    operation.

    So calling that function is doubly wrong, and will just cause an oops.

    Reported-by: Martin Lang
    Cc: Samuel Ortiz
    Cc: David Miller
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

16 Jul, 2014

1 commit


19 Jan, 2014

1 commit

  • This is a follow-up patch to f3d3342602f8bc ("net: rework recvmsg
    handler msg_name and msg_namelen logic").

    DECLARE_SOCKADDR validates that the structure we use for writing the
    name information to is not larger than the buffer which is reserved
    for msg->msg_name (which is 128 bytes). Also use DECLARE_SOCKADDR
    consistently in sendmsg code paths.

    Signed-off-by: Steffen Hurrle
    Suggested-by: Hannes Frederic Sowa
    Acked-by: Hannes Frederic Sowa
    Signed-off-by: David S. Miller

    Steffen Hurrle
     

07 Dec, 2013

1 commit

  • Several files refer to an old address for the Free Software Foundation
    in the file header comment. Resolve by replacing the address with
    the URL so that we do not have to keep
    updating the header comments anytime the address changes.

    CC: Samuel Ortiz
    Signed-off-by: Jeff Kirsher
    Signed-off-by: David S. Miller

    Jeff Kirsher
     

21 Nov, 2013

1 commit


04 Oct, 2013

1 commit

  • Change all __wait_event*() implementations to match the corresponding
    wait_event*() signature for convenience.

    In particular this does away with the weird 'ret' logic. Since there
    are __wait_event*() users this requires we update them too.

    Reviewed-by: Oleg Nesterov
    Signed-off-by: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20131002092529.042563462@infradead.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

09 Apr, 2013

2 commits


08 Apr, 2013

1 commit

  • The current code does not fill the msg_name member in case it is set.
    It also does not set the msg_namelen member to 0 and therefore makes
    net/socket.c leak the local, uninitialized sockaddr_storage variable
    to userland -- 128 bytes of kernel stack memory.

    Fix that by simply setting msg_namelen to 0 as obviously nobody cared
    about irda_recvmsg_dgram() not filling the msg_name in case it was
    set.

    Cc: Samuel Ortiz
    Signed-off-by: Mathias Krause
    Signed-off-by: David S. Miller

    Mathias Krause
     

21 Mar, 2013

1 commit


05 Feb, 2013

1 commit


05 Oct, 2012

1 commit

  • Fuzzing causes these printks to spew constantly.
    Changing them to DEBUG statements is consistent with other usage in the file,
    and makes them disappear when CONFIG_IRDA_DEBUG is disabled.

    Signed-off-by: Dave Jones
    Signed-off-by: David S. Miller

    Dave Jones
     

17 Jul, 2012

1 commit


22 Dec, 2011

1 commit


17 Jun, 2011

1 commit

  • Unnecessary casts of void * clutter the code.

    These are the remainder casts after several specific
    patches to remove netdev_priv and dev_priv.

    Done via coccinelle script:

    $ cat cast_void_pointer.cocci
    @@
    type T;
    T *pt;
    void *pv;
    @@

    - pt = (T *)pv;
    + pt = pv;

    Signed-off-by: Joe Perches
    Acked-by: Paul Moore
    Signed-off-by: David S. Miller

    Joe Perches
     

13 Apr, 2011

1 commit

  • 5b40964eadea40509d353318d2c82e8b7bf5e8a5 ("irda: Remove BKL instances
    from af_irda.c") introduced a path where we have a locking unbalance.
    If we pass invalid flags, we unlock a socket we never locked,
    resulting in this...

    =====================================
    [ BUG: bad unlock balance detected! ]
    -------------------------------------
    trinity/20101 is trying to release lock (sk_lock-AF_IRDA) at:
    [] irda_sendmsg+0x207/0x21d [irda]
    but there are no more locks to release!

    other info that might help us debug this:
    no locks held by trinity/20101.

    stack backtrace:
    Pid: 20101, comm: trinity Not tainted 2.6.39-rc3+ #3
    Call Trace:
    [] ? irda_sendmsg+0x207/0x21d [irda]
    [] print_unlock_inbalance_bug+0xc7/0xd2
    [] ? irda_sendmsg+0x207/0x21d [irda]
    [] lock_release+0xcf/0x18e
    [] release_sock+0x2d/0x155
    [] irda_sendmsg+0x207/0x21d [irda]
    [] __sock_sendmsg+0x69/0x75
    [] sock_sendmsg+0xa1/0xb6
    [] ? might_fault+0x5c/0xac
    [] ? lock_release+0x181/0x18e
    [] ? might_fault+0xa5/0xac
    [] ? might_fault+0x5c/0xac
    [] ? fcheck_files+0xb9/0xf0
    [] ? copy_from_user+0x2f/0x31
    [] ? verify_iovec+0x52/0xa6
    [] sys_sendmsg+0x23a/0x2b8
    [] ? lock_release+0x181/0x18e
    [] ? up_read+0x28/0x2c
    [] ? do_page_fault+0x360/0x3b4
    [] ? trace_hardirqs_on_caller+0x10b/0x12f
    [] ? finish_task_switch+0xb2/0xe3
    [] ? finish_task_switch+0x46/0xe3
    [] ? trace_hardirqs_off_caller+0x33/0x90
    [] ? retint_swapgs+0x13/0x1b
    [] ? trace_hardirqs_on_caller+0x10b/0x12f
    [] ? audit_syscall_entry+0x11c/0x148
    [] ? trace_hardirqs_on_thunk+0x3a/0x3f
    [] system_call_fastpath+0x16/0x1b

    Signed-off-by: Dave Jones
    Signed-off-by: David S. Miller

    Dave Jones
     

27 Dec, 2010

1 commit

  • * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (42 commits)
    ipv4: dont create routes on down devices
    epic100: hamachi: yellowfin: Fix skb allocation size
    sundance: Fix oopses with corrupted skb_shared_info
    Revert "ipv4: Allow configuring subnets as local addresses"
    USB: mcs7830: return negative if auto negotiate fails
    irda: prevent integer underflow in IRLMP_ENUMDEVICES
    tcp: fix listening_get_next()
    atl1c: Do not use legacy PCI power management
    mac80211: fix mesh forwarding
    MAINTAINERS: email address change
    net: Fix range checks in tcf_valid_offset().
    net_sched: sch_sfq: fix allot handling
    hostap: remove netif_stop_queue from init
    mac80211/rt2x00: add ieee80211_tx_status_ni()
    typhoon: memory corruption in typhoon_get_drvinfo()
    net: Add USB PID for new MOSCHIP USB ethernet controller MCS7832 variant
    net_sched: always clone skbs
    ipv6: Fragment locally generated tunnel-mode IPSec6 packets as needed.
    netlink: fix gcc -Wconversion compilation warning
    asix: add USB ID for Logitec LAN-GTJ U2A
    ...

    Linus Torvalds
     

24 Dec, 2010

1 commit

  • If the user-provided len is less than the expected offset, the
    IRLMP_ENUMDEVICES getsockopt will do a copy_to_user() with a very large
    size value. While this isn't be a security issue on x86 because it will
    get caught by the access_ok() check, it may leak large amounts of kernel
    heap on other architectures. In any event, this patch fixes it.

    Signed-off-by: Dan Rosenberg
    Signed-off-by: David S. Miller

    Dan Rosenberg
     

18 Nov, 2010

1 commit


11 Oct, 2010

1 commit


24 Sep, 2010

1 commit


31 Aug, 2010

1 commit

  • If irda_open_tsap() fails, the irda_bind() code tries to destroy
    the ->ias_obj object by hand, but does so wrongly.

    In particular, it fails to a) release the hashbin attached to the
    object and b) reset the self->ias_obj pointer to NULL.

    Fix both problems by using irias_delete_object() and explicitly
    setting self->ias_obj to NULL, just as irda_release() does.

    Reported-by: Tavis Ormandy
    Signed-off-by: David S. Miller

    David S. Miller
     

21 Apr, 2010

1 commit

  • Define a new function to return the waitqueue of a "struct sock".

    static inline wait_queue_head_t *sk_sleep(struct sock *sk)
    {
    return sk->sk_sleep;
    }

    Change all read occurrences of sk_sleep by a call to this function.

    Needed for a future RCU conversion. sk_sleep wont be a field directly
    available.

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

07 Nov, 2009

1 commit

  • The irda driver uses the BKL implicitly in its protocol
    operations. Replace the wrapped proto_ops with explicit
    lock_kernel() calls makes the usage more obvious and
    shrinks the size of the object code.

    The calls t lock_kernel() should eventually all be replaced
    by other serialization methods, which requires finding out

    The calls t lock_kernel() should eventually all be replaced
    by other serialization methods, which requires finding out
    which data actually needs protection.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: David S. Miller

    Arnd Bergmann
     

06 Nov, 2009

1 commit

  • The generic __sock_create function has a kern argument which allows the
    security system to make decisions based on if a socket is being created by
    the kernel or by userspace. This patch passes that flag to the
    net_proto_family specific create function, so it can do the same thing.

    Signed-off-by: Eric Paris
    Acked-by: Arnaldo Carvalho de Melo
    Signed-off-by: David S. Miller

    Eric Paris