After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 763676 - rofiles-fuse can_write check inverted
rofiles-fuse can_write check inverted
Status: RESOLVED FIXED
Product: ostree
Classification: Infrastructure
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: OSTree maintainer(s)
OSTree maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-03-15 12:22 UTC by Alexander Larsson
Modified: 2016-03-16 15:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
rofiles-fuse: Fix permission comparison (823 bytes, patch)
2016-03-15 12:22 UTC, Alexander Larsson
accepted-commit_now Details | Review

Description Alexander Larsson 2016-03-15 12:22:02 UTC
You can't e.g. chmod a newly created file, but you can chown an old file...
Comment 1 Alexander Larsson 2016-03-15 12:22:51 UTC
Created attachment 323977 [details] [review]
rofiles-fuse: Fix permission comparison

We want to allow write if the devinode is in the set,
not the other way around.
Comment 2 Alexander Larsson 2016-03-15 12:44:32 UTC
VERIFY_WRITE() also seems racy. You do a path-based stat check and then a path-based e.g. truncate operation, You need to open the fd in the verification, fstat on it and then do the operation based on the fd (ftruncate, fchmod, etc).

Also in general, there seem to be various edge-cases where i'm not sure rofiles-fuse does the right thing, since it always uses path based resolution even if the app did a fd-based operation. For example, a userspace fstat() call will be turned into a fstatat(basefd, path) where the path is some magical thing that fuse.c extracts from the inode nr passed in. In the case of an unlinked temp file that can easily do the wrong thing.

I'm trying to figure out if there is a way to use this to e.g. truncate (setattr SIZE) a ro file, but I can't think of any atm. Its still possibly confusing for userspace though.
Comment 3 Colin Walters 2016-03-15 13:32:22 UTC
Review of attachment 323977 [details] [review]:

Oh, hah.  In my defense, what I was primarily testing was open(..., O_TRUNC) which *does* work correctly because we rewrite the open flags.  This is also covered by the test suite.

Mind adding a test for this too?  (optional, feel free to commit as is)
Comment 4 Colin Walters 2016-03-15 13:35:04 UTC
As far as the fd vs path issues...yeah, true =/  Hm, your patch may actually make these worse as we will suddenly start enforcing things other than open(), right?

We could probably fix some of these with the FUSE lowlevel ops.  But anyways, I see rofiles-fuse as just a transient thing for functionality that should *really* live in the kernel.  See http://www.spinics.net/lists/linux-fsdevel/msg75085.html
Comment 5 Alexander Larsson 2016-03-16 15:31:51 UTC
I think you can handle the fd thing in some cases by looking at (struct fuse_file_info *)fi->fh.
Comment 6 Alexander Larsson 2016-03-16 15:33:13 UTC
Attachment 323977 [details] pushed as 89624ee - rofiles-fuse: Fix permission comparison