In the Linux kernel, the following vulnerability has been resolved:
f2fs: fix use-after-free of sbi in f2fs_compress_write_end_io()
In f2fs_compress_write_end_io(), dec_page_count(sbi, type) can bring
the F2FS_WB_CP_DATA counter to zero, unblocking
f2fs_wait_on_all_pages() in f2fs_put_super() on a concurrent unmount
CPU. The unmount path then proceeds to call
f2fs_destroy_page_array_cache(sbi), which destroys
sbi->page_array_slab via kmem_cache_destroy(), and eventually
kfree(sbi). Meanwhile, the bio completion callback is still executing:
when it reaches page_array_free(sbi, ...), it dereferences
sbi->page_array_slab — a destroyed slab cache — to call
kmem_cache_free(), causing a use-after-free.
This is the same class of bug as CVE-2026-23234 (which fixed the
equivalent race in f2fs_write_end_io() in data.c), but in the
compressed writeback completion path that was not covered by that fix.
Fix this by moving dec_page_count() to after page_array_free(), so
that all sbi accesses complete before the counter decrement that can
unblock unmount. For non-last folios (where atomic_dec_return on
cic->pending_pages is nonzero), dec_page_count is called immediately
before returning — page_array_free is not reached on this path, so
there is no post-decrement sbi access. For the last folio,
page_array_free runs while the F2FS_WB_CP_DATA counter is still
nonzero (this folio has not yet decremented it), keeping sbi alive,
and dec_page_count runs as the final operation.
CVE-2026-31702 is a use-after-free vulnerability in the Linux kernel's F2FS file system compression write completion handler. The vulnerability occurs when a concurrent unmount operation destroys the sbi (superblock info) structure while a bio completion callback is still executing, leading to potential kernel crashes or privilege escalation. This is a high-severity issue affecting systems using F2FS with compression enabled, particularly in data center and enterprise environments.
Immediate Actions:
1. Identify all Linux systems using F2FS file system with compression enabled (check mount options: mount | grep f2fs)
2. Prioritize systems in production environments, particularly those with high I/O concurrency
3. Implement monitoring for kernel panic logs and unexpected system reboots
Patching Guidance:
1. Apply the latest Linux kernel patch that includes the F2FS compression write-end-io fix
2. For kernel versions 7.1-rc1 and later, update to patched versions immediately
3. Test patches in non-production environments before deployment
4. Schedule maintenance windows for kernel updates on critical systems
Compensating Controls (if immediate patching not possible):
1. Disable F2FS compression if not critical to operations (mount with -o compress_algorithm=none)
2. Reduce concurrent I/O operations to minimize race condition window
3. Implement watchdog timers to detect and restart hung processes
4. Enable kernel crash dumps (kdump) for post-incident analysis
Detection Rules:
1. Monitor kernel logs for: 'use-after-free', 'page_array_slab', 'f2fs_compress_write_end_io'
2. Alert on unexpected kernel panics or BUG messages related to F2FS
3. Track system uptime anomalies indicating frequent crashes
4. Monitor memory corruption indicators in dmesg logs
الإجراءات الفورية:
1. تحديد جميع أنظمة لينكس التي تستخدم نظام الملفات F2FS مع تفعيل الضغط (تحقق من خيارات التثبيت: mount | grep f2fs)
2. إعطاء الأولوية للأنظمة في بيئات الإنتاج، خاصة تلك التي تتمتع بتزامن عالي للإدخال/الإخراج
3. تنفيذ المراقبة لسجلات توقف النواة والإعادة غير المتوقعة للنظام
إرشادات التصحيح:
1. تطبيق أحدث تصحيح نواة لينكس يتضمن إصلاح F2FS compression write-end-io
2. لإصدارات النواة 7.1-rc1 والإصدارات الأحدث، قم بالتحديث إلى الإصدارات المصححة فوراً
3. اختبر التصحيحات في بيئات غير الإنتاج قبل النشر
4. جدول نوافذ الصيانة لتحديثات النواة على الأنظمة الحرجة
الضوابط البديلة (إذا لم يكن التصحيح الفوري ممكناً):
1. تعطيل ضغط F2FS إذا لم يكن حرجاً للعمليات (mount مع -o compress_algorithm=none)
2. تقليل عمليات الإدخال/الإخراج المتزامنة لتقليل نافذة حالة السباق
3. تنفيذ مؤقتات watchdog للكشف عن العمليات المعلقة وإعادة تشغيلها
4. تفعيل تفريغ توقف النواة (kdump) لتحليل ما بعد الحادث
قواعد الكشف:
1. مراقبة سجلات النواة بحثاً عن: 'use-after-free', 'page_array_slab', 'f2fs_compress_write_end_io'
2. تنبيه على توقف النواة غير المتوقع أو رسائل BUG المتعلقة بـ F2FS
3. تتبع شذوذ وقت التشغيل الذي يشير إلى توقفات متكررة
4. مراقبة مؤشرات تلف الذاكرة في سجلات dmesg