Bug 431738

Summary: lsattr doesn't show attributes of ext3 quota files
Product: Red Hat Enterprise Linux 5 Reporter: csb sysadmin <admin>
Component: kernelAssignee: Eric Sandeen <esandeen>
Status: CLOSED ERRATA QA Contact: Boris Ranto <branto>
Severity: low Docs Contact:
Priority: low    
Version: 5.1CC: branto, eguan, philip, qcai, sct
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-07-21 10:25:19 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:

Description csb sysadmin 2008-02-06 18:46:43 UTC
Description of problem:

lsattr is not showing attributes of files, or at least for the /aquota.* files.
Other files were not tested. SELinux is off.

# lsattr /aquota.*
------------- /aquota.group
------------- /aquota.user
# chmod 644 /aquota.*
chmod: changing permissions of `/aquota.group': Operation not permitted
chmod: changing permissions of `/aquota.user': Operation not permitted
# chattr -i /aquota.*
# lsattr /aquota.*
------------- /aquota.group
------------- /aquota.user
# chmod 644 /aquota.*

that works.

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

e2fsprogs-1.39-10.el5_1.1

How reproducible:

All the time.

Steps to Reproduce:
1. Make sure SELinux is off.
2. In /etc/fstab make sure to have:

/dev/myvg/rootvol       /                       ext3   
defaults,usrquota,grpquota 0 0

i.e. usrquota,grpquota in the mount options and then reboot.

3. quotacheck -cugm /
4. reboot
5. setquota -g somegroup 0 maxQuotaInKB 0 0 /
6. chmod 644 /aquota.* (returns permission denied on both files)
7. lsattr /aquota.* (showed no bits set)
8. chattr -i /aquota.* (did something)
9. lsattr /aquota.* (showed no bits set, which is ok)
10. chmod 644 /aquota.* (works this time around).

Actual results:

lsattr doesn't show attributes of files

Expected results:

lsattr should show attributes of files

Additional info:

Comment 1 Eric Sandeen 2008-02-07 17:38:20 UTC
FWIW, an upstream change prevents changing the flags on these files:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=e47776a0a41a14a5634633c96e590827f552c4b5

                /* Is it quota file? Do not allow user to mess with it */
                if (IS_NOQUOTA(inode)) {
                        mutex_unlock(&inode->i_mutex);
                        return -EPERM;
                }

The file does indeed have S_IMMUTABLE set (looking at it in the debugger) - I'll
see why it's not reported by lsattr.


Comment 2 Eric Sandeen 2008-02-12 21:59:18 UTC
This actually looks like a kernel issue; it's not a huge priority but yes, it
should be fixed.

Comment 3 Eric Sandeen 2009-06-24 20:25:17 UTC
Hm, took another look at this and upstream it's like this:

[root@inode mnt]# lsattr /mnt/scratch/aquota.user 
-------------e- /mnt/scratch/aquota.user
[root@inode mnt]# chattr +i /mnt/scratch/aquota.*
[root@inode mnt]# lsattr /mnt/scratch/aquota.user 
----i--------e- /mnt/scratch/aquota.user

so it seems to be working there.

Comment 4 Philip Withnall 2009-07-27 13:20:09 UTC
This was fixed upstream with the following commits:

28be5abb400e5e082f5225105fdc69337ec0c0b4
4f99ed67cc1cf5302ea18aa042d75641b61a0a1b
ff9ddf7e847c4dc533f119efb6c77a6e57ab6397

The inode flags in struct ext3_inode_info were going out of sync with the inode flags in struct inode. The above commits fix it for ext[2-4]. Here's the log message of the first one:

commit 28be5abb400e5e082f5225105fdc69337ec0c0b4
Author: Jan Kara <jack>
Date:   Tue May 8 00:30:33 2007 -0700

    ext3: copy i_flags to inode flags on write
    
    A patch that stores inode flags such as S_IMMUTABLE, S_APPEND, etc.  from
    i_flags to EXT3_I(inode)->i_flags when inode is written to disk.  The same
    thing is done on GETFLAGS ioctl.
    
    Quota code changes these flags on quota files (to make it harder for
    sysadmin to screw himself) and these changes were not correctly propagated
    into the filesystem (especially, lsattr did not show them and users were
    wondering...).
    
    Propagate flags such as S_APPEND, S_IMMUTABLE, etc.  from i_flags into
    ext3-specific i_flags.  Hence, when someone sets these flags via a
    different interface than ioctl, they are stored correctly.
    
    Signed-off-by: Jan Kara <jack>
    Cc: <linux-ext4.org>
    Signed-off-by: Andrew Morton <akpm>
    Signed-off-by: Linus Torvalds <torvalds>

Comment 5 Eric Sandeen 2009-07-27 13:43:01 UTC
Ah, thanks for the reminder, I'd forgotten that went by.

-Eric

Comment 7 RHEL Program Management 2011-03-21 23:09:23 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 9 Jarod Wilson 2011-04-04 21:57:33 UTC
Patch(es) available in kernel-2.6.18-255.el5
You can download this test kernel (or newer) from http://people.redhat.com/jwilson/el5
Detailed testing feedback is always welcomed.

Comment 12 errata-xmlrpc 2011-07-21 10:25:19 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-1065.html