diff mbox series

[SRU,Impish,Hirsute,HWE-5.11,OEM-5.10] xfs: map unwritten blocks in XFS_IOC_{ALLOC, FREE}SP just like fallocate

Message ID 20220120143129.118237-2-cascardo@canonical.com
State New
Headers show
Series [SRU,Impish,Hirsute,HWE-5.11,OEM-5.10] xfs: map unwritten blocks in XFS_IOC_{ALLOC, FREE}SP just like fallocate | expand

Commit Message

Thadeu Lima de Souza Cascardo Jan. 20, 2022, 2:31 p.m. UTC
From: "Darrick J. Wong" <djwong@kernel.org>

The old ALLOCSP/FREESP ioctls in XFS can be used to preallocate space at
the end of files, just like fallocate and RESVSP.  Make the behavior
consistent with the other ioctls.

Reported-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
(cherry picked from commit 983d8e60f50806f90534cc5373d0ce867e5aaf79)
CVE-2021-4155
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
---
 fs/xfs/xfs_ioctl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Stefan Bader Jan. 25, 2022, 11:15 a.m. UTC | #1
On 20.01.22 15:31, Thadeu Lima de Souza Cascardo wrote:
> From: "Darrick J. Wong" <djwong@kernel.org>
> 
> The old ALLOCSP/FREESP ioctls in XFS can be used to preallocate space at
> the end of files, just like fallocate and RESVSP.  Make the behavior
> consistent with the other ioctls.
> 
> Reported-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> Reviewed-by: Dave Chinner <dchinner@redhat.com>
> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
> (cherry picked from commit 983d8e60f50806f90534cc5373d0ce867e5aaf79)
> CVE-2021-4155
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
> ---

Applied to focal:linux-hwe-5.11/hwe-5.11-next. This is taking over for 
impish:linux. Thanks.

-Stefan

>   fs/xfs/xfs_ioctl.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 1fe4c1fc0aea..feebc9c2c2aa 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -687,7 +687,8 @@ xfs_ioc_space(
>   
>   	if (bf->l_start > XFS_ISIZE(ip)) {
>   		error = xfs_alloc_file_space(ip, XFS_ISIZE(ip),
> -				bf->l_start - XFS_ISIZE(ip), 0);
> +				bf->l_start - XFS_ISIZE(ip),
> +				XFS_BMAPI_PREALLOC);
>   		if (error)
>   			goto out_unlock;
>   	}
Stefan Bader Jan. 25, 2022, 11:18 a.m. UTC | #2
On 25.01.22 12:15, Stefan Bader wrote:
> On 20.01.22 15:31, Thadeu Lima de Souza Cascardo wrote:
>> From: "Darrick J. Wong" <djwong@kernel.org>
>>
>> The old ALLOCSP/FREESP ioctls in XFS can be used to preallocate space at
>> the end of files, just like fallocate and RESVSP.  Make the behavior
>> consistent with the other ioctls.
>>
>> Reported-by: Kirill Tkhai <ktkhai@virtuozzo.com>
>> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
>> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
>> Reviewed-by: Dave Chinner <dchinner@redhat.com>
>> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
>> (cherry picked from commit 983d8e60f50806f90534cc5373d0ce867e5aaf79)
>> CVE-2021-4155
>> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
>> ---
> 
> Applied to focal:linux-hwe-5.11/hwe-5.11-next. This is taking over for 
> impish:linux. Thanks.

I clearly _mean_ hirsute:linux... sorry

-Stefan

> 
> -Stefan
> 
>>   fs/xfs/xfs_ioctl.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
>> index 1fe4c1fc0aea..feebc9c2c2aa 100644
>> --- a/fs/xfs/xfs_ioctl.c
>> +++ b/fs/xfs/xfs_ioctl.c
>> @@ -687,7 +687,8 @@ xfs_ioc_space(
>>       if (bf->l_start > XFS_ISIZE(ip)) {
>>           error = xfs_alloc_file_space(ip, XFS_ISIZE(ip),
>> -                bf->l_start - XFS_ISIZE(ip), 0);
>> +                bf->l_start - XFS_ISIZE(ip),
>> +                XFS_BMAPI_PREALLOC);
>>           if (error)
>>               goto out_unlock;
>>       }
> 
>
Stefan Bader Jan. 26, 2022, 3:07 p.m. UTC | #3
On 20.01.22 15:31, Thadeu Lima de Souza Cascardo wrote:
> From: "Darrick J. Wong" <djwong@kernel.org>
> 
> The old ALLOCSP/FREESP ioctls in XFS can be used to preallocate space at
> the end of files, just like fallocate and RESVSP.  Make the behavior
> consistent with the other ioctls.
> 
> Reported-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> Reviewed-by: Dave Chinner <dchinner@redhat.com>
> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
> (cherry picked from commit 983d8e60f50806f90534cc5373d0ce867e5aaf79)
> CVE-2021-4155
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
> ---

Applied to impish:linux/master-next. Thanks.

-Stefan

>   fs/xfs/xfs_ioctl.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 1fe4c1fc0aea..feebc9c2c2aa 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -687,7 +687,8 @@ xfs_ioc_space(
>   
>   	if (bf->l_start > XFS_ISIZE(ip)) {
>   		error = xfs_alloc_file_space(ip, XFS_ISIZE(ip),
> -				bf->l_start - XFS_ISIZE(ip), 0);
> +				bf->l_start - XFS_ISIZE(ip),
> +				XFS_BMAPI_PREALLOC);
>   		if (error)
>   			goto out_unlock;
>   	}
diff mbox series

Patch

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 1fe4c1fc0aea..feebc9c2c2aa 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -687,7 +687,8 @@  xfs_ioc_space(
 
 	if (bf->l_start > XFS_ISIZE(ip)) {
 		error = xfs_alloc_file_space(ip, XFS_ISIZE(ip),
-				bf->l_start - XFS_ISIZE(ip), 0);
+				bf->l_start - XFS_ISIZE(ip),
+				XFS_BMAPI_PREALLOC);
 		if (error)
 			goto out_unlock;
 	}