[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] libfsimage: FAT: Fix unaligned access



Hi,

Using pygrub on IA64, the following messages output:

pygrub(5742): unaligned access to 0x600000000013515c, ip=0x2000000003b721f0
pygrub(5742): unaligned access to 0x600000000013515e, ip=0x2000000003b721f0
pygrub(5742): unaligned access to 0x6000000000135162, ip=0x2000000003b721f0
pygrub(5742): unaligned access to 0x6000000000135164, ip=0x2000000003b721f0
pygrub(5742): unaligned access to 0x6000000000135166, ip=0x2000000003b721f0

The ip indicates this line of tools/libfsimage/fat/fsys_fat.c:231:
  next_cluster = * (unsigned long *) (FAT_BUF + (cached_pos >> 1));
If the partition is FAT16, this access causes an unaligned access.
This patch fixes it.

Signed-off-by: Kouya Shimura <kouya@xxxxxxxxxxxxxx>
Signed-off-by: KUWAMURA Shin'ya <kuwa@xxxxxxxxxxxxxx>

Best Regards,
-- 
  KUWAMURA Shin'ya
diff -r 7953164cebb6 tools/libfsimage/fat/fsys_fat.c
--- a/tools/libfsimage/fat/fsys_fat.c   Tue Aug 07 09:07:29 2007 +0100
+++ b/tools/libfsimage/fat/fsys_fat.c   Wed Aug 08 13:28:54 2007 +0900
@@ -228,15 +228,15 @@ fat_read (fsi_file_t *ffi, char *buf, in
              if (!devread (ffi, sector, 0, FAT_CACHE_SIZE, (char*) FAT_BUF))
                return 0;
            }
-         next_cluster = * (unsigned long *) (FAT_BUF + (cached_pos >> 1));
+         next_cluster = ((__u16 *) (FAT_BUF + (cached_pos >> 1)))[0];
          if (FAT_SUPER->fat_size == 3)
            {
              if (cached_pos & 1)
                next_cluster >>= 4;
              next_cluster &= 0xFFF;
            }
-         else if (FAT_SUPER->fat_size == 4)
-           next_cluster &= 0xFFFF;
+         else if (FAT_SUPER->fat_size > 4)
+           next_cluster |= ((__u16 *) (FAT_BUF + (cached_pos >> 1)))[1] << 16;
          
          if (next_cluster >= FAT_SUPER->clust_eof_marker)
            return ret;
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.