1. Nov 22, 2022
    • Xin Long's avatar
      tipc: add an extra conn_get in tipc_conn_alloc · a7b42969
      Xin Long authored
      One extra conn_get() is needed in tipc_conn_alloc(), as after
      tipc_conn_alloc() is called, tipc_conn_close() may free this
      con before deferencing it in tipc_topsrv_accept():
      
         tipc_conn_alloc();
         newsk = newsock->sk;
                                       <---- tipc_conn_close();
         write_lock_bh(&sk->sk_callback_lock);
         newsk->sk_data_ready = tipc_conn_data_ready;
      
      Then an uaf issue can be triggered:
      
        BUG: KASAN: use-after-free in tipc_topsrv_accept+0x1e7/0x370 [tipc]
        Call Trace:
         <TASK>
         dump_stack_lvl+0x33/0x46
         print_report+0x178/0x4b0
         kasan_report+0x8c/0x100
         kasan_check_range+0x179/0x1e0
         tipc_topsrv_accept+0x1e7/0x370 [tipc]
         process_one_work+0x6a3/0x1030
         worker_thread+0x8a/0xdf0
      
      This patch fixes it by holding it in tipc_conn_alloc(), then after
      all accessing in tipc_topsrv_accept() releasing it. Note when does
      this in tipc_topsrv_kern_subscr(), as tipc_conn_rcv_sub() returns
      0 or -1 only, we don't need to check for "> 0".
      
      Fixes: c5fa7b3c
      
       ("tipc: introduce new TIPC server infrastructure")
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      a7b42969
    • Xin Long's avatar
      tipc: set con sock in tipc_conn_alloc · 0e5d56c6
      Xin Long authored
      A crash was reported by Wei Chen:
      
        BUG: kernel NULL pointer dereference, address: 0000000000000018
        RIP: 0010:tipc_conn_close+0x12/0x100
        Call Trace:
         tipc_topsrv_exit_net+0x139/0x320
         ops_exit_list.isra.9+0x49/0x80
         cleanup_net+0x31a/0x540
         process_one_work+0x3fa/0x9f0
         worker_thread+0x42/0x5c0
      
      It was caused by !con->sock in tipc_conn_close(). In tipc_topsrv_accept(),
      con is allocated in conn_idr then its sock is set:
      
        con = tipc_conn_alloc();
        ...                    <----[1]
        con->sock = newsock;
      
      If tipc_conn_close() is called in anytime of [1], the null-pointer-def
      is triggered by con->sock->sk due to con->sock is not yet set.
      
      This patch fixes it by moving the con->sock setting to tipc_conn_alloc()
      under s->idr_lock. So that con->sock can never be NULL when getting the
      con from s->conn_idr. It will be also safer to move con->server and flag
      CF_CONNECTED setting under s->idr_lock, as they should all be set before
      tipc_conn_alloc() is called.
      
      Fixes: c5fa7b3c
      
       ("tipc: introduce new TIPC server infrastructure")
      Reported-by: default avatarWei Chen <harperchen1110@gmail.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      0e5d56c6
    • Wei Yongjun's avatar
      net: phy: at803x: fix error return code in at803x_probe() · 1f0dd412
      Wei Yongjun authored
      Fix to return a negative error code from the ccr read error handling
      case instead of 0, as done elsewhere in this function.
      
      Fixes: 3265f421
      
       ("net: phy: at803x: add fiber support")
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Link: https://lore.kernel.org/r/20221118103635.254256-1-weiyongjun@huaweicloud.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      1f0dd412
  2. Nov 21, 2022
  3. Nov 19, 2022
  4. Nov 18, 2022
  5. Nov 17, 2022
    • Hangbin Liu's avatar
      net: use struct_group to copy ip/ipv6 header addresses · 58e0be1e
      Hangbin Liu authored
      
      
      kernel test robot reported warnings when build bonding module with
      make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/net/bonding/:
      
                       from ../drivers/net/bonding/bond_main.c:35:
      In function ‘fortify_memcpy_chk’,
          inlined from ‘iph_to_flow_copy_v4addrs’ at ../include/net/ip.h:566:2,
          inlined from ‘bond_flow_ip’ at ../drivers/net/bonding/bond_main.c:3984:3:
      ../include/linux/fortify-string.h:413:25: warning: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of f
      ield (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
        413 |                         __read_overflow2_field(q_size_field, size);
            |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In function ‘fortify_memcpy_chk’,
          inlined from ‘iph_to_flow_copy_v6addrs’ at ../include/net/ipv6.h:900:2,
          inlined from ‘bond_flow_ip’ at ../drivers/net/bonding/bond_main.c:3994:3:
      ../include/linux/fortify-string.h:413:25: warning: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of f
      ield (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
        413 |                         __read_overflow2_field(q_size_field, size);
            |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      This is because we try to copy the whole ip/ip6 address to the flow_key,
      while we only point the to ip/ip6 saddr. Note that since these are UAPI
      headers, __struct_group() is used to avoid the compiler warnings.
      
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Fixes: c3f83241
      
       ("net: Add full IPv6 addresses to flow_keys")
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Link: https://lore.kernel.org/r/20221115142400.1204786-1-liuhangbin@gmail.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      58e0be1e
    • Alexandru Tachici's avatar
      net: usb: smsc95xx: fix external PHY reset · 809ff97a
      Alexandru Tachici authored
      An external PHY needs settling time after power up or reset.
      In the bind() function an mdio bus is registered. If at this point
      the external PHY is still initialising, no valid PHY ID will be
      read and on phy_find_first() the bind() function will fail.
      
      If an external PHY is present, wait the maximum time specified
      in 802.3 45.2.7.1.1.
      
      Fixes: 05b35e7e
      
       ("smsc95xx: add phylib support")
      Signed-off-by: default avatarAlexandru Tachici <alexandru.tachici@analog.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Link: https://lore.kernel.org/r/20221115114434.9991-2-alexandru.tachici@analog.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      809ff97a