[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZDMLSOoMt5Ims6xT@eldamar.lan>
Date: Sun, 9 Apr 2023 21:00:24 +0200
From: Salvatore Bonaccorso <carnil@...ian.org>
To: Xu Yilun <yilun.xu@...el.com>, Sangsup Lee <k1rh4.lee@...il.com>
Cc: k1rh4.lee@...il.com, Wu Hao <hao.wu@...el.com>,
Tom Rix <trix@...hat.com>, Moritz Fischer <mdf@...nel.org>,
linux-fpga@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fpga: dfl-afu-region: Add overflow checks for region
size and offset
Hi,
On Fri, Feb 10, 2023 at 04:21:37PM +0800, Xu Yilun wrote:
> On 2023-02-05 at 21:43:26 -0800, k1rh4.lee@...il.com wrote:
> > From: Sangsup Lee <k1rh4.lee@...il.com>
> >
> > The size + offset is able to be integer overflow value and it lead to mis-allocate region.
>
> But I didn't see the memory allocation.
>
> >
> > Signed-off-by: Sangsup Lee <k1rh4.lee@...il.com>
> > ---
> > drivers/fpga/dfl-afu-region.c | 7 ++++++-
> > 1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/fpga/dfl-afu-region.c b/drivers/fpga/dfl-afu-region.c
> > index 2e7b41629406..82b530111601 100644
> > --- a/drivers/fpga/dfl-afu-region.c
> > +++ b/drivers/fpga/dfl-afu-region.c
> > @@ -151,12 +151,17 @@ int afu_mmio_region_get_by_offset(struct dfl_feature_platform_data *pdata,
> > struct dfl_afu_mmio_region *region;
> > struct dfl_afu *afu;
> > int ret = 0;
> > + u64 region_size = 0;
>
> Reverse Xmax tree please.
>
> >
> > mutex_lock(&pdata->lock);
> > + if (check_add_overflow(offset, size, ®ion_size)) {
>
> I'm not sure if the check is necessary.
>
> The offset comes from: offset = vma->vm_pgoff << PAGE_SHIFT
> The size comes from: size = vma->vm_end - vma->vm_start
> Is it possible the upper mm layer passes invalid vma?
>
> Thanks,
> Yilun
Did you saw the comments on your patch by Yilun? Did it felt trough
the cracks?
Regards,
Salvatore
Powered by blists - more mailing lists