|
8 | 8 | #include "fsverity_private.h"
|
9 | 9 |
|
10 | 10 | #include <linux/mount.h>
|
11 |
| -#include <linux/pagemap.h> |
12 | 11 | #include <linux/sched/signal.h>
|
13 | 12 | #include <linux/uaccess.h>
|
14 | 13 |
|
@@ -367,25 +366,27 @@ int fsverity_ioctl_enable(struct file *filp, const void __user *uarg)
|
367 | 366 | goto out_drop_write;
|
368 | 367 |
|
369 | 368 | err = enable_verity(filp, &arg);
|
370 |
| - if (err) |
371 |
| - goto out_allow_write_access; |
372 | 369 |
|
373 | 370 | /*
|
374 |
| - * Some pages of the file may have been evicted from pagecache after |
375 |
| - * being used in the Merkle tree construction, then read into pagecache |
376 |
| - * again by another process reading from the file concurrently. Since |
377 |
| - * these pages didn't undergo verification against the file digest which |
378 |
| - * fs-verity now claims to be enforcing, we have to wipe the pagecache |
379 |
| - * to ensure that all future reads are verified. |
| 371 | + * We no longer drop the inode's pagecache after enabling verity. This |
| 372 | + * used to be done to try to avoid a race condition where pages could be |
| 373 | + * evicted after being used in the Merkle tree construction, then |
| 374 | + * re-instantiated by a concurrent read. Such pages are unverified, and |
| 375 | + * the backing storage could have filled them with different content, so |
| 376 | + * they shouldn't be used to fulfill reads once verity is enabled. |
| 377 | + * |
| 378 | + * But, dropping the pagecache has a big performance impact, and it |
| 379 | + * doesn't fully solve the race condition anyway. So for those reasons, |
| 380 | + * and also because this race condition isn't very important relatively |
| 381 | + * speaking (especially for small-ish files, where the chance of a page |
| 382 | + * being used, evicted, *and* re-instantiated all while enabling verity |
| 383 | + * is quite small), we no longer drop the inode's pagecache. |
380 | 384 | */
|
381 |
| - filemap_write_and_wait(inode->i_mapping); |
382 |
| - invalidate_inode_pages2(inode->i_mapping); |
383 | 385 |
|
384 | 386 | /*
|
385 | 387 | * allow_write_access() is needed to pair with deny_write_access().
|
386 | 388 | * Regardless, the filesystem won't allow writing to verity files.
|
387 | 389 | */
|
388 |
| -out_allow_write_access: |
389 | 390 | allow_write_access(filp);
|
390 | 391 | out_drop_write:
|
391 | 392 | mnt_drop_write_file(filp);
|
|
0 commit comments