Skip to content
  • Dongli Zhang's avatar
    xen-netfront: do not use ~0U as error return value for xennet_fill_frags() · a761129e
    Dongli Zhang authored
    xennet_fill_frags() uses ~0U as return value when the sk_buff is not able
    to cache extra fragments. This is incorrect because the return type of
    xennet_fill_frags() is RING_IDX and 0xffffffff is an expected value for
    ring buffer index.
    
    In the situation when the rsp_cons is approaching 0xffffffff, the return
    value of xennet_fill_frags() may become 0xffffffff which xennet_poll() (the
    caller) would regard as error. As a result, queue->rx.rsp_cons is set
    incorrectly because it is updated only when there is error. If there is no
    error, xennet_poll() would be responsible to update queue->rx.rsp_cons.
    Finally, queue->rx.rsp_cons would point to the rx ring buffer entries whose
    queue->rx_skbs[i] and queue->grant_rx_ref[i] are already cleared to NULL.
    This leads to NULL pointer access in the next iteration to process rx ring
    buffer entries.
    
    The symptom is similar to the one fixed in
    commit 00b36850 ("xen-netfront: do not assume sk_buff...
    a761129e