1*4882a593SmuzhiyunFrom ffd5a46f68710e2781899d0be4d701429a5a817d Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: Daniel Axtens <dja@axtens.net> 3*4882a593SmuzhiyunDate: Mon, 18 Jan 2021 14:51:11 +1100 4*4882a593SmuzhiyunSubject: [PATCH] fs/jfs: Do not move to leaf level if name length is negative 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunFuzzing JFS revealed crashes where a negative number would be passed 7*4882a593Smuzhiyunto le_to_cpu16_copy(). There it would be cast to a large positive number 8*4882a593Smuzhiyunand the copy would read and write off the end of the respective buffers. 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunCatch this at the top as well as the bottom of the loop. 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunSigned-off-by: Daniel Axtens <dja@axtens.net> 13*4882a593SmuzhiyunReviewed-by: Daniel Kiper <daniel.kiper@oracle.com> 14*4882a593SmuzhiyunSigned-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com> 15*4882a593Smuzhiyun--- 16*4882a593Smuzhiyun grub-core/fs/jfs.c | 2 +- 17*4882a593Smuzhiyun 1 file changed, 1 insertion(+), 1 deletion(-) 18*4882a593Smuzhiyun 19*4882a593Smuzhiyundiff --git a/grub-core/fs/jfs.c b/grub-core/fs/jfs.c 20*4882a593Smuzhiyunindex d5a6d65..e5bbda6 100644 21*4882a593Smuzhiyun--- a/grub-core/fs/jfs.c 22*4882a593Smuzhiyun+++ b/grub-core/fs/jfs.c 23*4882a593Smuzhiyun@@ -567,7 +567,7 @@ grub_jfs_getent (struct grub_jfs_diropen *diro) 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun /* Move down to the leaf level. */ 26*4882a593Smuzhiyun nextent = leaf->next; 27*4882a593Smuzhiyun- if (leaf->next != 255) 28*4882a593Smuzhiyun+ if (leaf->next != 255 && len > 0) 29*4882a593Smuzhiyun do 30*4882a593Smuzhiyun { 31*4882a593Smuzhiyun next_leaf = &diro->next_leaf[nextent]; 32*4882a593Smuzhiyun-- 33*4882a593Smuzhiyun2.14.2 34*4882a593Smuzhiyun 35