[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250508121208.GA5657@nvidia.com>
Date: Thu, 8 May 2025 09:12:08 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: "Tian, Kevin" <kevin.tian@...el.com>
Cc: Nicolin Chen <nicolinc@...dia.com>,
Pranjal Shrivastava <praan@...gle.com>,
"corbet@....net" <corbet@....net>,
"will@...nel.org" <will@...nel.org>,
"bagasdotme@...il.com" <bagasdotme@...il.com>,
"robin.murphy@....com" <robin.murphy@....com>,
"joro@...tes.org" <joro@...tes.org>,
"thierry.reding@...il.com" <thierry.reding@...il.com>,
"vdumpa@...dia.com" <vdumpa@...dia.com>,
"jonathanh@...dia.com" <jonathanh@...dia.com>,
"shuah@...nel.org" <shuah@...nel.org>,
"jsnitsel@...hat.com" <jsnitsel@...hat.com>,
"nathan@...nel.org" <nathan@...nel.org>,
"peterz@...radead.org" <peterz@...radead.org>,
"Liu, Yi L" <yi.l.liu@...el.com>,
"mshavit@...gle.com" <mshavit@...gle.com>,
"zhangzekun11@...wei.com" <zhangzekun11@...wei.com>,
"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org" <linux-arm-kernel@...ts.infradead.org>,
"linux-tegra@...r.kernel.org" <linux-tegra@...r.kernel.org>,
"linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
"patches@...ts.linux.dev" <patches@...ts.linux.dev>,
"mochs@...dia.com" <mochs@...dia.com>,
"alok.a.tiwari@...cle.com" <alok.a.tiwari@...cle.com>,
"vasant.hegde@....com" <vasant.hegde@....com>
Subject: Re: [PATCH v2 13/22] iommufd: Add mmap interface
On Thu, May 08, 2025 at 09:15:47AM +0000, Tian, Kevin wrote:
> > From: Nicolin Chen <nicolinc@...dia.com>
> > Sent: Thursday, May 8, 2025 11:50 AM
> >
> > On Wed, May 07, 2025 at 07:08:09PM -0300, Jason Gunthorpe wrote:
> > > On Wed, May 07, 2025 at 02:09:31PM -0700, Nicolin Chen wrote:
> > > > I have another question: while I don't think my code is handling
> > > > this well either, how should we validate the input address is an
> > > > allowed one?
> > >
> > > The pgoff to mmap? If it isn't in the maple tree it is not allowed, if
> > > it isn't at the start of range it is not allowed, if the size is not
> > > exactly the same as the range it is not allowed.
> >
> > Kevin suggested to allow a partial mmap, i.e allow the size to be
> > smaller than what the cookie describes. Yet, surely the mmap size
> > should not above the allocated size.
> >
>
> let me clarify - I didn't suggested it. Instead it's what the code
> does hence I suggested to make it explicit. 😊
It is probably reasonable to require the pgoff to be at the start but
allow a shorter map, for forward compatability.
But also, you could add flags to the ioctl creating the mmap to
request future bigger sizes.
There is some appeal to be more strict to make misuse less likely..
Jason
Powered by blists - more mailing lists