• R
    ima: pass filename to ima_rdwr_violation_check() · 4e8581ee
    Roberto Sassu 提交于
    ima_rdwr_violation_check() retrieves the full path of a measured file by
    calling ima_d_path(). If process_measurement() calls this function, it
    reuses the pointer and passes it to the functions to measure/appraise/audit
    an accessed file.
    
    After commit bc15ed66 ("ima: fix ima_d_path() possible race with
    rename"), ima_d_path() first tries to retrieve the full path by calling
    d_absolute_path() and, if there is an error, copies the dentry name to the
    buffer passed as argument.
    
    However, ima_rdwr_violation_check() passes to ima_d_path() the pointer of a
    local variable. process_measurement() might be reusing the pointer to an
    area in the stack which may have been already overwritten after
    ima_rdwr_violation_check() returned.
    
    Correct this issue by passing to ima_rdwr_violation_check() the pointer of
    a buffer declared in process_measurement().
    
    Fixes: bc15ed66 ("ima: fix ima_d_path() possible race with rename")
    Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
    Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
    4e8581ee
ima_main.c 13.2 KB