🇰🇷 한글 설명
Linux kernel UFS 드라이버의 __ufshcd_wl_suspend()에서 cancel_delayed_work_sync() 호출 순서 문제로 인한 Race Condition. ufshcd_vops_suspend() 실행 중 ufshcd_rtc_work()가 계속 실행되어 SError 발생 및 kernel panic 초래.
💡 쉬운 설명
스마트폰/SSD의 저장장치 컨트롤러(UFS)에서 전원 절약 모드 진입 시 작업 순서 오류로 시스템이 갑자기 멈추는 버그. 특정 하드웨어 환경에서는 재시작 후 부팅이 불가능할 수 있음.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
scsi: ufs: core: Fix SError in ufshcd_rtc_work() during UFS suspend
In __ufshcd_wl_suspend(), cancel_delayed_work_sync() is called to cancel
the UFS RTC work, but it is placed after ufshcd_vops_suspend(hba, pm_op,
POST_CHANGE). This creates a race condition where ufshcd_rtc_work() can
still be running while ufshcd_vops_suspend() is executing. When
UFSHCD_CAP_CLK_GATING is not supported, the condition
!hba->clk_gating.active_reqs is always true, causing ufshcd_update_rtc()
to be executed. Since ufshcd_vops_suspend() typically performs clock
gating operations, executing ufshcd_update_rtc() at that moment triggers
an SError. The kernel panic trace is as follows:
Kernel panic - not syncing: Asynchronous SError Interrupt
Call trace:
dump_backtrace+0xec/0x128
show_stack+0x18/0x28
dump_stack_lvl+0x40/0xa0
dump_stack+0x18/0x24
panic+0x148/0x374
nmi_panic+0x3c/0x8c
arm64_serror_panic+0x64/0x8c
do_serror+0xc4/0xc8
el1h_64_error_handler+0x34/0x4c
el1h_64_error+0x68/0x6c
el1_interrupt+0x20/0x58
el1h_64_irq_handler+0x18/0x24
el1h_64_irq+0x68/0x6c
ktime_get+0xc4/0x12c
ufshcd_mcq_sq_stop+0x4c/0xec
ufshcd_mcq_sq_cleanup+0x64/0x1dc
ufshcd_clear_cmd+0x38/0x134
ufshcd_issue_dev_cmd+0x298/0x4d0
ufshcd_exec_dev_cmd+0x1a4/0x1c4
ufshcd_query_attr+0xbc/0x19c
ufshcd_rtc_work+0x10c/0x1c8
process_scheduled_works+0x1c4/0x45c
worker_thread+0x32c/0x3e8
kthread+0x120/0x1d8
ret_from_fork+0x10/0x20
Fix this by moving cancel_delayed_work_sync() before the call to
ufshcd_vops_suspend(hba, pm_op, PRE_CHANGE), ensuring the UFS RTC work is
fully completed or cancelled at that point.
📍 영향받는 시스템
ARM64 기반 Linux kernel (UFS 호스트 컨트롤러 드라이버 포함) - 특히 UFSHCD_CAP_CLK_GATING 비활성화 시스템
⚔️ 공격 벡터
로컬 권한 필요 - UFS 장치의 suspend/resume 사이클 중 ufshcd_rtc_work() 함수 실행 시 trigger되는 Race Condition
🛡️ 대응 방법
Linux kernel을 패치된 버전으로 업그레이드 (kernel/drivers/ufs/core/ufshcd.c의 cancel_delayed_work_sync() 호출을 PRE_CHANGE 전으로 이동한 버전)
🔧 검증 코드
현재 kernel 버전 확인 후 패치 적용 후 suspend/resume 사이클에서 kernel panic 발생 여부 테스트로 확인 (안정적 재부팅 가능 시 해결)
uname -r | grep -E 'version|kernel' && cat /proc/version | grep -oP '\d+\.\d+\.\d+'