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=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 7D499C33CAF for ; Thu, 23 Jan 2020 13:27:13 +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 56B0E21835 for ; Thu, 23 Jan 2020 13:27:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 56B0E21835 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com 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 C27A36FCAD; Thu, 23 Jan 2020 13:27:12 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 371E46FCAD for ; Thu, 23 Jan 2020 13:27:11 +0000 (UTC) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jan 2020 05:27:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,354,1574150400"; d="scan'208";a="229827766" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by orsmga006.jf.intel.com with SMTP; 23 Jan 2020 05:27:08 -0800 Received: by stinkbox (sSMTP sendmail emulation); Thu, 23 Jan 2020 15:27:07 +0200 Date: Thu, 23 Jan 2020 15:27:07 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Chris Wilson Message-ID: <20200123132707.GK13686@intel.com> References: <20200123125934.1401755-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200123125934.1401755-1-chris@chris-wilson.co.uk> X-Patchwork-Hint: comment User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [Intel-gfx] [PATCH] drm/i915/gem: Detect overflow in calculating dumb buffer size 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-gfx@lists.freedesktop.org, stable@vger.kernel.org Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Thu, Jan 23, 2020 at 12:59:34PM +0000, Chris Wilson wrote: > To multiply 2 u32 numbers to generate a u64 in C requires a bit of > forewarning for the compiler. > = > Signed-off-by: Chris Wilson > Cc: Ramalingam C > Cc: Joonas Lahtinen > Cc: stable@vger.kernel.org > --- > drivers/gpu/drm/i915/i915_gem.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > = > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_= gem.c > index 0a20083321a3..ff79da5657f8 100644 > --- a/drivers/gpu/drm/i915/i915_gem.c > +++ b/drivers/gpu/drm/i915/i915_gem.c > @@ -265,7 +265,10 @@ i915_gem_dumb_create(struct drm_file *file, > DRM_FORMAT_MOD_LINEAR)) > args->pitch =3D ALIGN(args->pitch, 4096); > = > - args->size =3D args->pitch * args->height; > + if (args->pitch < args->width) > + return -EINVAL; > + > + args->size =3D mul_u32_u32(args->pitch, args->height); I thought something would have checked these against the mode_config fb limits already. But can't see code like that anywhere. Maybe we should just do that in the core? > = > mem_type =3D INTEL_MEMORY_SYSTEM; > if (HAS_LMEM(to_i915(dev))) > -- = > 2.25.0 > = > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx -- = Ville Syrj=E4l=E4 Intel _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx 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=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 5414FC2D0DB for ; Thu, 23 Jan 2020 13:27:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2CEEC24685 for ; Thu, 23 Jan 2020 13:27:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726232AbgAWN1L (ORCPT ); Thu, 23 Jan 2020 08:27:11 -0500 Received: from mga12.intel.com ([192.55.52.136]:15397 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726227AbgAWN1L (ORCPT ); Thu, 23 Jan 2020 08:27:11 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jan 2020 05:27:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,354,1574150400"; d="scan'208";a="229827766" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by orsmga006.jf.intel.com with SMTP; 23 Jan 2020 05:27:08 -0800 Received: by stinkbox (sSMTP sendmail emulation); Thu, 23 Jan 2020 15:27:07 +0200 Date: Thu, 23 Jan 2020 15:27:07 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Chris Wilson Cc: intel-gfx@lists.freedesktop.org, stable@vger.kernel.org Subject: Re: [Intel-gfx] [PATCH] drm/i915/gem: Detect overflow in calculating dumb buffer size Message-ID: <20200123132707.GK13686@intel.com> References: <20200123125934.1401755-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200123125934.1401755-1-chris@chris-wilson.co.uk> X-Patchwork-Hint: comment User-Agent: Mutt/1.10.1 (2018-07-13) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Thu, Jan 23, 2020 at 12:59:34PM +0000, Chris Wilson wrote: > To multiply 2 u32 numbers to generate a u64 in C requires a bit of > forewarning for the compiler. > > Signed-off-by: Chris Wilson > Cc: Ramalingam C > Cc: Joonas Lahtinen > Cc: stable@vger.kernel.org > --- > drivers/gpu/drm/i915/i915_gem.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c > index 0a20083321a3..ff79da5657f8 100644 > --- a/drivers/gpu/drm/i915/i915_gem.c > +++ b/drivers/gpu/drm/i915/i915_gem.c > @@ -265,7 +265,10 @@ i915_gem_dumb_create(struct drm_file *file, > DRM_FORMAT_MOD_LINEAR)) > args->pitch = ALIGN(args->pitch, 4096); > > - args->size = args->pitch * args->height; > + if (args->pitch < args->width) > + return -EINVAL; > + > + args->size = mul_u32_u32(args->pitch, args->height); I thought something would have checked these against the mode_config fb limits already. But can't see code like that anywhere. Maybe we should just do that in the core? > > mem_type = INTEL_MEMORY_SYSTEM; > if (HAS_LMEM(to_i915(dev))) > -- > 2.25.0 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Ville Syrjälä Intel