Bug 291981 - chattr / lsattr broken on 32bit userspace and 64bit kernel x86_64 w/ xfs
chattr / lsattr broken on 32bit userspace and 64bit kernel x86_64 w/ xfs
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: kernel (Show other bugs)
rawhide
All Linux
medium Severity high
: ---
: ---
Assigned To: Eric Sandeen
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-09-15 06:34 EDT by Sami Farin
Modified: 2007-11-30 17:12 EST (History)
0 users

See Also:
Fixed In Version: kernel-2_6_23-0_187_rc6_git7_fc8
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-09-18 17:10:06 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
patch to test (1.34 KB, patch)
2007-09-16 10:45 EDT, Eric Sandeen
no flags Details | Diff

  None (edit)
Description Sami Farin 2007-09-15 06:34:57 EDT
Description of problem:
$ touch doesnotwork
$ lsattr doesnotwork 
ioctl(3, EXT2_IOC_GETFLAGS, 0xffbe2888) = -1 EINVAL (Invalid argument)

$ df -Th .
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda6      xfs     28G   15G   14G  51% /

(Please change Component if the bug is really in kernel or xfs or ...)

Version-Release number of selected component (if applicable):
1.40.2-5

How reproducible:
always

Steps to Reproduce:
1. run 32bit binary of lsattr/chattr on x86_64 kernel
2.
3.
  
Actual results:
EINVAL

also, for chattr +i:
2007-09-15 13:21:26.890857757 <4>[234912.043934] ioctl32(chattr:4922): Unknown
cmd fd(3) cmd(80046601){t:'f';sz:4} arg(fff4d6c8) on
/var/log/qmail/smtpd/old/@4000000040dc8884213ed37c.s.gz


Expected results:
as documented in man pages

Additional info:
Comment 1 Eric Sandeen 2007-09-16 00:02:03 EDT
This works for me:

[root@inode tmp]# ./chattr32 +i file
[root@inode tmp]# file chattr32
chattr32: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for
GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not
stripped

[root@inode tmp]# ./lsattr32 file
----i--------- file
[root@inode tmp]# file lsattr32
lsattr32: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for
GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not
stripped

[root@inode tmp]# uname -a
Linux inode.lab.msp.redhat.com 2.6.23-0.184.rc6.git4.fc8 #1 SMP Fri Sep 14
17:11:26 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux

those two binaries were built from e2fsprogs-1.40.2-5 on a 32-bit box, and
rsynced to the x86_64 box.

What kernel version are you using?
Comment 2 Sami Farin 2007-09-16 06:00:08 EDT
/usr/bin/lsattr: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped

Linux safari.finland.fbi 2.6.22.6-cfs-v20.5-64 #2 SMP Wed Sep 12 19:00:17 EEST
2007 x86_64 x86_64 x86_64 GNU/Linux
Comment 3 Eric Sandeen 2007-09-16 10:03:48 EDT
> Linux safari.finland.fbi 2.6.22.6-cfs-v20.5-64 #2 SMP Wed Sep 12 19:00:17 EEST
2007 x86_64 x86_64 x86_64 GNU/Linux

That's not a fedora kernel.

If you can reproduce this on a fedora kernel, please re-open.  This is most
likely a kernel problem, and you're not running a fedora kernel.

Thanks,

-Eric
Comment 4 Eric Sandeen 2007-09-16 10:11:24 EDT
Whoops, just realized you were trying this on xfs.  Sorry.  It is broken there.

This should be working... I'll look into it.

-Eric
Comment 5 Eric Sandeen 2007-09-16 10:45:11 EDT
Created attachment 196721 [details]
patch to test

This should fix it.  Care to test it, if you can rebuild xfs?

I'll send this to sgi.

-Eric
Comment 6 Sami Farin 2007-09-16 11:23:26 EDT
Thanks.  Fix looks straightforward, other fs'es are also using FS_IOC32_GETFLAGS...

I can rebuild+reboot inside a couple of days.

This is not the only thing broken on XFS with 32bit compat.
For example:

# xfs_io -r -p xfs_bmap -c "bmap -v" /tmp/jee.txt 
xfs_bmap: can't get geometry ["/tmp/jee.txt"]: Invalid argument

# /rh/BUILD/xfsprogs-2.9.4/io/xfs_io -r -p xfs_bmap -c "bmap -v" /tmp/jee.txt 
/tmp/jee.txt:
 EXT: FILE-OFFSET      BLOCK-RANGE        AG AG-OFFSET        TOTAL
   0: [0..719]:        24530448..24531167 10 (101648..102367)   720
Comment 7 Eric Sandeen 2007-09-16 15:28:57 EDT
Yep... we've never had all of the xfs ioctls working, though at least some
were... and I thought lsattr was too.  I'm not sure if something broke... I'll
take a look when I get a chance.

Don't sweat the test if you don't want to or can't, but the patch is there if
you want it.  I'll take a look at the rest of this and send a patch upstream.

Thanks,
-Eric
Comment 8 Eric Sandeen 2007-09-16 16:03:19 EDT
Actually, what kernel message did you get out of the bmap command?  this one
actually does seem to be working for me :) and I don't see any obvious size or
alignment problems in struct getbmap...

-Eric
Comment 9 Sami Farin 2007-09-16 16:10:15 EDT
bmap did not produce any kernel messages.
Comment 10 Eric Sandeen 2007-09-17 12:34:22 EDT
very strange that bmap gives no messages.  Maybe strace?  Honestly, it does work
for me here.  :)

Patch for GETXFLAGS, SETXFLAGS, and GETVERSION sent upstream:

http://oss.sgi.com/archives/xfs/2007-09/msg00174.html

When they ack and/or commit it, I can put it into the fedora kernel until it
comes back via kernel.org.

Thanks,

-Eric
Comment 11 Sami Farin 2007-09-17 13:25:09 EDT
strace is useless
20:03:14.953872 ioctl(3, 0x806c5864, 0xffcfbf88) = -1 EINVAL (Invalid argument)
<0.000014>

32bit version works with 
xfs_io -r -p xfs_bmap -c "bmap"    /tmp/jee.txt
but not with
xfs_io -r -p xfs_bmap -c "bmap -v" /tmp/jee.txt

Nice that you sent the patch, but you forgot to tell who found the bug.
Comment 12 Eric Sandeen 2007-09-17 13:32:31 EDT
Sorry 'bout that.  Will follow up.
Comment 13 Eric Sandeen 2007-09-17 13:39:12 EDT
Dunno...

[root@inode sbin]# ./xfs_io -r -p xfs_bmap -c "bmap -v" /obj/e2fsprogs-1.35.tar.gz
/obj/e2fsprogs-1.35.tar.gz:
 EXT: FILE-OFFSET      BLOCK-RANGE                AG AG-OFFSET            TOTAL
FLAGS
   0: [0..6159]:       18461096..18467255          0 (18461096..18467255)  6160
01111

[root@inode sbin]# file xfs_io
xfs_io: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux
2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
[root@inode sbin]# uname -a
Linux inode.lab.msp.redhat.com 2.6.23-rc1-git3 #7 SMP Fri Sep 7 16:51:19 CDT
2007 x86_64 x86_64 x86_64 GNU/Linux
Comment 14 Eric Sandeen 2007-09-18 17:10:06 EDT
modified rawhide kernel, building now.

Note You need to log in before you can comment on or make changes to this bug.