WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] libfsimage: FAT: Fix unaligned access
From: "KUWAMURA Shin'ya" <kuwa@xxxxxxxxxxxxxx>
Date: Wed, 08 Aug 2007 14:19:51 +0900 (JST)
Delivery-date: Tue, 07 Aug 2007 22:18:21 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] libfsimage: FAT: Fix unaligned access, KUWAMURA Shin'ya <=