attr_punch_hole() handles a range that is not cluster aligned by reporting the frame size back to the caller, which zeroes the partial clusters and retries. Return -EINVAL for an unaligned punch on a compressed attribute; the sparse case is unaffected. Signed-off-by: Konstantin Komarov --- fs/ntfs3/attrib.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 254037763a86..928c91b57da5 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -2386,6 +2386,12 @@ int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32 *frame_size) if ((vbo | bytes) & mask) { /* We have to zero a range(s). */ + if (is_attr_compressed(attr_b)) { + /* Compressed file punch must be frame aligned. */ + return -EINVAL; + } + + /* Sparse files can be punched. */ if (!frame_size) { /* Caller insists range is aligned. */ return -EINVAL; -- 2.43.0