1. 08 Oct, 2019 4 commits
    • Eric Dumazet's avatar
      tun: fix memory leak in error path · 11fc7d5a
      Eric Dumazet authored
      syzbot reported a warning [1] that triggered after recent Jiri patch.
      
      This exposes a bug that we hit already in the past (see commit
      ff244c6b ("tun: handle register_netdevice() failures properly")
      for details)
      
      tun uses priv->destructor without an ndo_init() method.
      
      register_netdevice() can return an error, but will
      not call priv->destructor() in some cases. Jiri recent
      patch added one more.
      
      A long term fix would be to transfer the initialization
      of what we destroy in ->destructor() in the ndo_init()
      
      This looks a bit risky given the complexity of tun driver.
      
      A simpler fix is to detect after the failed register_netdevice()
      if the tun_free_netdev() function was called already.
      
      [1]
      ODEBUG: free active (active state 0) object type: timer_list hint: tun_flow_cleanup+0x0/0x280 drivers/net/tun.c:457
      WARNING: CPU: 0 PID: 8653 at lib/debugobjects.c:481 debug_print_object+0x168/0x250 lib/debugobjects.c:481
      Kernel panic - not syncing: panic_on_warn set ...
      CPU: 0 PID: 8653 Comm: syz-executor976 Not tainted 5.4.0-rc1-next-20191004 #0
      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+0x172/0x1f0 lib/dump_stack.c:113
       panic+0x2dc/0x755 kernel/panic.c:220
       __warn.cold+0x2f/0x3c kernel/panic.c:581
       report_bug+0x289/0x300 lib/bug.c:195
       fixup_bug arch/x86/kernel/traps.c:174 [inline]
       fixup_bug arch/x86/kernel/traps.c:169 [inline]
       do_error_trap+0x11b/0x200 arch/x86/kernel/traps.c:267
       do_invalid_op+0x37/0x50 arch/x86/kernel/traps.c:286
       invalid_op+0x23/0x30 arch/x86/entry/entry_64.S:1028
      RIP: 0010:debug_print_object+0x168/0x250 lib/debugobjects.c:481
      Code: dd 80 b9 e6 87 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 b5 00 00 00 48 8b 14 dd 80 b9 e6 87 48 c7 c7 e0 ae e6 87 e8 80 84 ff fd <0f> 0b 83 05 e3 ee 80 06 01 48 83 c4 20 5b 41 5c 41 5d 41 5e 5d c3
      RSP: 0018:ffff888095997a28 EFLAGS: 00010082
      RAX: 0000000000000000 RBX: 0000000000000003 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: ffffffff815cb526 RDI: ffffed1012b32f37
      RBP: ffff888095997a68 R08: ffff8880a92ac580 R09: ffffed1015d04101
      R10: ffffed1015d04100 R11: ffff8880ae820807 R12: 0000000000000001
      R13: ffffffff88fb5340 R14: ffffffff81627110 R15: ffff8880aa41eab8
       __debug_check_no_obj_freed lib/debugobjects.c:963 [inline]
       debug_check_no_obj_freed+0x2d4/0x43f lib/debugobjects.c:994
       kfree+0xf8/0x2c0 mm/slab.c:3755
       kvfree+0x61/0x70 mm/util.c:593
       netdev_freemem net/core/dev.c:9384 [inline]
       free_netdev+0x39d/0x450 net/core/dev.c:9533
       tun_set_iff drivers/net/tun.c:2871 [inline]
       __tun_chr_ioctl+0x317b/0x3f30 drivers/net/tun.c:3075
       tun_chr_ioctl+0x2b/0x40 drivers/net/tun.c:3355
       vfs_ioctl fs/ioctl.c:47 [inline]
       file_ioctl fs/ioctl.c:539 [inline]
       do_vfs_ioctl+0xdb6/0x13e0 fs/ioctl.c:726
       ksys_ioctl+0xab/0xd0 fs/ioctl.c:743
       __do_sys_ioctl fs/ioctl.c:750 [inline]
       __se_sys_ioctl fs/ioctl.c:748 [inline]
       __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:748
       do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x441439
      Code: e8 9c ae 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 3b 0a fc ff c3 66 2e 0f 1f 84 00 00 00 00
      RSP: 002b:00007fff61c37438 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
      RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000441439
      RDX: 0000000020000400 RSI: 00000000400454ca RDI: 0000000000000004
      RBP: 00007fff61c37470 R08: 0000000000000001 R09: 0000000100000000
      R10: 0000000000000000 R11: 0000000000000246 R12: ffffffffffffffff
      R13: 0000000000000005 R14: 0000000000000000 R15: 0000000000000000
      Kernel Offset: disabled
      Rebooting in 86400 seconds..
      
      Fixes: ff927412 ("net: introduce name_node struct to be used in hashlist")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Jiri Pirko <jiri@mellanox.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      11fc7d5a
    • Colin Ian King's avatar
      netdevsim: fix spelling mistake "forbidded" -> "forbid" · f9867b51
      Colin Ian King authored
      There is a spelling mistake in a NL_SET_ERR_MSG_MOD message. Fix it.
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      f9867b51
    • Colin Ian King's avatar
      net: phy: mscc: make arrays static, makes object smaller · c4256794
      Colin Ian King authored
      Don't populate const arrays on the stack but instead make them
      static. Makes the object code smaller by 1058 bytes.
      
      Before:
         text	   data	    bss	    dec	    hex	filename
        29879	   6144	      0	  36023	   8cb7	drivers/net/phy/mscc.o
      
      After:
         text	   data	    bss	    dec	    hex	filename
        28437	   6528	      0	  34965	   8895	drivers/net/phy/mscc.o
      
      (gcc version 9.2.1, amd64)
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      c4256794
    • Colin Ian King's avatar
      nfp: bpf: make array exp_mask static, makes object smaller · 155283c3
      Colin Ian King authored
      Don't populate the array exp_mask on the stack but instead make it
      static. Makes the object code smaller by 224 bytes.
      
      Before:
         text	   data	    bss	    dec	    hex	filename
        77832	   2290	      0	  80122	  138fa	ethernet/netronome/nfp/bpf/jit.o
      
      After:
         text	   data	    bss	    dec	    hex	filename
        77544	   2354	      0	  79898	  1381a	ethernet/netronome/nfp/bpf/jit.o
      
      (gcc version 9.2.1, amd64)
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      155283c3
  2. 07 Oct, 2019 32 commits
  3. 06 Oct, 2019 4 commits