Linux-Fsdevel Archive on lore.kernel.org
 help / color / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
To: Rich Felker <dalias@libc.org>
Cc: Andreas Schwab <schwab@linux-m68k.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	"Darrick J. Wong" <darrick.wong@oracle.com>,
	Christoph Hellwig <hch@infradead.org>,
	linux-xfs@vger.kernel.org, libc-alpha@sourceware.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: XFS reports lchmod failure, but changes file system contents
Date: Wed, 12 Feb 2020 21:26:11 +0100
Message-ID: <87sgjflfh8.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: <20200212201951.GC1663@brightrain.aerifal.cx> (Rich Felker's message of "Wed, 12 Feb 2020 15:19:51 -0500")

* 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?

  reply index

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12 11:48 Florian Weimer
2020-02-12 12:15 ` Florian Weimer
2020-02-12 16:16 ` Darrick J. Wong
2020-02-12 18:11   ` Christoph Hellwig
2020-02-12 18:37     ` Darrick J. Wong
2020-02-12 19:15       ` Florian Weimer
2020-02-12 19:51         ` Al Viro
2020-02-12 19:55           ` Rich Felker
2020-02-12 20:01           ` Florian Weimer
2020-02-12 20:17             ` Andreas Schwab
2020-02-12 20:19               ` Rich Felker
2020-02-12 20:26                 ` Florian Weimer [this message]
2020-02-12 20:38                   ` Rich Felker
2020-02-12 20:27                 ` Al Viro
2020-02-12 20:36                   ` Rich Felker
2020-02-12 20:18             ` Rich Felker
2020-02-12 20:38             ` Paul Eggert
2020-02-21  4:09             ` Aleksa Sarai
2020-02-21  5:02               ` Al Viro
2020-02-21  5:21                 ` Aleksa Sarai
2020-02-12 18:50     ` Florian Weimer
2020-02-12 18:55       ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sgjflfh8.fsf@mid.deneb.enyo.de \
    --to=fw@deneb.enyo.de \
    --cc=dalias@libc.org \
    --cc=darrick.wong@oracle.com \
    --cc=hch@infradead.org \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=schwab@linux-m68k.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Fsdevel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-fsdevel/0 linux-fsdevel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-fsdevel linux-fsdevel/ https://lore.kernel.org/linux-fsdevel \
		linux-fsdevel@vger.kernel.org
	public-inbox-index linux-fsdevel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-fsdevel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git