From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AC0DC33CB1 for ; Fri, 17 Jan 2020 13:08:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 28E6A206E6 for ; Fri, 17 Jan 2020 13:08:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 28E6A206E6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=chris-wilson.co.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BC3EB6E4FE; Fri, 17 Jan 2020 13:08:53 +0000 (UTC) Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 54C5F6E4FE for ; Fri, 17 Jan 2020 13:08:52 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 19916239-1500050 for multiple; Fri, 17 Jan 2020 13:08:50 +0000 MIME-Version: 1.0 To: Matthew Auld From: Chris Wilson In-Reply-To: <157926305863.2389.1610916410403647851@skylake-alporthouse-com> References: <20200116203150.923826-1-matthew.auld@intel.com> <157920953480.7612.16415611914387513987@skylake-alporthouse-com> <157926305863.2389.1610916410403647851@skylake-alporthouse-com> Message-ID: <157926652734.2389.11661018962198755251@skylake-alporthouse-com> User-Agent: alot/0.6 Date: Fri, 17 Jan 2020 13:08:47 +0000 Subject: Re: [Intel-gfx] [PATCH v2 1/2] drm/i915/userptr: add user_size limit check X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel Graphics Development , Matthew Auld Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Quoting Chris Wilson (2020-01-17 12:10:58) > Quoting Matthew Auld (2020-01-17 11:51:53) > > On Thu, 16 Jan 2020 at 21:19, Chris Wilson wrote: > > > > > > Quoting Matthew Auld (2020-01-16 20:31:49) > > > > Don't allow a mismatch between obj->base.size/vma->size and the actual > > > > number of pages for the backing store, which is limited to INT_MAX > > > > pages. > > > > > > > > Signed-off-by: Matthew Auld > > > > Cc: Chris Wilson > > > > --- > > > > drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 12 ++++++++++++ > > > > 1 file changed, 12 insertions(+) > > > > > > > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c > > > > index e5558af111e2..fef96a303d9d 100644 > > > > --- a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c > > > > +++ b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c > > > > @@ -768,6 +768,18 @@ i915_gem_userptr_ioctl(struct drm_device *dev, > > > > if (args->flags & ~(I915_USERPTR_READ_ONLY | > > > > I915_USERPTR_UNSYNCHRONIZED)) > > > > return -EINVAL; > > > > + /* > > > > + * XXX: There is a prevalence of the assumption that we fit the > > > > + * object's page count inside a 32bit _signed_ variable. Let's document > > > > + * this and catch if we ever need to fix it. In the meantime, if you do > > > > + * spot such a local variable, please consider fixing! > > > > + */ > > > > + > > > > + if (args->user_size >> PAGE_SHIFT > INT_MAX) > > > > + return -E2BIG; > > > > > > I'm convinced that the following patch is the last bug (excusing > > > i915_gem_internal.c), and think we should commit to removing this limit. > > > > You mean on our side? There is still all the sg_table stuff, > > __get_user_pages_fast etc. > > Didn't notice the get_user_pages -- some use long, sone ints. oops. > > sg_table I was thinking of just the sg_length snafu that we work around. > We can kill off sg_table itself as we never pass that outside of the > driver, and just assume our chunking is correct. (Basically lifting more > of lib/scatterlist.c into our control, one day we really should tell > them their code doesn't scale to our use.) > > Ok. Let's collate this information into something like > > /* > * XXX: There is a prevalence of the assumption that we fit the > * object's page count inside a 32bit _signed_ variable. Let's document > * this and catch if we ever need to fix it. In the meantime, if you do > * spot such a local variable, please consider fixing! > * > * Aside from our own locals (for which we have no excuse!): > * - sg_table embeds unsigned int for num_pages > * - get_user_pages*() mixed ints with longs > */ If you include the information about what we know remains, Reviewed-by: Chris Wilson -Chris _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx