• Jeff Layton's avatar
    mtab: handle ENOSPC/EFBIG condition properly when altering mtab · 33012eba
    Jeff Layton authored
    It's possible that when mount.cifs goes to append the mtab that there
    won't be enough space to do so, and the mntent won't be appended to the
    file in its entirety.
    Add a my_endmntent routine that will fflush and then fsync the FILE if
    that succeeds. If either fails then it will truncate the file back to
    its provided size. It will then call endmntent unconditionally.
    Have add_mtab call fstat on the opened mtab file in order to get the
    size of the file before it has been appended. Assuming that that
    succeeds, use my_endmntent to ensure that the file is not corrupted
    before closing it. It's possible that we'll have a small race window
    where the mtab is incorrect, but it should be quickly corrected.
    This was reported some time ago as CVE-2011-1678:
    ...and it seems to fix the reproducer that I was able to come up with.
    Signed-off-by: default avatarJeff Layton <jlayton@samba.org>
    Reviewed-by: default avatarSuresh Jayaraman <sjayaraman@suse.de>
mount.h 1.48 KB