Mark Fasheh 5de4480ae7 vfs: allow dedupe of user owned read-only files
The permission check in vfs_dedupe_file_range_one() is too coarse - We only
allow dedupe of the destination file if the user is root, or they have the
file open for write.

This effectively limits a non-root user from deduping their own read-only
files. In addition, the write file descriptor that the user is forced to
hold open can prevent execution of files. As file data during a dedupe
does not change, the behavior is unexpected and this has caused a number of
issue reports. For an example, see:

https://github.com/markfasheh/duperemove/issues/129

So change the check so we allow dedupe on the target if:

- the root or admin is asking for it
- the process has write access
- the owner of the file is asking for the dedupe
- the process could get write access

That way users can open read-only and still get dedupe.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2018-10-17 21:15:39 -04:00
..
2018-08-21 18:19:09 -07:00
2018-06-11 10:16:13 -07:00
2018-08-21 23:54:17 -04:00
2018-10-10 16:41:40 -04:00
2018-08-22 13:29:39 -07:00
2018-08-21 18:47:36 -07:00
2018-08-15 22:40:03 -07:00
2018-08-17 16:20:28 -07:00
2018-08-15 22:47:23 -07:00
2018-08-18 11:44:53 -07:00
2018-05-22 14:27:52 -04:00
2018-08-23 16:03:58 -07:00
2018-10-12 22:46:50 -04:00
2018-08-21 18:19:09 -07:00
2018-05-22 14:27:52 -04:00
2018-08-18 11:44:53 -07:00
2018-08-24 13:50:07 +02:00
\n
2018-08-17 09:38:39 -07:00
2018-08-21 18:19:09 -07:00
2018-07-03 16:44:45 -04:00
2018-08-14 10:23:25 -07:00
2018-08-17 16:20:30 -07:00
2018-06-05 19:23:26 +02:00
2018-08-25 18:43:59 -07:00
2018-08-21 18:19:09 -07:00
2018-05-03 16:11:37 -06:00
2018-08-21 18:19:09 -07:00
2018-08-21 18:19:09 -07:00
2018-07-18 15:44:40 +02:00
2018-08-21 18:15:47 -07:00
2018-06-11 08:22:34 -07:00
2018-08-21 18:19:09 -07:00
2018-02-15 15:34:42 -05:00
2018-08-21 18:19:09 -07:00
2018-04-04 12:44:02 -07:00