• Ziyang Xuan's avatar
    net/af_packet: registration process optimization in packet_init() · 63b7c2eb
    Ziyang Xuan authored
    Now, register_pernet_subsys() and register_netdevice_notifier() are both
    after sock_register(). It can create PF_PACKET socket and process socket
    once sock_register() successfully. It is possible PF_PACKET socket is
    creating but register_pernet_subsys() and register_netdevice_notifier()
    are not registered yet. Thus net->packet.sklist_lock and net->packet.sklist
    will be accessed without initialization that is done in packet_net_init().
    Although this is a low probability scenario.
    
    Move register_pernet_subsys() and register_netdevice_notifier() to the
    front in packet_init(). Correspondingly, adjust the unregister process
    in packet_exit().
    Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    63b7c2eb
af_packet.c 112 KB