• Michael S. Tsirkin's avatar
    vhost-net: fix range checking in mrg bufs case · ee05d693
    Michael S. Tsirkin authored
    In mergeable buffer case, we use headcount, log_num
    and seg as indexes in same-size arrays, and
    we know that headcount <= seg and
    log_num equals either 0 or seg.
    
    Therefore, the right thing to do is range-check seg,
    not headcount as we do now: these will be different
    if guest chains s/g descriptors (this does not
    happen now, but we can not trust the guest).
    
    Long term, we should add BUG_ON checks to verify
    two other indexes are what we think they should be.
    Reported-by: default avatarJason Wang <jasowang@redhat.com>
    Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
    ee05d693
net.c 21.6 KB