25 Jul, 2020

1 commit

  • Rework the remaining setsockopt code to pass a sockptr_t instead of a
    plain user pointer. This removes the last remaining set_fs(KERNEL_DS)
    outside of architecture specific code.

    Signed-off-by: Christoph Hellwig
    Acked-by: Stefan Schmidt [ieee802154]
    Acked-by: Matthieu Baerts
    Signed-off-by: David S. Miller

    Christoph Hellwig
     

14 Jul, 2020

1 commit


29 Jun, 2020

1 commit

  • syzbot was to trigger a bug by tricking AF_LLC with
    non sensible addr->sllc_arphrd

    It seems clear LLC requires an Ethernet device.

    Back in commit abf9d537fea2 ("llc: add support for SO_BINDTODEVICE")
    Octavian Purdila added possibility for application to use a zero
    value for sllc_arphrd, convert it to ARPHRD_ETHER to not cause
    regressions on existing applications.

    BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:199 [inline]
    BUG: KASAN: use-after-free in list_empty include/linux/list.h:268 [inline]
    BUG: KASAN: use-after-free in waitqueue_active include/linux/wait.h:126 [inline]
    BUG: KASAN: use-after-free in wq_has_sleeper include/linux/wait.h:160 [inline]
    BUG: KASAN: use-after-free in skwq_has_sleeper include/net/sock.h:2092 [inline]
    BUG: KASAN: use-after-free in sock_def_write_space+0x642/0x670 net/core/sock.c:2813
    Read of size 8 at addr ffff88801e0b4078 by task ksoftirqd/3/27

    CPU: 3 PID: 27 Comm: ksoftirqd/3 Not tainted 5.5.0-rc1-syzkaller #0
    Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
    Call Trace:
    __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:639
    __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135
    __read_once_size include/linux/compiler.h:199 [inline]
    list_empty include/linux/list.h:268 [inline]
    waitqueue_active include/linux/wait.h:126 [inline]
    wq_has_sleeper include/linux/wait.h:160 [inline]
    skwq_has_sleeper include/net/sock.h:2092 [inline]
    sock_def_write_space+0x642/0x670 net/core/sock.c:2813
    sock_wfree+0x1e1/0x260 net/core/sock.c:1958
    skb_release_head_state+0xeb/0x260 net/core/skbuff.c:652
    skb_release_all+0x16/0x60 net/core/skbuff.c:663
    __kfree_skb net/core/skbuff.c:679 [inline]
    consume_skb net/core/skbuff.c:838 [inline]
    consume_skb+0xfb/0x410 net/core/skbuff.c:832
    __dev_kfree_skb_any+0xa4/0xd0 net/core/dev.c:2967
    dev_kfree_skb_any include/linux/netdevice.h:3650 [inline]
    e1000_unmap_and_free_tx_resource.isra.0+0x21b/0x3a0 drivers/net/ethernet/intel/e1000/e1000_main.c:1963
    e1000_clean_tx_irq drivers/net/ethernet/intel/e1000/e1000_main.c:3854 [inline]
    e1000_clean+0x4cc/0x1d10 drivers/net/ethernet/intel/e1000/e1000_main.c:3796
    napi_poll net/core/dev.c:6532 [inline]
    net_rx_action+0x508/0x1120 net/core/dev.c:6600
    __do_softirq+0x262/0x98c kernel/softirq.c:292
    run_ksoftirqd kernel/softirq.c:603 [inline]
    run_ksoftirqd+0x8e/0x110 kernel/softirq.c:595
    smpboot_thread_fn+0x6a3/0xa40 kernel/smpboot.c:165
    kthread+0x361/0x430 kernel/kthread.c:255
    ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

    Allocated by task 8247:
    save_stack+0x23/0x90 mm/kasan/common.c:72
    set_track mm/kasan/common.c:80 [inline]
    __kasan_kmalloc mm/kasan/common.c:513 [inline]
    __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:486
    kasan_slab_alloc+0xf/0x20 mm/kasan/common.c:521
    slab_post_alloc_hook mm/slab.h:584 [inline]
    slab_alloc mm/slab.c:3320 [inline]
    kmem_cache_alloc+0x121/0x710 mm/slab.c:3484
    sock_alloc_inode+0x1c/0x1d0 net/socket.c:240
    alloc_inode+0x68/0x1e0 fs/inode.c:230
    new_inode_pseudo+0x19/0xf0 fs/inode.c:919
    sock_alloc+0x41/0x270 net/socket.c:560
    __sock_create+0xc2/0x730 net/socket.c:1384
    sock_create net/socket.c:1471 [inline]
    __sys_socket+0x103/0x220 net/socket.c:1513
    __do_sys_socket net/socket.c:1522 [inline]
    __se_sys_socket net/socket.c:1520 [inline]
    __ia32_sys_socket+0x73/0xb0 net/socket.c:1520
    do_syscall_32_irqs_on arch/x86/entry/common.c:337 [inline]
    do_fast_syscall_32+0x27b/0xe16 arch/x86/entry/common.c:408
    entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139

    Freed by task 17:
    save_stack+0x23/0x90 mm/kasan/common.c:72
    set_track mm/kasan/common.c:80 [inline]
    kasan_set_free_info mm/kasan/common.c:335 [inline]
    __kasan_slab_free+0x102/0x150 mm/kasan/common.c:474
    kasan_slab_free+0xe/0x10 mm/kasan/common.c:483
    __cache_free mm/slab.c:3426 [inline]
    kmem_cache_free+0x86/0x320 mm/slab.c:3694
    sock_free_inode+0x20/0x30 net/socket.c:261
    i_callback+0x44/0x80 fs/inode.c:219
    __rcu_reclaim kernel/rcu/rcu.h:222 [inline]
    rcu_do_batch kernel/rcu/tree.c:2183 [inline]
    rcu_core+0x570/0x1540 kernel/rcu/tree.c:2408
    rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2417
    __do_softirq+0x262/0x98c kernel/softirq.c:292

    The buggy address belongs to the object at ffff88801e0b4000
    which belongs to the cache sock_inode_cache of size 1152
    The buggy address is located 120 bytes inside of
    1152-byte region [ffff88801e0b4000, ffff88801e0b4480)
    The buggy address belongs to the page:
    page:ffffea0000782d00 refcount:1 mapcount:0 mapping:ffff88807aa59c40 index:0xffff88801e0b4ffd
    raw: 00fffe0000000200 ffffea00008e6c88 ffffea0000782d48 ffff88807aa59c40
    raw: ffff88801e0b4ffd ffff88801e0b4000 0000000100000003 0000000000000000
    page dumped because: kasan: bad access detected

    Memory state around the buggy address:
    ffff88801e0b3f00: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
    ffff88801e0b3f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
    >ffff88801e0b4000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    ^
    ffff88801e0b4080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    ffff88801e0b4100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb

    Fixes: abf9d537fea2 ("llc: add support for SO_BINDTODEVICE")
    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

27 Feb, 2020

1 commit

  • When debugging via dprintk() is not enabled, make the dprintk()
    macro be an empty do-while loop, as is done in
    .

    This fixes a gcc warning when -Wextra is set:
    ../net/llc/af_llc.c:974:51: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]

    I have verified that there is not object code change (with gcc 7.5.0).

    Signed-off-by: Randy Dunlap
    Cc: netdev@vger.kernel.org
    Cc: "David S. Miller"
    Signed-off-by: David S. Miller

    Randy Dunlap
     

25 Feb, 2020

1 commit

  • Sparse reports a warning at llc_seq_start()

    warning: context imbalance in llc_seq_start() - wrong count at exit
    The root cause is the msiing annotation at llc_seq_start()

    Add the missing __acquires(RCU) annotation

    Signed-off-by: Jules Irenge
    Signed-off-by: David S. Miller

    Jules Irenge
     

21 Dec, 2019

1 commit

  • When a frame with NULL DSAP is received, llc_station_rcv is called.
    In turn, llc_stat_ev_rx_null_dsap_xid_c is called to check if it is a NULL
    XID frame. The return statement of llc_stat_ev_rx_null_dsap_xid_c returns 1
    when the incoming frame is not a NULL XID frame and 0 otherwise. Hence, a
    NULL XID response is returned unexpectedly, e.g. when the incoming frame is
    a NULL TEST command.

    To fix the error, simply remove the conditional operator.

    A similar error in llc_stat_ev_rx_null_dsap_test_c is also fixed.

    Signed-off-by: Chan Shu Tak, Alex
    Signed-off-by: David S. Miller

    Chan Shu Tak, Alex
     

07 Nov, 2019

2 commits

  • sk->sk_backlog.tail might be read without holding the socket spinlock,
    we need to add proper READ_ONCE()/WRITE_ONCE() to silence the warnings.

    KCSAN reported :

    BUG: KCSAN: data-race in tcp_add_backlog / tcp_recvmsg

    write to 0xffff8881265109f8 of 8 bytes by interrupt on cpu 1:
    __sk_add_backlog include/net/sock.h:907 [inline]
    sk_add_backlog include/net/sock.h:938 [inline]
    tcp_add_backlog+0x476/0xce0 net/ipv4/tcp_ipv4.c:1759
    tcp_v4_rcv+0x1a70/0x1bd0 net/ipv4/tcp_ipv4.c:1947
    ip_protocol_deliver_rcu+0x4d/0x420 net/ipv4/ip_input.c:204
    ip_local_deliver_finish+0x110/0x140 net/ipv4/ip_input.c:231
    NF_HOOK include/linux/netfilter.h:305 [inline]
    NF_HOOK include/linux/netfilter.h:299 [inline]
    ip_local_deliver+0x133/0x210 net/ipv4/ip_input.c:252
    dst_input include/net/dst.h:442 [inline]
    ip_rcv_finish+0x121/0x160 net/ipv4/ip_input.c:413
    NF_HOOK include/linux/netfilter.h:305 [inline]
    NF_HOOK include/linux/netfilter.h:299 [inline]
    ip_rcv+0x18f/0x1a0 net/ipv4/ip_input.c:523
    __netif_receive_skb_one_core+0xa7/0xe0 net/core/dev.c:4929
    __netif_receive_skb+0x37/0xf0 net/core/dev.c:5043
    netif_receive_skb_internal+0x59/0x190 net/core/dev.c:5133
    napi_skb_finish net/core/dev.c:5596 [inline]
    napi_gro_receive+0x28f/0x330 net/core/dev.c:5629
    receive_buf+0x284/0x30b0 drivers/net/virtio_net.c:1061
    virtnet_receive drivers/net/virtio_net.c:1323 [inline]
    virtnet_poll+0x436/0x7d0 drivers/net/virtio_net.c:1428
    napi_poll net/core/dev.c:6311 [inline]
    net_rx_action+0x3ae/0xa90 net/core/dev.c:6379
    __do_softirq+0x115/0x33f kernel/softirq.c:292
    invoke_softirq kernel/softirq.c:373 [inline]
    irq_exit+0xbb/0xe0 kernel/softirq.c:413
    exiting_irq arch/x86/include/asm/apic.h:536 [inline]
    do_IRQ+0xa6/0x180 arch/x86/kernel/irq.c:263
    ret_from_intr+0x0/0x19
    native_safe_halt+0xe/0x10 arch/x86/kernel/paravirt.c:71
    arch_cpu_idle+0x1f/0x30 arch/x86/kernel/process.c:571
    default_idle_call+0x1e/0x40 kernel/sched/idle.c:94
    cpuidle_idle_call kernel/sched/idle.c:154 [inline]
    do_idle+0x1af/0x280 kernel/sched/idle.c:263
    cpu_startup_entry+0x1b/0x20 kernel/sched/idle.c:355
    start_secondary+0x208/0x260 arch/x86/kernel/smpboot.c:264
    secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:241

    read to 0xffff8881265109f8 of 8 bytes by task 8057 on cpu 0:
    tcp_recvmsg+0x46e/0x1b40 net/ipv4/tcp.c:2050
    inet_recvmsg+0xbb/0x250 net/ipv4/af_inet.c:838
    sock_recvmsg_nosec net/socket.c:871 [inline]
    sock_recvmsg net/socket.c:889 [inline]
    sock_recvmsg+0x92/0xb0 net/socket.c:885
    sock_read_iter+0x15f/0x1e0 net/socket.c:967
    call_read_iter include/linux/fs.h:1889 [inline]
    new_sync_read+0x389/0x4f0 fs/read_write.c:414
    __vfs_read+0xb1/0xc0 fs/read_write.c:427
    vfs_read fs/read_write.c:461 [inline]
    vfs_read+0x143/0x2c0 fs/read_write.c:446
    ksys_read+0xd5/0x1b0 fs/read_write.c:587
    __do_sys_read fs/read_write.c:597 [inline]
    __se_sys_read fs/read_write.c:595 [inline]
    __x64_sys_read+0x4c/0x60 fs/read_write.c:595
    do_syscall_64+0xcc/0x370 arch/x86/entry/common.c:290
    entry_SYSCALL_64_after_hwframe+0x44/0xa9

    Reported by Kernel Concurrency Sanitizer on:
    CPU: 0 PID: 8057 Comm: syz-fuzzer Not tainted 5.4.0-rc6+ #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011

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

    Eric Dumazet
     
  • Writers are holding a lock, but many readers do not.

    Following patch will add appropriate barriers in
    sk_acceptq_removed() and sk_acceptq_added().

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

    Eric Dumazet
     

10 Oct, 2019

1 commit

  • sk_add_backlog() callers usually read sk->sk_rcvbuf without
    owning the socket lock. This means sk_rcvbuf value can
    be changed by other cpus, and KCSAN complains.

    Add READ_ONCE() annotations to document the lockless nature
    of these reads.

    Note that writes over sk_rcvbuf should also use WRITE_ONCE(),
    but this will be done in separate patches to ease stable
    backports (if we decide this is relevant for stable trees).

    BUG: KCSAN: data-race in tcp_add_backlog / tcp_recvmsg

    write to 0xffff88812ab369f8 of 8 bytes by interrupt on cpu 1:
    __sk_add_backlog include/net/sock.h:902 [inline]
    sk_add_backlog include/net/sock.h:933 [inline]
    tcp_add_backlog+0x45a/0xcc0 net/ipv4/tcp_ipv4.c:1737
    tcp_v4_rcv+0x1aba/0x1bf0 net/ipv4/tcp_ipv4.c:1925
    ip_protocol_deliver_rcu+0x51/0x470 net/ipv4/ip_input.c:204
    ip_local_deliver_finish+0x110/0x140 net/ipv4/ip_input.c:231
    NF_HOOK include/linux/netfilter.h:305 [inline]
    NF_HOOK include/linux/netfilter.h:299 [inline]
    ip_local_deliver+0x133/0x210 net/ipv4/ip_input.c:252
    dst_input include/net/dst.h:442 [inline]
    ip_rcv_finish+0x121/0x160 net/ipv4/ip_input.c:413
    NF_HOOK include/linux/netfilter.h:305 [inline]
    NF_HOOK include/linux/netfilter.h:299 [inline]
    ip_rcv+0x18f/0x1a0 net/ipv4/ip_input.c:523
    __netif_receive_skb_one_core+0xa7/0xe0 net/core/dev.c:5004
    __netif_receive_skb+0x37/0xf0 net/core/dev.c:5118
    netif_receive_skb_internal+0x59/0x190 net/core/dev.c:5208
    napi_skb_finish net/core/dev.c:5671 [inline]
    napi_gro_receive+0x28f/0x330 net/core/dev.c:5704
    receive_buf+0x284/0x30b0 drivers/net/virtio_net.c:1061
    virtnet_receive drivers/net/virtio_net.c:1323 [inline]
    virtnet_poll+0x436/0x7d0 drivers/net/virtio_net.c:1428
    napi_poll net/core/dev.c:6352 [inline]
    net_rx_action+0x3ae/0xa50 net/core/dev.c:6418

    read to 0xffff88812ab369f8 of 8 bytes by task 7271 on cpu 0:
    tcp_recvmsg+0x470/0x1a30 net/ipv4/tcp.c:2047
    inet_recvmsg+0xbb/0x250 net/ipv4/af_inet.c:838
    sock_recvmsg_nosec net/socket.c:871 [inline]
    sock_recvmsg net/socket.c:889 [inline]
    sock_recvmsg+0x92/0xb0 net/socket.c:885
    sock_read_iter+0x15f/0x1e0 net/socket.c:967
    call_read_iter include/linux/fs.h:1864 [inline]
    new_sync_read+0x389/0x4f0 fs/read_write.c:414
    __vfs_read+0xb1/0xc0 fs/read_write.c:427
    vfs_read fs/read_write.c:461 [inline]
    vfs_read+0x143/0x2c0 fs/read_write.c:446
    ksys_read+0xd5/0x1b0 fs/read_write.c:587
    __do_sys_read fs/read_write.c:597 [inline]
    __se_sys_read fs/read_write.c:595 [inline]
    __x64_sys_read+0x4c/0x60 fs/read_write.c:595
    do_syscall_64+0xcf/0x2f0 arch/x86/entry/common.c:296
    entry_SYSCALL_64_after_hwframe+0x44/0xa9

    Reported by Kernel Concurrency Sanitizer on:
    CPU: 0 PID: 7271 Comm: syz-fuzzer Not tainted 5.3.0+ #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011

    Signed-off-by: Eric Dumazet
    Reported-by: syzbot
    Signed-off-by: Jakub Kicinski

    Eric Dumazet
     

09 Oct, 2019

4 commits

  • If llc_conn_state_process() sees that llc_conn_service() put the skb on
    a list, it will drop one fewer references to it. This is wrong because
    the current behavior is that llc_conn_service() never consumes a
    reference to the skb.

    The code also makes the number of skb references being dropped
    conditional on which of ind_prim and cfm_prim are nonzero, yet neither
    of these affects how many references are *acquired*. So there is extra
    code that tries to fix this up by sometimes taking another reference.

    Remove the unnecessary/broken refcounting logic and instead just add an
    skb_get() before the only two places where an extra reference is
    actually consumed.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Eric Biggers
    Signed-off-by: Jakub Kicinski

    Eric Biggers
     
  • All callers of llc_conn_state_process() except llc_build_and_send_pkt()
    (via llc_ui_sendmsg() -> llc_ui_send_data()) assume that it always
    consumes a reference to the skb. Fix this caller to do the same.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Eric Biggers
    Signed-off-by: Jakub Kicinski

    Eric Biggers
     
  • syzbot reported:

    BUG: memory leak
    unreferenced object 0xffff88811eb3de00 (size 224):
    comm "syz-executor559", pid 7315, jiffies 4294943019 (age 10.300s)
    hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    00 a0 38 24 81 88 ff ff 00 c0 f2 15 81 88 ff ff ..8$............
    backtrace:
    [] kmemleak_alloc_recursive include/linux/kmemleak.h:55 [inline]
    [] slab_post_alloc_hook mm/slab.h:439 [inline]
    [] slab_alloc_node mm/slab.c:3269 [inline]
    [] kmem_cache_alloc_node+0x153/0x2a0 mm/slab.c:3579
    [] __alloc_skb+0x6e/0x210 net/core/skbuff.c:198
    [] alloc_skb include/linux/skbuff.h:1058 [inline]
    [] llc_alloc_frame+0x66/0x110 net/llc/llc_sap.c:54
    [] llc_conn_ac_send_sabme_cmd_p_set_x+0x2f/0x140 net/llc/llc_c_ac.c:777
    [] llc_exec_conn_trans_actions net/llc/llc_conn.c:475 [inline]
    [] llc_conn_service net/llc/llc_conn.c:400 [inline]
    [] llc_conn_state_process+0x1ac/0x640 net/llc/llc_conn.c:75
    [] llc_establish_connection+0x110/0x170 net/llc/llc_if.c:109
    [] llc_ui_connect+0x10e/0x370 net/llc/af_llc.c:477
    [] __sys_connect+0x11d/0x170 net/socket.c:1840
    [...]

    The bug is that most callers of llc_conn_send_pdu() assume it consumes a
    reference to the skb, when actually due to commit b85ab56c3f81 ("llc:
    properly handle dev_queue_xmit() return value") it doesn't.

    Revert most of that commit, and instead make the few places that need
    llc_conn_send_pdu() to *not* consume a reference call skb_get() before.

    Fixes: b85ab56c3f81 ("llc: properly handle dev_queue_xmit() return value")
    Reported-by: syzbot+6b825a6494a04cc0e3f7@syzkaller.appspotmail.com
    Signed-off-by: Eric Biggers
    Signed-off-by: Jakub Kicinski

    Eric Biggers
     
  • syzbot reported:

    BUG: memory leak
    unreferenced object 0xffff888116270800 (size 224):
    comm "syz-executor641", pid 7047, jiffies 4294947360 (age 13.860s)
    hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    00 20 e1 2a 81 88 ff ff 00 40 3d 2a 81 88 ff ff . .*.....@=*....
    backtrace:
    [] kmemleak_alloc_recursive include/linux/kmemleak.h:55 [inline]
    [] slab_post_alloc_hook mm/slab.h:439 [inline]
    [] slab_alloc_node mm/slab.c:3269 [inline]
    [] kmem_cache_alloc_node+0x153/0x2a0 mm/slab.c:3579
    [] __alloc_skb+0x6e/0x210 net/core/skbuff.c:198
    [] alloc_skb include/linux/skbuff.h:1058 [inline]
    [] alloc_skb_with_frags+0x5f/0x250 net/core/skbuff.c:5327
    [] sock_alloc_send_pskb+0x269/0x2a0 net/core/sock.c:2225
    [] sock_alloc_send_skb+0x32/0x40 net/core/sock.c:2242
    [] llc_ui_sendmsg+0x10a/0x540 net/llc/af_llc.c:933
    [] sock_sendmsg_nosec net/socket.c:652 [inline]
    [] sock_sendmsg+0x54/0x70 net/socket.c:671
    [] __sys_sendto+0x148/0x1f0 net/socket.c:1964
    [...]

    The bug is that llc_sap_state_process() always takes an extra reference
    to the skb, but sometimes neither llc_sap_next_state() nor
    llc_sap_state_process() itself drops this reference.

    Fix it by changing llc_sap_next_state() to never consume a reference to
    the skb, rather than sometimes do so and sometimes not. Then remove the
    extra skb_get() and kfree_skb() from llc_sap_state_process().

    Reported-by: syzbot+6bf095f9becf5efef645@syzkaller.appspotmail.com
    Reported-by: syzbot+31c16aa4202dace3812e@syzkaller.appspotmail.com
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Eric Biggers
    Signed-off-by: Jakub Kicinski

    Eric Biggers
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program can be redistributed or modified under the terms of the
    gnu general public license version 2 as published by the free
    software foundation this program is distributed without any warranty
    or implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license version 2 for more
    details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 1 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Alexios Zavras
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190529141900.551133917@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

29 May, 2019

1 commit

  • If llc_mac_hdr_init() returns an error, we must drop the skb
    since no llc_build_and_send_ui_pkt() caller will take care of this.

    BUG: memory leak
    unreferenced object 0xffff8881202b6800 (size 2048):
    comm "syz-executor907", pid 7074, jiffies 4294943781 (age 8.590s)
    hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    1a 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00 ...@............
    backtrace:
    [] kmemleak_alloc_recursive include/linux/kmemleak.h:55 [inline]
    [] slab_post_alloc_hook mm/slab.h:439 [inline]
    [] slab_alloc mm/slab.c:3326 [inline]
    [] __do_kmalloc mm/slab.c:3658 [inline]
    [] __kmalloc+0x161/0x2c0 mm/slab.c:3669
    [] kmalloc include/linux/slab.h:552 [inline]
    [] sk_prot_alloc+0xd6/0x170 net/core/sock.c:1608
    [] sk_alloc+0x35/0x2f0 net/core/sock.c:1662
    [] llc_sk_alloc+0x35/0x170 net/llc/llc_conn.c:950
    [] llc_ui_create+0x7b/0x140 net/llc/af_llc.c:173
    [] __sock_create+0x164/0x250 net/socket.c:1430
    [] sock_create net/socket.c:1481 [inline]
    [] __sys_socket+0x69/0x110 net/socket.c:1523
    [] __do_sys_socket net/socket.c:1532 [inline]
    [] __se_sys_socket net/socket.c:1530 [inline]
    [] __x64_sys_socket+0x1e/0x30 net/socket.c:1530
    [] do_syscall_64+0x76/0x1a0 arch/x86/entry/common.c:301
    [] entry_SYSCALL_64_after_hwframe+0x44/0xa9

    BUG: memory leak
    unreferenced object 0xffff88811d750d00 (size 224):
    comm "syz-executor907", pid 7074, jiffies 4294943781 (age 8.600s)
    hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    00 f0 0c 24 81 88 ff ff 00 68 2b 20 81 88 ff ff ...$.....h+ ....
    backtrace:
    [] kmemleak_alloc_recursive include/linux/kmemleak.h:55 [inline]
    [] slab_post_alloc_hook mm/slab.h:439 [inline]
    [] slab_alloc_node mm/slab.c:3269 [inline]
    [] kmem_cache_alloc_node+0x153/0x2a0 mm/slab.c:3579
    [] __alloc_skb+0x6e/0x210 net/core/skbuff.c:198
    [] alloc_skb include/linux/skbuff.h:1058 [inline]
    [] alloc_skb_with_frags+0x5f/0x250 net/core/skbuff.c:5327
    [] sock_alloc_send_pskb+0x269/0x2a0 net/core/sock.c:2225
    [] sock_alloc_send_skb+0x32/0x40 net/core/sock.c:2242
    [] llc_ui_sendmsg+0x10a/0x540 net/llc/af_llc.c:933
    [] sock_sendmsg_nosec net/socket.c:652 [inline]
    [] sock_sendmsg+0x54/0x70 net/socket.c:671
    [] __sys_sendto+0x148/0x1f0 net/socket.c:1964
    [] __do_sys_sendto net/socket.c:1976 [inline]
    [] __se_sys_sendto net/socket.c:1972 [inline]
    [] __x64_sys_sendto+0x2a/0x30 net/socket.c:1972
    [] do_syscall_64+0x76/0x1a0 arch/x86/entry/common.c:301
    [] entry_SYSCALL_64_after_hwframe+0x44/0xa9

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Eric Dumazet
    Reported-by: syzbot
    Signed-off-by: David S. Miller

    Eric Dumazet
     

21 May, 2019

1 commit


13 Apr, 2019

1 commit


23 Oct, 2018

1 commit

  • syzkaller triggered a use-after-free [1], caused by a combination of
    skb_get() in llc_conn_state_process() and usage of sk_eat_skb()

    sk_eat_skb() is assuming the skb about to be freed is only used by
    the current thread. TCP/DCCP stacks enforce this because current
    thread holds the socket lock.

    llc_conn_state_process() wants to make sure skb does not disappear,
    and holds a reference on the skb it manipulates. But as soon as this
    skb is added to socket receive queue, another thread can consume it.

    This means that llc must use regular skb_unlink() and kfree_skb()
    so that both producer and consumer can safely work on the same skb.

    [1]
    BUG: KASAN: use-after-free in atomic_read include/asm-generic/atomic-instrumented.h:21 [inline]
    BUG: KASAN: use-after-free in refcount_read include/linux/refcount.h:43 [inline]
    BUG: KASAN: use-after-free in skb_unref include/linux/skbuff.h:967 [inline]
    BUG: KASAN: use-after-free in kfree_skb+0xb7/0x580 net/core/skbuff.c:655
    Read of size 4 at addr ffff8801d1f6fba4 by task ksoftirqd/1/18

    CPU: 1 PID: 18 Comm: ksoftirqd/1 Not tainted 4.19.0-rc8+ #295
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0x1c4/0x2b6 lib/dump_stack.c:113
    print_address_description.cold.8+0x9/0x1ff mm/kasan/report.c:256
    kasan_report_error mm/kasan/report.c:354 [inline]
    kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412
    check_memory_region_inline mm/kasan/kasan.c:260 [inline]
    check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
    kasan_check_read+0x11/0x20 mm/kasan/kasan.c:272
    atomic_read include/asm-generic/atomic-instrumented.h:21 [inline]
    refcount_read include/linux/refcount.h:43 [inline]
    skb_unref include/linux/skbuff.h:967 [inline]
    kfree_skb+0xb7/0x580 net/core/skbuff.c:655
    llc_sap_state_process+0x9b/0x550 net/llc/llc_sap.c:224
    llc_sap_rcv+0x156/0x1f0 net/llc/llc_sap.c:297
    llc_sap_handler+0x65e/0xf80 net/llc/llc_sap.c:438
    llc_rcv+0x79e/0xe20 net/llc/llc_input.c:208
    __netif_receive_skb_one_core+0x14d/0x200 net/core/dev.c:4913
    __netif_receive_skb+0x2c/0x1e0 net/core/dev.c:5023
    process_backlog+0x218/0x6f0 net/core/dev.c:5829
    napi_poll net/core/dev.c:6249 [inline]
    net_rx_action+0x7c5/0x1950 net/core/dev.c:6315
    __do_softirq+0x30c/0xb03 kernel/softirq.c:292
    run_ksoftirqd+0x94/0x100 kernel/softirq.c:653
    smpboot_thread_fn+0x68b/0xa00 kernel/smpboot.c:164
    kthread+0x35a/0x420 kernel/kthread.c:246
    ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:413

    Allocated by task 18:
    save_stack+0x43/0xd0 mm/kasan/kasan.c:448
    set_track mm/kasan/kasan.c:460 [inline]
    kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
    kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:490
    kmem_cache_alloc_node+0x144/0x730 mm/slab.c:3644
    __alloc_skb+0x119/0x770 net/core/skbuff.c:193
    alloc_skb include/linux/skbuff.h:995 [inline]
    llc_alloc_frame+0xbc/0x370 net/llc/llc_sap.c:54
    llc_station_ac_send_xid_r net/llc/llc_station.c:52 [inline]
    llc_station_rcv+0x1dc/0x1420 net/llc/llc_station.c:111
    llc_rcv+0xc32/0xe20 net/llc/llc_input.c:220
    __netif_receive_skb_one_core+0x14d/0x200 net/core/dev.c:4913
    __netif_receive_skb+0x2c/0x1e0 net/core/dev.c:5023
    process_backlog+0x218/0x6f0 net/core/dev.c:5829
    napi_poll net/core/dev.c:6249 [inline]
    net_rx_action+0x7c5/0x1950 net/core/dev.c:6315
    __do_softirq+0x30c/0xb03 kernel/softirq.c:292

    Freed by task 16383:
    save_stack+0x43/0xd0 mm/kasan/kasan.c:448
    set_track mm/kasan/kasan.c:460 [inline]
    __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
    kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
    __cache_free mm/slab.c:3498 [inline]
    kmem_cache_free+0x83/0x290 mm/slab.c:3756
    kfree_skbmem+0x154/0x230 net/core/skbuff.c:582
    __kfree_skb+0x1d/0x20 net/core/skbuff.c:642
    sk_eat_skb include/net/sock.h:2366 [inline]
    llc_ui_recvmsg+0xec2/0x1610 net/llc/af_llc.c:882
    sock_recvmsg_nosec net/socket.c:794 [inline]
    sock_recvmsg+0xd0/0x110 net/socket.c:801
    ___sys_recvmsg+0x2b6/0x680 net/socket.c:2278
    __sys_recvmmsg+0x303/0xb90 net/socket.c:2390
    do_sys_recvmmsg+0x181/0x1a0 net/socket.c:2466
    __do_sys_recvmmsg net/socket.c:2484 [inline]
    __se_sys_recvmmsg net/socket.c:2480 [inline]
    __x64_sys_recvmmsg+0xbe/0x150 net/socket.c:2480
    do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
    entry_SYSCALL_64_after_hwframe+0x49/0xbe

    The buggy address belongs to the object at ffff8801d1f6fac0
    which belongs to the cache skbuff_head_cache of size 232
    The buggy address is located 228 bytes inside of
    232-byte region [ffff8801d1f6fac0, ffff8801d1f6fba8)
    The buggy address belongs to the page:
    page:ffffea000747dbc0 count:1 mapcount:0 mapping:ffff8801d9be7680 index:0xffff8801d1f6fe80
    flags: 0x2fffc0000000100(slab)
    raw: 02fffc0000000100 ffffea0007346e88 ffffea000705b108 ffff8801d9be7680
    raw: ffff8801d1f6fe80 ffff8801d1f6f0c0 000000010000000b 0000000000000000
    page dumped because: kasan: bad access detected

    Memory state around the buggy address:
    ffff8801d1f6fa80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
    ffff8801d1f6fb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    >ffff8801d1f6fb80: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc
    ^
    ffff8801d1f6fc00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    ffff8801d1f6fc80: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Eric Dumazet
    Reported-by: syzbot
    Signed-off-by: David S. Miller

    Eric Dumazet
     

20 Oct, 2018

1 commit

  • net/sched/cls_api.c has overlapping changes to a call to
    nlmsg_parse(), one (from 'net') added rtm_tca_policy instead of NULL
    to the 5th argument, and another (from 'net-next') added cb->extack
    instead of NULL to the 6th argument.

    net/ipv4/ipmr_base.c is a case of a bug fix in 'net' being done to
    code which moved (to mr_table_dump)) in 'net-next'. Thanks to David
    Ahern for the heads up.

    Signed-off-by: David S. Miller

    David S. Miller
     

16 Oct, 2018

1 commit

  • WHen an llc sock is added into the sk_laddr_hash of an llc_sap,
    it is not marked with SOCK_RCU_FREE.

    This causes that the sock could be freed while it is still being
    read by __llc_lookup_established() with RCU read lock. sock is
    refcounted, but with RCU read lock, nothing prevents the readers
    getting a zero refcnt.

    Fix it by setting SOCK_RCU_FREE in llc_sap_add_socket().

    Reported-by: syzbot+11e05f04c15e03be5254@syzkaller.appspotmail.com
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    Cong Wang
     

14 Sep, 2018

1 commit

  • llc_sap_close() is called by llc_sap_put() which
    could be called in BH context in llc_rcv(). We can't
    block in BH.

    There is no reason to block it here, kfree_rcu() should
    be sufficient.

    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    Cong Wang
     

10 Aug, 2018

1 commit


08 Aug, 2018

1 commit

  • llc_sap_put() decreases the refcnt before deleting sap
    from the global list. Therefore, there is a chance
    llc_sap_find() could find a sap with zero refcnt
    in this global list.

    Close this race condition by checking if refcnt is zero
    or not in llc_sap_find(), if it is zero then it is being
    removed so we can just treat it as gone.

    Reported-by:
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    Cong Wang
     

25 Jul, 2018

1 commit


29 Jun, 2018

1 commit

  • The poll() changes were not well thought out, and completely
    unexplained. They also caused a huge performance regression, because
    "->poll()" was no longer a trivial file operation that just called down
    to the underlying file operations, but instead did at least two indirect
    calls.

    Indirect calls are sadly slow now with the Spectre mitigation, but the
    performance problem could at least be largely mitigated by changing the
    "->get_poll_head()" operation to just have a per-file-descriptor pointer
    to the poll head instead. That gets rid of one of the new indirections.

    But that doesn't fix the new complexity that is completely unwarranted
    for the regular case. The (undocumented) reason for the poll() changes
    was some alleged AIO poll race fixing, but we don't make the common case
    slower and more complex for some uncommon special case, so this all
    really needs way more explanations and most likely a fundamental
    redesign.

    [ This revert is a revert of about 30 different commits, not reverted
    individually because that would just be unnecessarily messy - Linus ]

    Cc: Al Viro
    Cc: Christoph Hellwig
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

05 Jun, 2018

1 commit

  • Pull aio updates from Al Viro:
    "Majority of AIO stuff this cycle. aio-fsync and aio-poll, mostly.

    The only thing I'm holding back for a day or so is Adam's aio ioprio -
    his last-minute fixup is trivial (missing stub in !CONFIG_BLOCK case),
    but let it sit in -next for decency sake..."

    * 'work.aio-1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (46 commits)
    aio: sanitize the limit checking in io_submit(2)
    aio: fold do_io_submit() into callers
    aio: shift copyin of iocb into io_submit_one()
    aio_read_events_ring(): make a bit more readable
    aio: all callers of aio_{read,write,fsync,poll} treat 0 and -EIOCBQUEUED the same way
    aio: take list removal to (some) callers of aio_complete()
    aio: add missing break for the IOCB_CMD_FDSYNC case
    random: convert to ->poll_mask
    timerfd: convert to ->poll_mask
    eventfd: switch to ->poll_mask
    pipe: convert to ->poll_mask
    crypto: af_alg: convert to ->poll_mask
    net/rxrpc: convert to ->poll_mask
    net/iucv: convert to ->poll_mask
    net/phonet: convert to ->poll_mask
    net/nfc: convert to ->poll_mask
    net/caif: convert to ->poll_mask
    net/bluetooth: convert to ->poll_mask
    net/sctp: convert to ->poll_mask
    net/tipc: convert to ->poll_mask
    ...

    Linus Torvalds
     

26 May, 2018

1 commit


16 May, 2018

1 commit


08 May, 2018

1 commit

  • syzbot loves to set very small mtu on devices, since it brings joy.
    We must make llc_ui_sendmsg() fool proof.

    usercopy: Kernel memory overwrite attempt detected to wrapped address (offset 0, size 18446612139802320068)!

    kernel BUG at mm/usercopy.c:100!
    invalid opcode: 0000 [#1] SMP KASAN
    Dumping ftrace buffer:
    (ftrace buffer empty)
    Modules linked in:
    CPU: 0 PID: 17464 Comm: syz-executor1 Not tainted 4.17.0-rc3+ #36
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    RIP: 0010:usercopy_abort+0xbb/0xbd mm/usercopy.c:88
    RSP: 0018:ffff8801868bf800 EFLAGS: 00010282
    RAX: 000000000000006c RBX: ffffffff87d2fb00 RCX: 0000000000000000
    RDX: 000000000000006c RSI: ffffffff81610731 RDI: ffffed0030d17ef6
    RBP: ffff8801868bf858 R08: ffff88018daa4200 R09: ffffed003b5c4fb0
    R10: ffffed003b5c4fb0 R11: ffff8801dae27d87 R12: ffffffff87d2f8e0
    R13: ffffffff87d2f7a0 R14: ffffffff87d2f7a0 R15: ffffffff87d2f7a0
    FS: 00007f56a14ac700(0000) GS:ffff8801dae00000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000001b2bc21000 CR3: 00000001abeb1000 CR4: 00000000001426f0
    DR0: 0000000020000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000030602
    Call Trace:
    check_bogus_address mm/usercopy.c:153 [inline]
    __check_object_size+0x5d9/0x5d9 mm/usercopy.c:256
    check_object_size include/linux/thread_info.h:108 [inline]
    check_copy_size include/linux/thread_info.h:139 [inline]
    copy_from_iter_full include/linux/uio.h:121 [inline]
    memcpy_from_msg include/linux/skbuff.h:3305 [inline]
    llc_ui_sendmsg+0x4b1/0x1530 net/llc/af_llc.c:941
    sock_sendmsg_nosec net/socket.c:629 [inline]
    sock_sendmsg+0xd5/0x120 net/socket.c:639
    __sys_sendto+0x3d7/0x670 net/socket.c:1789
    __do_sys_sendto net/socket.c:1801 [inline]
    __se_sys_sendto net/socket.c:1797 [inline]
    __x64_sys_sendto+0xe1/0x1a0 net/socket.c:1797
    do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
    entry_SYSCALL_64_after_hwframe+0x49/0xbe
    RIP: 0033:0x455979
    RSP: 002b:00007f56a14abc68 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
    RAX: ffffffffffffffda RBX: 00007f56a14ac6d4 RCX: 0000000000455979
    RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000018
    RBP: 000000000072bea0 R08: 00000000200012c0 R09: 0000000000000010
    R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
    R13: 0000000000000548 R14: 00000000006fbf60 R15: 0000000000000000
    Code: 55 c0 e8 c0 55 bb ff ff 75 c8 48 8b 55 c0 4d 89 f9 ff 75 d0 4d 89 e8 48 89 d9 4c 89 e6 41 56 48 c7 c7 80 fa d2 87 e8 a0 0b a3 ff 0b e8 95 55 bb ff e8 c0 a8 f7 ff 8b 95 14 ff ff ff 4d 89 e8
    RIP: usercopy_abort+0xbb/0xbd mm/usercopy.c:88 RSP: ffff8801868bf800

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Eric Dumazet
    Reported-by: syzbot
    Signed-off-by: David S. Miller

    Eric Dumazet
     

23 Apr, 2018

2 commits

  • For SOCK_ZAPPED socket, we don't need to care about llc->sap,
    so we should just skip these refcount functions in this case.

    Fixes: f7e43672683b ("llc: hold llc_sap before release_sock()")
    Reported-by: kernel test robot
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    Cong Wang
     
  • The connection timers of an llc sock could be still flying
    after we delete them in llc_sk_free(), and even possibly
    after we free the sock. We could just wait synchronously
    here in case of troubles.

    Note, I leave other call paths as they are, since they may
    not have to wait, at least we can change them to synchronously
    when needed.

    Also, move the code to net/llc/llc_conn.c, which is apparently
    a better place.

    Reported-by:
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    Cong Wang
     

20 Apr, 2018

1 commit

  • syzbot reported we still access llc->sap in llc_backlog_rcv()
    after it is freed in llc_sap_remove_socket():

    Call Trace:
    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0x1b9/0x294 lib/dump_stack.c:113
    print_address_description+0x6c/0x20b mm/kasan/report.c:256
    kasan_report_error mm/kasan/report.c:354 [inline]
    kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
    __asan_report_load1_noabort+0x14/0x20 mm/kasan/report.c:430
    llc_conn_ac_send_sabme_cmd_p_set_x+0x3a8/0x460 net/llc/llc_c_ac.c:785
    llc_exec_conn_trans_actions net/llc/llc_conn.c:475 [inline]
    llc_conn_service net/llc/llc_conn.c:400 [inline]
    llc_conn_state_process+0x4e1/0x13a0 net/llc/llc_conn.c:75
    llc_backlog_rcv+0x195/0x1e0 net/llc/llc_conn.c:891
    sk_backlog_rcv include/net/sock.h:909 [inline]
    __release_sock+0x12f/0x3a0 net/core/sock.c:2335
    release_sock+0xa4/0x2b0 net/core/sock.c:2850
    llc_ui_release+0xc8/0x220 net/llc/af_llc.c:204

    llc->sap is refcount'ed and llc_sap_remove_socket() is paired
    with llc_sap_add_socket(). This can be amended by holding its refcount
    before llc_sap_remove_socket() and releasing it after release_sock().

    Reported-by:
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    Cong Wang
     

02 Apr, 2018

1 commit


27 Mar, 2018

2 commits

  • llc_conn_send_pdu() pushes the skb into write queue and
    calls llc_conn_send_pdus() to flush them out. However, the
    status of dev_queue_xmit() is not returned to caller,
    in this case, llc_conn_state_process().

    llc_conn_state_process() needs hold the skb no matter
    success or failure, because it still uses it after that,
    therefore we should hold skb before dev_queue_xmit() when
    that skb is the one being processed by llc_conn_state_process().

    For other callers, they can just pass NULL and ignore
    the return value as they are.

    Reported-by: Noam Rathaus
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    Cong Wang
     
  • Prefer the direct use of octal for permissions.

    Done with checkpatch -f --types=SYMBOLIC_PERMS --fix-inplace
    and some typing.

    Miscellanea:

    o Whitespace neatening around these conversions.

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

    Joe Perches
     

12 Mar, 2018

1 commit

  • Avoid a VLA[1] by using a real constant expression instead of a variable.
    The compiler should be able to optimize the original code and avoid using
    an actual VLA. Anyway this change is useful because it will avoid a false
    positive with -Wvla, it might also help the compiler generating better
    code.

    [1] https://lkml.org/lkml/2018/3/7/621

    Signed-off-by: Salvatore Mesoraca
    Signed-off-by: David S. Miller

    Salvatore Mesoraca
     

13 Feb, 2018

1 commit

  • Changes since v1:
    Added changes in these files:
    drivers/infiniband/hw/usnic/usnic_transport.c
    drivers/staging/lustre/lnet/lnet/lib-socket.c
    drivers/target/iscsi/iscsi_target_login.c
    drivers/vhost/net.c
    fs/dlm/lowcomms.c
    fs/ocfs2/cluster/tcp.c
    security/tomoyo/network.c

    Before:
    All these functions either return a negative error indicator,
    or store length of sockaddr into "int *socklen" parameter
    and return zero on success.

    "int *socklen" parameter is awkward. For example, if caller does not
    care, it still needs to provide on-stack storage for the value
    it does not need.

    None of the many FOO_getname() functions of various protocols
    ever used old value of *socklen. They always just overwrite it.

    This change drops this parameter, and makes all these functions, on success,
    return length of sockaddr. It's always >= 0 and can be differentiated
    from an error.

    Tests in callers are changed from "if (err)" to "if (err < 0)", where needed.

    rpc_sockname() lost "int buflen" parameter, since its only use was
    to be passed to kernel_getsockname() as &buflen and subsequently
    not used in any way.

    Userspace API is not changed.

    text data bss dec hex filename
    30108430 2633624 873672 33615726 200ef6e vmlinux.before.o
    30108109 2633612 873672 33615393 200ee21 vmlinux.o

    Signed-off-by: Denys Vlasenko
    CC: David S. Miller
    CC: linux-kernel@vger.kernel.org
    CC: netdev@vger.kernel.org
    CC: linux-bluetooth@vger.kernel.org
    CC: linux-decnet-user@lists.sourceforge.net
    CC: linux-wireless@vger.kernel.org
    CC: linux-rdma@vger.kernel.org
    CC: linux-sctp@vger.kernel.org
    CC: linux-nfs@vger.kernel.org
    CC: linux-x25@vger.kernel.org
    Signed-off-by: David S. Miller

    Denys Vlasenko
     

17 Jan, 2018

1 commit

  • /proc has been ignoring struct file_operations::owner field for 10 years.
    Specifically, it started with commit 786d7e1612f0b0adb6046f19b906609e4fe8b1ba
    ("Fix rmmod/read/write races in /proc entries"). Notice the chunk where
    inode->i_fop is initialized with proxy struct file_operations for
    regular files:

    - if (de->proc_fops)
    - inode->i_fop = de->proc_fops;
    + if (de->proc_fops) {
    + if (S_ISREG(inode->i_mode))
    + inode->i_fop = &proc_reg_file_ops;
    + else
    + inode->i_fop = de->proc_fops;
    + }

    VFS stopped pinning module at this point.

    Signed-off-by: Alexey Dobriyan
    Signed-off-by: David S. Miller

    Alexey Dobriyan
     

16 Nov, 2017

1 commit

  • Pull networking updates from David Miller:
    "Highlights:

    1) Maintain the TCP retransmit queue using an rbtree, with 1GB
    windows at 100Gb this really has become necessary. From Eric
    Dumazet.

    2) Multi-program support for cgroup+bpf, from Alexei Starovoitov.

    3) Perform broadcast flooding in hardware in mv88e6xxx, from Andrew
    Lunn.

    4) Add meter action support to openvswitch, from Andy Zhou.

    5) Add a data meta pointer for BPF accessible packets, from Daniel
    Borkmann.

    6) Namespace-ify almost all TCP sysctl knobs, from Eric Dumazet.

    7) Turn on Broadcom Tags in b53 driver, from Florian Fainelli.

    8) More work to move the RTNL mutex down, from Florian Westphal.

    9) Add 'bpftool' utility, to help with bpf program introspection.
    From Jakub Kicinski.

    10) Add new 'cpumap' type for XDP_REDIRECT action, from Jesper
    Dangaard Brouer.

    11) Support 'blocks' of transformations in the packet scheduler which
    can span multiple network devices, from Jiri Pirko.

    12) TC flower offload support in cxgb4, from Kumar Sanghvi.

    13) Priority based stream scheduler for SCTP, from Marcelo Ricardo
    Leitner.

    14) Thunderbolt networking driver, from Amir Levy and Mika Westerberg.

    15) Add RED qdisc offloadability, and use it in mlxsw driver. From
    Nogah Frankel.

    16) eBPF based device controller for cgroup v2, from Roman Gushchin.

    17) Add some fundamental tracepoints for TCP, from Song Liu.

    18) Remove garbage collection from ipv6 route layer, this is a
    significant accomplishment. From Wei Wang.

    19) Add multicast route offload support to mlxsw, from Yotam Gigi"

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (2177 commits)
    tcp: highest_sack fix
    geneve: fix fill_info when link down
    bpf: fix lockdep splat
    net: cdc_ncm: GetNtbFormat endian fix
    openvswitch: meter: fix NULL pointer dereference in ovs_meter_cmd_reply_start
    netem: remove unnecessary 64 bit modulus
    netem: use 64 bit divide by rate
    tcp: Namespace-ify sysctl_tcp_default_congestion_control
    net: Protect iterations over net::fib_notifier_ops in fib_seq_sum()
    ipv6: set all.accept_dad to 0 by default
    uapi: fix linux/tls.h userspace compilation error
    usbnet: ipheth: prevent TX queue timeouts when device not ready
    vhost_net: conditionally enable tx polling
    uapi: fix linux/rxrpc.h userspace compilation errors
    net: stmmac: fix LPI transitioning for dwmac4
    atm: horizon: Fix irq release error
    net-sysfs: trigger netlink notification on ifalias change via sysfs
    openvswitch: Using kfree_rcu() to simplify the code
    openvswitch: Make local function ovs_nsh_key_attr_size() static
    openvswitch: Fix return value check in ovs_meter_cmd_features()
    ...

    Linus Torvalds
     

07 Nov, 2017

1 commit