All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* bug in may_dedupe_file allows to deduplicate files we aren't allowed to write to
@ 2024-05-04  4:49 Hugo Valtier
  2024-05-04  9:43 ` Amir Goldstein
  0 siblings, 1 reply; 5+ messages in thread
From: Hugo Valtier @ 2024-05-04  4:49 UTC (permalink / raw
  To: mfasheh, viro, linux-fsdevel, linux-kernel

For context I am making a file based deduplication tool.

I found that in this commit
5de4480ae7f8 ("vfs: allow dedupe of user owned read-only files")
it states:
> - the process could get write access

However the behavior added in allow_file_dedupe now may_dedupe_file is opposite:
> +       if (!inode_permission(file_inode(file), MAY_WRITE))
> +               return true

I've tested that I can create an other readonly file as root and have
my unprivileged user deduplicate it however if I then make the file
other writeable I cannot anymore*.
It doesn't make sense to me why giving write permissions on a file
should remove the permission to deduplicate*.

I'm not sure on how to fix this, flipping the condition would work but
that is a breaking change and idk if this is ok here.
Adding a check to also users who have write access to the file would
remove all the logic here since you would always be allowed to dedup
FDs you managed to get your hands on.

Any input on this welcome, thx

*without opening the file in write mode which I don't want to do
because it can prevent execution of files which is the exact thing is
5de4480ae7f8 were trying to address in the first place

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-07 22:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-04  4:49 bug in may_dedupe_file allows to deduplicate files we aren't allowed to write to Hugo Valtier
2024-05-04  9:43 ` Amir Goldstein
2024-05-04 20:50   ` Hugo Valtier
2024-05-05  6:57     ` Amir Goldstein
2024-05-07 22:14       ` Darrick J. Wong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.