🇰🇷 한글 설명
리눅스 커널의 중첩된 OverlayFS 환경에서 backing file의 경로를 잘못 계산하는 취약점이 발견되었습니다. 이로 인해 /proc/<pid>/maps 및 perf/ftrace mmap 레코드에 실제 사용자 경로가 아닌 잘못된 경로가 표시됩니다. LSM 훅 추가 과정에서 기존에 수정되었던 경로 처리 로직이 다시 잘못 구현되어 발생한 문제입니다.
💡 쉬운 설명
파일 시스템을 겹쳐서 사용하는 특수한 설정에서, 컴퓨터가 파일의 실제 위치를 엉뚱한 곳으로 인식하는 문제입니다. 이로 인해 시스템 모니터링 도구에서 파일 경로가 실제와 다르게 나타날 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
fs: fix user path of nested backing files
backing_file_open() derives the path to be stored in the new backing
file from user_file->f_path. This is incorrect when user_file itself
is a backing file, which is the case for nested stacking filesystems,
e.g. overlayfs mounts where the lowerdir of one overlayfs is the merged
directory of another. Since commit def3ae83da02 ("fs: store real path
instead of fake path in backing file f_path") the f_path of a backing
file holds the real path of the intermediate layer, not the path that
the user opened.
Commit 924577e4f6ca ("ovl: Fix nested backing file paths") fixed this
for such configurations by passing file_user_path() from
ovl_open_realfile(). However, commit 6af36aeb147a ("lsm: add
backing_file LSM hooks") changed the first argument of
backing_file_open() from the user path back to the user file and
derived the path from user_file->f_path again, silently re-introducing
the problem.
As a result, files mapped through a nested overlayfs show the wrong
path in /proc/<pid>/maps and in perf/ftrace mmap records. For example,
with two nested overlayfs mounts:
mkdir -p /ovl/{lower,upper,work,merged} /ovl/nested
echo hello > /ovl/lower/foo
mount -t overlay overlay \
-o lowerdir=/ovl/lower,upperdir=/ovl/upper,workdir=/ovl/work \
/ovl/merged
# at least two lowerdirs are needed when upperdir is nonexistent
mount -t overlay overlay \
-o lowerdir=/ovl/merged:/ovl/lower /ovl/nested
mapping /ovl/nested/foo shows a disconnected path instead of the user
path:
# readlink /proc/self/fd/3
/ovl/nested/foo
# grep foo /proc/self/maps
7f6e2c100000-7f6e2c101000 r--s 00000000 00:24 15813027 /foo
The bogus path is derived from the f_path of the intermediate backing
file, whose mount is a private clone that d_path() cannot resolve.
Fix this by using file_user_path(), which returns the outermost
user-visible path for backing files and falls back to
&user_file->f_path for regular files. This restores the behavior of
commit 924577e4f6ca ("ovl: Fix nested backing file paths") for
overlayfs and also fixes the same problem for the other
backing_file_open() callers, fuse passthrough and erofs ishare, when
their user file is itself a backing file.
backing_tmpfile_open() has the same pattern but is not affected: it is
only called by ovl_create_tmpfile() for the upper layer, and another
overlayfs is rejected as upperdir by the DCACHE_OP_REAL check in
ovl_mount_dir_check(), so its user_file can never be a backing file.
📍 영향받는 시스템
Linux kernel (OverlayFS, FUSE passthrough, EROFS ishare 사용 환경)
⚔️ 공격 벡터
직접적인 공격보다는 시스템 모니터링 및 디버깅 시 잘못된 경로 정보를 노출하여 분석을 방해하거나 보안 감사 도구를 교란할 수 있음
🛡️ 대응 방법
리눅스 커널을 최신 패치가 적용된 버전으로 업데이트하여 backing_file_open() 함수가 file_user_path()를 사용하도록 수정해야 함
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이후인지 확인하십시오.