[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zx9PTso9Me5es7He@infradead.org>
Date: Mon, 28 Oct 2024 01:46:06 -0700
From: Christoph Hellwig <hch@...radead.org>
To: MottiKumar Babu <mottikumarbabu@...il.com>
Cc: cem@...nel.org, djwong@...nel.org, chandanbabu@...nel.org,
dchinner@...hat.com, zhangjiachen.jaycee@...edance.com,
linux-xfs@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-kernel-mentees@...ts.linux.dev, anupnewsmail@...il.com,
skhan@...uxfoundation.org
Subject: Re: [PATCH] Fix out-of-bounds access in xfs_bmapi_allocate by
validating whichfork
On Mon, Oct 28, 2024 at 01:05:27AM +0530, MottiKumar Babu wrote:
> This issue was reported by Coverity Scan.
>
> Report:
> CID 1633175 Out-of-bounds access - Access of memory not owned by this buffer may cause crashes or incorrect computations.
> In xfs_bmapi_allocate: Out-of-bounds access to a buffer (CWE-119)
>
> Signed-off-by: MottiKumar Babu <mottikumarbabu@...il.com>
> ---
> fs/xfs/libxfs/xfs_bmap.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 36dd08d13293..6ff378d2d3d9 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -4169,6 +4169,10 @@ xfs_bmapi_allocate(
> * is not on the busy list.
> */
> bma->datatype = XFS_ALLOC_NOBUSY;
> + // Ensure whichfork is valid (0 or 1) before further checks
> + if (whichfork < 0 || whichfork > 1) {
> + return -EINVAL; // Invalid fork
How is this supposed to happen?
Powered by blists - more mailing lists