Skip to content
  • Stanislav Kinsbursky's avatar
    nfsd: check passed socket's net matches NFSd superblock's one · 344f3a6b
    Stanislav Kinsbursky authored
    
    
    commit 3064639423c48d6e0eb9ecc27c512a58e38c6c57 upstream.
    
    There could be a case, when NFSd file system is mounted in network, different
    to socket's one, like below:
    
    "ip netns exec" creates new network and mount namespace, which duplicates NFSd
    mount point, created in init_net context. And thus NFS server stop in nested
    network context leads to RPCBIND client destruction in init_net.
    Then, on NFSd start in nested network context, rpc.nfsd process creates socket
    in nested net and passes it into "write_ports", which leads to RPCBIND sockets
    creation in init_net context because of the same reason (NFSd monut point was
    created in init_net context). An attempt to register passed socket in nested
    net leads to panic, because no RPCBIND client present in nexted network
    namespace.
    
    This patch add check that passed socket's net matches NFSd superblock's one.
    And returns -EINVAL error to user psace otherwise.
    
    v2: Put socket on exit.
    
    Reported-by: default avatarWeng Meiling <wengmeiling.weng@huawei.com>
    Signed-off-by: default avatarStanislav Kinsbursky <skinsbursky@parallels.com>
    Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    344f3a6b