Bug 749117 - extN: new file created even if open(2) returned -EPERM
Summary: extN: new file created even if open(2) returned -EPERM
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: kernel
Version: 6.3
Hardware: All
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: Eric Sandeen
QA Contact: Petr Beňas
URL:
Whiteboard:
Depends On:
Blocks: 756309 767187
TreeView+ depends on / blocked
 
Reported: 2011-10-26 08:43 UTC by Eryu Guan
Modified: 2015-01-04 23:01 UTC (History)
7 users (show)

Fixed In Version: kernel-2.6.32-229.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 756309 (view as bug list)
Environment:
Last Closed: 2012-06-20 08:00:14 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2012:0862 0 normal SHIPPED_LIVE Moderate: Red Hat Enterprise Linux 6 kernel security, bug fix and enhancement update 2012-06-20 12:55:00 UTC

Description Eryu Guan 2011-10-26 08:43:19 UTC
Description of problem:
In an append only dir, a open(2) call without O_RDONLY and O_APPEND will return -EPERM, but after the call new file is created.

Version-Release number of selected component (if applicable):
kernel-2.6.32-211.el6

How reproducible:
100%

Steps to Reproduce:
1. mkdir /mnt/ext4/append-only
2. chattr +a /mnt/ext4/append-only
3. ./test /mnt/ext4/append-only/testfile (touch /mnt/ext4/append-only/testfile will also work, but touch won't return error, you have to strace touch and search for open, it returns -EPERM)

# cat test.c
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <errno.h>

int main(int argc, char *argv[])
{
        int fd;
        fd = open(argv[1], O_RDWR|O_CREAT, 0666);
        if (fd == -1)
                perror("open failed");
        exit(errno);
}
  
Actual results:
[root@fstest xfstests]# mkdir -p /mnt/ext4/append-only
[root@fstest xfstests]# chattr +a /mnt/ext4/append-only
[root@fstest xfstests]# lsattr /mnt/ext4/
--------------- /mnt/ext4/lost+found
-----a-------e- /mnt/ext4/append-only
[root@fstest xfstests]# ./test /mnt/ext4/append-only/testfile
open failed: Operation not permitted
[root@fstest xfstests]# ls -l /mnt/ext4/append-only/testfile
-rw-r--r--. 1 root root 0 Oct 26 16:07 /mnt/ext4/append-only/testfile
[root@fstest xfstests]# lsattr /mnt/ext4/append-only/testfile
-----a-------e- /mnt/ext4/append-only/testfile

Expected results:
open(2) return success or new file is not created at all

Additional info:
xfs will create new file with no problem
btrfs will fail too

Not sure if it's really a bug, but some kind of inconsistent

Comment 3 Ric Wheeler 2011-10-28 05:31:35 UTC
This would be an upstream discussion I think.

Comment 4 Eryu Guan 2011-10-30 01:33:19 UTC
Seems upstream prefers masking out append and immutable bits from EXTN_FL_INHERITED

http://permalink.gmane.org/gmane.comp.file-systems.ext4/27277

Comment 5 Eric Sandeen 2011-12-22 19:33:55 UTC
Upstream now as of commit 1cd9f097

Comment 7 RHEL Program Management 2011-12-22 19:49:46 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 8 Aristeu Rozanski 2012-02-10 19:33:49 UTC
Patch(es) available on kernel-2.6.32-229.el6

Comment 12 Petr Beňas 2012-02-23 09:41:04 UTC
Reproduced in 2.6.32-221.el6.x86_64 and verified in 2.6.32-229.el6.x86_64.

Comment 14 errata-xmlrpc 2012-06-20 08:00:14 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2012-0862.html


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