• Meng Xu's avatar
    ALSA: asihpi: fix a potential double-fetch bug when copying puhm · e1af344d
    Meng Xu authored
    The hm->h.size is intended to hold the actual size of the hm struct
    that is copied from userspace and should always be <= sizeof(*hm).
    
    However, after copy_from_user(hm, puhm, hm->h.size), since userspace
    process has full control over the memory region pointed by puhm, it is
    possible that the value of hm->h.size is different from what is fetched-in
    previously (get_user(hm->h.size, (u16 __user *)puhm)). In other words,
    hm->h.size is overriden and the relation between hm->h.size and the hm
    struct is broken.
    
    This patch proposes to use a seperate variable, msg_size, to hold
    the value of the first fetch and override hm->h.size to msg_size
    after the second fetch to maintain the relation.
    Signed-off-by: default avatarMeng Xu <mengxu.gatech@gmail.com>
    Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
    e1af344d
hpioctl.c 15.2 KB