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)
committerivanmeler <i_ivan@windowslive.com>
Wed, 13 Apr 2022 21:13:59 +0000 (21:13 +0000)
commit823b16faf825038de8ac53b599aec128a9d8ee8f
treeb7fd59b118036ea56ece5dbb9fc07dfcb0edbb18
parent0bde6976e65812ce6c069e88f1a7151e80d8c798
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