UPSTREAM: loop: drop caches if offset or block_size are changed
authorJaegeuk Kim <jaegeuk@kernel.org>
Fri, 14 Dec 2018 19:14:38 +0000 (11:14 -0800)
committerMichael Benedict <michaelbt@live.com>
Sat, 5 Oct 2019 02:31:33 +0000 (12:31 +1000)
commit86b3474fc2973f7a689c7c669621397115574774
tree698ec3ac84d8de4c21797c4440f773b0475daf1c
parent0df6179ff59959f47eb066e52d4fa3560e1000d4
UPSTREAM: loop: drop caches if offset or block_size are changed

If we don't drop caches used in old offset or block_size, we can get old data
from new offset/block_size, which gives unexpected data to user.

For example, Martijn found a loopback bug in the below scenario.
1) LOOP_SET_FD loads first two pages on loop file
2) LOOP_SET_STATUS64 changes the offset on the loop file
3) mount is failed due to the cached pages having wrong superblock

Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Reported-by: Martijn Coenen <maco@google.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
(cherry picked from commit 490b8c65b9db45896769e1095e78725775f47b3e)
Change-Id: Iffb7e1f04ab587e1a8785bc862a425efb654be24
drivers/block/loop.c