Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3504021rwb; Tue, 16 Aug 2022 04:23:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR7wJcSWxWhrRSfA0SJDaewQPq3/lXYiy8cE5GAgMN51x1GBWp5A4E+17zROGssA4gKtteBZ X-Received: by 2002:aa7:d6cd:0:b0:43d:4ab8:87b8 with SMTP id x13-20020aa7d6cd000000b0043d4ab887b8mr18446281edr.412.1660648986017; Tue, 16 Aug 2022 04:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660648986; cv=none; d=google.com; s=arc-20160816; b=nBRmiv8eXXONsGMLpCKQOVzfy0FGgqefwO1LzUJX3O2cTW0gpum7UA+bcssYoIu9vF k+GzMx4TPO27jc4+5RsMO3fyc1bhv3407w7wjPGNpM3m2AwkLuuax8fCTvidMn8M6NSc zV+b6XCaC7a+Dch2s1S2+9fQbzgdMDgAMX8OCtcEyQ+LTt8inRyirHUE5ekgqGXJetm5 xHR3NFK84ub6mzoNuM8YMLuHNcophRueauCrqnefwbVORwUeddAnALYKYrEG1AfuXy7G 083HrPPbj4PbtfOnVUhkUn4fJuDNYlAELtLM5dz6wMtNv/+EoMoOSZaziS1iQtqdQE6P 9ltw== 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=sVYafVhZJncteQP6NWcqdElDh3uXuo53pPtT6i1lqz8=; b=KQHIqnCkK39MmzLv7iJ+mm4sEQgRuWvgZBvp/pO6npWCfsaxNBdKosWyodqyXlc59W y+fQJN+GtBfaUZo/ng0bm8MXz3LdRC8ussmtf1lPIyDH3d9oL55mWaLbn57TxluB4+zL GqX5IUhjH2Rc5Osp+UT6ey85+Bc+6J0GTiwoUbkAv7VtcCwjG7ARqyHphC/1lea9bsa+ mFku6uI2mMCEu4yY/ru4fCEimqDDdAJbCk2pWwD06l8SLSO1XIuXBC4lcBNkNcFLwtSB pxPXECmzvT0nluX4udsRPtwS6xP4+bDgzM+0C7n4Bz4dGhJCxigrR/9XHMmFd9tDNQbs iaTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=llpqdswo; 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 vp22-20020a17090712d600b0072aeded8896si7995579ejb.396.2022.08.16.04.22.39; Tue, 16 Aug 2022 04:23:06 -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=llpqdswo; 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 S232848AbiHPKNs (ORCPT + 99 others); Tue, 16 Aug 2022 06:13:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232536AbiHPKNO (ORCPT ); Tue, 16 Aug 2022 06:13:14 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B3E695AE2 for ; Tue, 16 Aug 2022 02:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660642667; x=1692178667; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KrqKUXm8zxAx+xUgfzAnf90BYMAv5LCjSDW1jp1aEC0=; b=llpqdswoa72rVBSJ3Rx7iBeeRYOENriFNniRvngpF/mkuJZTIT9XzO4/ qtOZb4SpXcXVlINFiTYGrFTB9BUeGi8a+sw8mQXmXdkbLzSsBSf0AMX6C Bq69R2i5Gas2MotgE3JJdAgN8b9NykmXxYmNe2NcVkfIMM3QFNAcrOnb5 yfjKL7/gfwrIQjv5MMwumoepKwZrvA3u0SCuXdqvs+d0R6FaMZdUCVEth dTesajAavFLtTYFLxUH5+rfV/g5oBMfNGg0NlIcak688s2r/2wHEG9xEx 28U37sPxMidR7D/WWp7LPgN52lanqwSvRUa487+ROoXDHtk14mAbNR+bW A==; X-IronPort-AV: E=McAfee;i="6400,9594,10440"; a="293446834" X-IronPort-AV: E=Sophos;i="5.93,240,1654585200"; d="scan'208";a="293446834" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2022 02:36:00 -0700 X-IronPort-AV: E=Sophos;i="5.93,240,1654585200"; d="scan'208";a="733231060" Received: from clbarnes-mobl.amr.corp.intel.com (HELO paris.amr.corp.intel.com) ([10.254.7.166]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2022 02:35:58 -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 v7 6/8] drm/i915: Check if the size is too big while creating shmem file Date: Tue, 16 Aug 2022 18:35:23 +0900 Message-Id: <20220816093525.184940-7-gwan-gyeong.mun@intel.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220816093525.184940-1-gwan-gyeong.mun@intel.com> References: <20220816093525.184940-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=-4.4 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_NONE,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.37.1