• B
    SUNRPC: Fix buffer handling of GSS MIC without slack · ed2c6aeb
    Benjamin Coddington 提交于
    mainline inclusion
    from mainline-v5.4-rc1
    commit 5f1bc399
    category: bugfix
    bugzilla: 51816
    CVE: NA
    
    -------------------------------------------------
    
    The GSS Message Integrity Check data for krb5i may lie partially in the XDR
    reply buffer's pages and tail.  If so, we try to copy the entire MIC into
    free space in the tail.  But as the estimations of the slack space required
    for authentication and verification have improved there may be less free
    space in the tail to complete this copy -- see commit 2c94b8ec
    ("SUNRPC: Use au_rslack when computing reply buffer size").  In fact, there
    may only be room in the tail for a single copy of the MIC, and not part of
    the MIC and then another complete copy.
    
    The real world failure reported is that `ls` of a directory on NFS may
    sometimes return -EIO, which can be traced back to xdr_buf_read_netobj()
    failing to find available free space in the tail to copy the MIC.
    
    Fix this by checking for the case of the MIC crossing the boundaries of
    head, pages, and tail. If so, shift the buffer until the MIC is contained
    completely within the pages or tail.  This allows the remainder of the
    function to create a sub buffer that directly address the complete MIC.
    Signed-off-by: NBenjamin Coddington <bcodding@redhat.com>
    Cc: stable@vger.kernel.org # v5.1
    Reviewed-by: NChuck Lever <chuck.lever@oracle.com>
    Signed-off-by: NAnna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: NLu Wei <luwei32@huawei.com>
    Reviewed-by: NYue Haibing <yuehaibing@huawei.com>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    ed2c6aeb
xdr.c 41.1 KB