]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Linux kernels (at least up until 2.6.27) are lacking compat sys_ustat
authorBarry Naujok <bnaujok@sgi.com>
Tue, 2 Dec 2008 03:03:12 +0000 (03:03 +0000)
committerBarry Naujok <bnaujok@sgi.com>
Tue, 2 Dec 2008 03:03:12 +0000 (03:03 +0000)
handlers on some platforms (notably PPC) so that if called from 32 bits
on a 64-bit kernel, the kernel will copy out too much (32 bytes onto a
20-byte structure):

[root@xero xfstests]# xfs_logprint /dev/loop0
xfs_logprint:
*** stack smashing detected ***: xfs_logprint terminated
Aborted

This will be fixed upstream, but for the benefit of older kernels we
may want to guard against this by padding the structure we pass into
the syscall.   We don't care about the values anyway, just the return
value.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Merge of master-melb:xfs-cmds:32618a by kenmcd.

  Pad ustat struct to avoid stack corruption

libxfs/linux.c

index 6022b7bbc48d3059f71564acb5b54ba59bdd3e49..bc4990323d805c0f8c9e1739181a6bf86c28327a 100644 (file)
@@ -49,7 +49,8 @@ static int max_block_alignment;
 int
 platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose)
 {
-       struct ustat    ust;
+       /* Pad ust; pre-2.6.28 linux copies out too much in 32bit compat mode */
+       struct ustat    ust[2];
        struct stat64   st;
 
        if (!s) {
@@ -60,7 +61,7 @@ platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose)
                s = &st;
        }
 
-       if (ustat(s->st_rdev, &ust) >= 0) {
+       if (ustat(s->st_rdev, ust) >= 0) {
                if (verbose)
                        fprintf(stderr,
                                _("%s: %s contains a mounted filesystem\n"),