• Amir Goldstein's avatar
    ovl: fix possible use after free on redirect dir lookup · 4c7d0c9c
    Amir Goldstein authored
    ovl_lookup_layer() iterates on path elements of d->name.name
    but also frees and allocates a new pointer for d->name.name.
    
    For the case of lookup in upper layer, the initial d->name.name
    pointer is stable (dentry->d_name), but for lower layers, the
    initial d->name.name can be d->redirect, which can be freed during
    iteration.
    
    [SzM]
    Keep the count of remaining characters in the redirect path and calculate
    the current position from that.  This works becuase only the prefix is
    modified, the ending always stays the same.
    
    Fixes: 02b69b28 ("ovl: lookup redirects")
    Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
    4c7d0c9c
namei.c 8.56 KB