Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp216080rwb; Fri, 12 Aug 2022 18:11:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR5jIXHL/N/vOWFo3QP5U9T3tANHHWbt/Uq4+VRvlCzBXpQ2IdbwzK/UBFziTS2BzZ8v8yF5 X-Received: by 2002:a05:6a00:174e:b0:52b:c705:a42c with SMTP id j14-20020a056a00174e00b0052bc705a42cmr6535457pfc.68.1660353077602; Fri, 12 Aug 2022 18:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660353077; cv=none; d=google.com; s=arc-20160816; b=RTqJLG+/2djabiC/ANaCyEw5e7c/JZEtPeAZqzBEeO/D7aFaQMfyrNu4Av5Rmy/vaZ lqfXXv4E4U0gQidaII4Stkwj3pZQDBamOXE7TryrsPnPAd5ntu67Lkmu/6TWwfFKliSo 2LEhWQt4I0TXrCVENj980fuDvP9OUF+/kyhM4waCrT19uKWxdpjlJ72JkftJbZUFxchF yZ1z7+fKaZB7ABncEd+PG+6bN85BZ05WLRognxO1peXHb3LBqVOSyKws1KEr/+whY4M8 LoYypi0jS46Uh7rnRL24navPsaMjmGSNNEvYCpWggexy4zgPR4I97t51UouzLDXoDCE4 C+yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vOiUiUBT3AIO6nyO2JKWbxpeGhHIUJMqADLBas44GUo=; b=tDIRe3+zFOefWJ79dwbuD7DSRZM3zGYLbA/yWFLPhX9vUo8JI+lQDw5J5LzDwo2FlA KLt1F8nLV+s778VDmtcXEUdyD2rb7rvg6ZC1+01bT7SY/F42cVn3vcSqTwF1oqfpoovh p4jhl1E0RaE1W3F+qP8L/ZN2tZSS9jj9IaaJfnRI8aD7bmyAhtFcZYzT8yvuwnwgAMUa PbnOxSvNrK/VSyJ+RC0SIptEAz1g7EPnWsROOevZ/zNf7dY6Y2VEBnYsn++w4KRslOS0 KbjHeHLnf9znMUxgHeOOCZsp3OGVlDkBPeWx5JcI4XuaqrtQ/zoHUjWB595VT8B+AZVG eWkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JwwC1Hvw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a654d07000000b0041a8d6b47a8si3868983pgt.699.2022.08.12.18.11.05; Fri, 12 Aug 2022 18:11:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JwwC1Hvw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238809AbiHMBJv (ORCPT + 99 others); Fri, 12 Aug 2022 21:09:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238223AbiHMBJS (ORCPT ); Fri, 12 Aug 2022 21:09:18 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88332AB067 for ; Fri, 12 Aug 2022 18:09:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660352954; x=1691888954; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uGkMdALCNhPir9OCf7HNUlcXk+ktqw6h9jb2//vd0mQ=; b=JwwC1HvwD54pIIstFMRWMKu3ob2Y7L77ehqeDwOAQSgzTx8iFuc9PONQ KdPovY82AL7eRMzIIsuH84KTxOCBkDW0UAPbBmpLiyTg1SDmgjWo3RX4H mlhwDq4E4X5Zz3RzDexAlSV3g8RT6um/S+GeBKXnLVdqU9Rjahs6aMxrV JZcFNPEahIC/5BSVOzXsbRSKqSvGIcfT/XLhBLcGhTQYGDMalMmhedUpE aokD4WbIK2i1ctBUp2d/eSQpCOwH5TS5v/eU1Cx2XzCCGrJoc6c91EYtS LnCnKiohrW+I+8biMslnRUgEmT0df0Ew9eyXQU9Iu3DjQEghWgOGzEgLC Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10437"; a="271488740" X-IronPort-AV: E=Sophos;i="5.93,233,1654585200"; d="scan'208";a="271488740" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2022 18:09:14 -0700 X-IronPort-AV: E=Sophos;i="5.93,233,1654585200"; d="scan'208";a="666038387" Received: from akoska-mobl1.ger.corp.intel.com (HELO hades.ger.corp.intel.com) ([10.252.36.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2022 18:09:11 -0700 From: Gwan-gyeong Mun To: intel-gfx@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, mchehab@kernel.org, chris@chris-wilson.co.uk, matthew.auld@intel.com, thomas.hellstrom@linux.intel.com, jani.nikula@intel.com, nirmoy.das@intel.com, airlied@linux.ie, daniel@ffwll.ch, andi.shyti@linux.intel.com, andrzej.hajda@intel.com Subject: [PATCH v6 6/8] drm/i915: Check if the size is too big while creating shmem file Date: Sat, 13 Aug 2022 04:08:55 +0300 Message-Id: <20220813010857.4043956-7-gwan-gyeong.mun@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220813010857.4043956-1-gwan-gyeong.mun@intel.com> References: <20220813010857.4043956-1-gwan-gyeong.mun@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The __shmem_file_setup() function returns -EINVAL if size is greater than MAX_LFS_FILESIZE. To handle the same error as other code that returns -E2BIG when the size is too large, it add a code that returns -E2BIG when the size is larger than the size that can be handled. v4: If BITS_PER_LONG is 32, size > MAX_LFS_FILESIZE is always false, so it checks only when BITS_PER_LONG is 64. Signed-off-by: Gwan-gyeong Mun Cc: Chris Wilson Cc: Matthew Auld Cc: Thomas Hellström Reviewed-by: Nirmoy Das Reviewed-by: Mauro Carvalho Chehab Reported-by: kernel test robot Reviewed-by: Andrzej Hajda --- drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c index 4cb35808e431..4a7a6d65fc7a 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c @@ -541,6 +541,20 @@ static int __create_shmem(struct drm_i915_private *i915, drm_gem_private_object_init(&i915->drm, obj, size); + /* XXX: The __shmem_file_setup() function returns -EINVAL if size is + * greater than MAX_LFS_FILESIZE. + * To handle the same error as other code that returns -E2BIG when + * the size is too large, we add a code that returns -E2BIG when the + * size is larger than the size that can be handled. + * If BITS_PER_LONG is 32, size > MAX_LFS_FILESIZE is always false, + * so we only needs to check when BITS_PER_LONG is 64. + * If BITS_PER_LONG is 32, E2BIG checks are processed when + * i915_gem_object_size_2big() is called before init_object() callback + * is called. + */ + if (BITS_PER_LONG == 64 && size > MAX_LFS_FILESIZE) + return -E2BIG; + if (i915->mm.gemfs) filp = shmem_file_setup_with_mnt(i915->mm.gemfs, "i915", size, flags); -- 2.34.1