🇰🇷 한글 설명
리눅스 커널의 vfs_tmpfile() 함수에서 호출자의 fsuid 또는 fsgid가 파일 시스템에 매핑되지 않는 경우를 확인하지 않는 취약점이 발견되었습니다. 이로 인해 idmapped 마운트 환경에서 O_TMPFILE을 통해 생성된 임시 파일의 소유자가 유효하지 않은 값((uid_t)-1)으로 설정될 수 있습니다. 이를 방지하기 위해 fsuidgid_has_mapping() 체크 로직이 추가되었습니다.
💡 쉬운 설명
파일을 만들 때 사용자의 권한 정보가 파일 시스템과 맞지 않으면 생성을 거부해야 하는데, 이 과정이 누락되어 잘못된 소유자의 파일이 만들어질 수 있었습니다. 이제 시스템이 사용자의 권한이 유효한지 먼저 확인하여 안전하게 파일을 생성합니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
fs: refuse O_TMPFILE creation with an unmapped fsuid or fsgid
vfs_tmpfile() never checked that the caller's fsuid and fsgid map into
the filesystem. On an idmapped mount whose idmapping does not cover the
caller's fs{u,g}id, the ->tmpfile() instance initializes the new inode
through inode_init_owner(), where mapped_fsuid()/mapped_fsgid() return
INVALID_UID/INVALID_GID, and the tmpfile ends up owned by (uid_t)-1.
Every other creation path already refuses this: may_o_create() (O_CREAT)
and may_create_dentry() (mkdir, mknod, symlink, link) bail out with
-EOVERFLOW via fsuidgid_has_mapping() precisely so that an object cannot
be created with an owner the filesystem cannot represent. An O_TMPFILE
is no exception: it is created I_LINKABLE and linkat(2) can splice it
into the namespace afterwards, so the same guarantee must hold.
Add the missing fsuidgid_has_mapping() check to vfs_tmpfile(). On a
non-idmapped mount the caller's fs{u,g}id always map in the superblock's
user namespace, so this is a no-op there and only takes effect on an
idmapped mount that does not map the caller. It applies to every
filesystem that sets FS_ALLOW_IDMAP and implements ->tmpfile() (tmpfs,
ext4, btrfs, xfs, f2fs, ...), and to overlayfs, whose upper-layer
tmpfile creation funnels through vfs_tmpfile() via backing_tmpfile_open().
📍 영향받는 시스템
idmapped mount를 사용하는 tmpfs, ext4, btrfs, xfs, f2fs, overlayfs 등이 포함된 Linux Kernel
⚔️ 공격 벡터
매핑되지 않은 fsuid/fsgid를 가진 상태에서 O_TMPFILE 플래그를 사용하여 임시 파일을 생성 시도
🛡️ 대응 방법
fsuidgid_has_mapping() 체크가 포함된 최신 리눅스 커널로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 패치된 최신 보안 업데이트 버전인지 확인