mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
ntfs: handle signal interruption in fallocate
The ntfs_attr_fallocate() function checks for pending signals during
allocation loops and exits early via 'out' label. However, when a signal
interrupts the operation with err == 0, the function returns 0 (success)
instead of -EINTR.
The signal_pending() checks at the allocation loops jump to 'out' without
setting err = -EINTR, so the function returns success even when interrupted
by a signal.
Set err = -EINTR when jumping to the signal exit path, and only override
when no other error is pending. This ensures:
- Allocation interrupted by signal returns -EINTR
- Allocation that completed successfully before signal arrived returns 0
- Other errors are preserved and not overwritten by -EINTR
Fixes: 495e90fa33 ("ntfs: update attrib operations")
Cc: stable@vger.kernel.org
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
parent
03c6ecc4b4
commit
4dc8f4ee2d
|
|
@ -5709,7 +5709,7 @@ int ntfs_attr_fallocate(struct ntfs_inode *ni, loff_t start, loff_t byte_len, bo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signal_pending(current))
|
if (signal_pending(current))
|
||||||
goto out;
|
goto signal_out;
|
||||||
|
|
||||||
vcn += alloc_cnt;
|
vcn += alloc_cnt;
|
||||||
try_alloc_cnt -= alloc_cnt;
|
try_alloc_cnt -= alloc_cnt;
|
||||||
|
|
@ -5730,7 +5730,7 @@ int ntfs_attr_fallocate(struct ntfs_inode *ni, loff_t start, loff_t byte_len, bo
|
||||||
up_write(&ni->runlist.lock);
|
up_write(&ni->runlist.lock);
|
||||||
mutex_unlock(&ni->mrec_lock);
|
mutex_unlock(&ni->mrec_lock);
|
||||||
if (err || signal_pending(current))
|
if (err || signal_pending(current))
|
||||||
goto out;
|
goto signal_out;
|
||||||
|
|
||||||
vcn += alloc_cnt;
|
vcn += alloc_cnt;
|
||||||
try_alloc_cnt -= alloc_cnt;
|
try_alloc_cnt -= alloc_cnt;
|
||||||
|
|
@ -5756,4 +5756,8 @@ int ntfs_attr_fallocate(struct ntfs_inode *ni, loff_t start, loff_t byte_len, bo
|
||||||
mutex_unlock(&ni->mrec_lock);
|
mutex_unlock(&ni->mrec_lock);
|
||||||
out:
|
out:
|
||||||
return err >= 0 ? 0 : err;
|
return err >= 0 ? 0 : err;
|
||||||
|
signal_out:
|
||||||
|
if (!err)
|
||||||
|
err = -EINTR;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user