Re: XFS reports lchmod failure, but changes file system contents

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 12, 2020 at 09:26:11PM +0100, Florian Weimer wrote:
> * Rich Felker:
> 
> > On Wed, Feb 12, 2020 at 09:17:41PM +0100, Andreas Schwab wrote:
> >> On Feb 12 2020, Florian Weimer wrote:
> >> 
> >> > * Al Viro:
> >> >
> >> >> On Wed, Feb 12, 2020 at 08:15:08PM +0100, Florian Weimer wrote:
> >> >>
> >> >>> | Further, I've found some inconsistent behavior with ext4: chmod on the
> >> >>> | magic symlink fails with EOPNOTSUPP as in Florian's test, but fchmod
> >> >>> | on the O_PATH fd succeeds and changes the symlink mode. This is with
> >> >>> | 5.4. Cany anyone else confirm this? Is it a problem?
> >> >>> 
> >> >>> It looks broken to me because fchmod (as an inode-changing operation)
> >> >>> is not supposed to work on O_PATH descriptors.
> >> >>
> >> >> Why?  O_PATH does have an associated inode just fine; where does
> >> >> that "not supposed to" come from?
> >> >
> >> > It fails on most file systems right now.  I thought that was expected.
> >> > Other system calls (fsetxattr IIRC) do not work on O_PATH descriptors,
> >> > either.  I assumed that an O_PATH descriptor was not intending to
> >> > confer that capability.  Even openat fails.
> >> 
> >> According to open(2), this is expected:
> >> 
> >>        O_PATH (since Linux 2.6.39)
> >>               Obtain a file descriptor that can be used for two  purposes:  to
> >>               indicate a location in the filesystem tree and to perform opera-
> >>               tions that act purely at the file descriptor  level.   The  file
> >>               itself  is not opened, and other file operations (e.g., read(2),
> >>               write(2), fchmod(2), fchown(2), fgetxattr(2), ioctl(2), mmap(2))
> >>               fail with the error EBADF.
> >
> > That text is outdated and should be corrected. Fixing fchmod fchown,
> > fstat, etc. to operate on O_PATH file descriptors was a very
> > intentional change in the kernel.
> 
> I suppose we could do the S_ISLNK check, try fchmod, and if that
> fails, go via /proc.  Is this the direction you want to go in?

It was, but Al Viro just pointed out to me that I was wrong. I think
we could use fstat (which AIUI now works) to do the S_ISLNK check, so
that it doesn't depend on /proc, but I don't see a way to do the chmod
operation without /proc at this time.

Rich



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux