Bug 291981

Summary: chattr / lsattr broken on 32bit userspace and 64bit kernel x86_64 w/ xfs
Product: [Fedora] Fedora Reporter: Sami Farin <hvtaifwkbgefbaei>
Component: kernelAssignee: Eric Sandeen <esandeen>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: medium    
Version: rawhideKeywords: Reopened
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
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 21:10:06 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
patch to test none

Description Sami Farin 2007-09-15 10:34:57 UTC
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 04:02:03 UTC
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 10:00:08 UTC
/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 14:03:48 UTC
> 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 14:11:24 UTC
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 14:45:11 UTC
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 15:23:26 UTC
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 19:28:57 UTC
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 20:03:19 UTC
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 20:10:15 UTC
bmap did not produce any kernel messages.


Comment 10 Eric Sandeen 2007-09-17 16:34:22 UTC
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 17:25:09 UTC
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 17:32:31 UTC
Sorry 'bout that.  Will follow up.

Comment 13 Eric Sandeen 2007-09-17 17:39:12 UTC
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 21:10:06 UTC
modified rawhide kernel, building now.