Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3591774rwa; Tue, 23 Aug 2022 07:09:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR4xiXgvHkJvrNxjCWMWKq1aZ4SRDhy2tTiiw3yU7kSFI7pHirsqoTob3kFTDJ4vPA54PBe+ X-Received: by 2002:aa7:cf03:0:b0:447:5d35:6a8c with SMTP id a3-20020aa7cf03000000b004475d356a8cmr102271edy.265.1661263760085; Tue, 23 Aug 2022 07:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661263760; cv=none; d=google.com; s=arc-20160816; b=m4NX/Wbc/S9jrhszeFAR1rQSXo9B63IAOCoiAXtnZ/4q1ePzjW1RB7NjOQOI2c60HJ anw4mjaRXYO52ogHiGns9cCWQNQMJ/xmojO/5DoL5jikytqus88+rR2KzYW82LnQhfdK 9s7/rVgcQ6AAY3lecHeTQbRKxC8tXgBgWRfp3Ilo7DWw6fjsoddGif/HaEDdSHsLKK3a SOoAipe3upGxgARpjJY1IoE7zv7cxWRcli7OtxYV+Es3lrXlqlqzNuPjDtglqe3uGer6 oPDSJGc1PWlvr0rNbLxStTIQoQh5QJAYSj+mq63NpFYYqKBIgETs+ntCpnCiBYYcg6AM 6kMA== 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=POmAXduJ6SI7RVAAlYyvfPFre0sPrROg8vVQxGKuQEo=; b=c61+maHvE5q+mJCiXEiEKD8H9N8bMrElRlxjW6Jb+J+WzOih9H4TkICHgUm69T2ENl hQFoVCdV9tdn4/EMxA+m/3AvTgA2ezWT67womG8wuIApdqf5bPqT4Gmi8k0P/XPWP4q+ +ooStkH1tvdy2/Aix9zH/sjf76a7HWu5hXvxObcqq7hDcQPjFxIQgw7XXwKa2vJm99L3 rOF/b+RVqgM5NIux63+UxGsH5My9vr/73ciYemoSe9b0gJWJFGm6Z2/7lDqooecB1ltm U7mEAHNPY17SwQE6ptGrExR4YYCmnsVhvsN9ZL5DM8gs3g+NbohMm5xFlev9rnxa7RxY XVOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XphxZ09y; 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 ga23-20020a1709070c1700b0072ed60fb78asi3712741ejc.548.2022.08.23.07.08.54; Tue, 23 Aug 2022 07:09:20 -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=XphxZ09y; 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 S241752AbiHWNUz (ORCPT + 99 others); Tue, 23 Aug 2022 09:20:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241767AbiHWNUT (ORCPT ); Tue, 23 Aug 2022 09:20:19 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBA32140C97 for ; Tue, 23 Aug 2022 03:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661249948; x=1692785948; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fusilmdSQD+FIBKYeUukiHJrxKRQ3B5pPSTTQeO8rTk=; b=XphxZ09yA08rZUFMPA1jd9zWhL9eRh/sEeaJuMUk7kCC2G1f+Ug9vKBJ AePNu/cn2lF+tU6SlBgE1uFCkg7IAp+DFZrl9dS/Za2r4Ifgti8p/z3j+ lQGh3jNCa9yKbNEyIj/RyyX9r48zCt0eoUWjgJpVWGUoDm21ywoveOp4Q SzbXNItgON+Qapcghut4AAuduVlheKOGSGlyYKtWFPEJ3NqD7JYeX219z f9iEALvHMyRtbj6L7frQt71J2mw3ROU2xCryIUB+2lBVRuiGaE6DHjPtM Q//CdYCD81LIsjf3MJKIOdzyn23PgGiVTB3VnyzTj02L49Z5THfFfgwnz Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10447"; a="291206644" X-IronPort-AV: E=Sophos;i="5.93,257,1654585200"; d="scan'208";a="291206644" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2022 03:18:18 -0700 X-IronPort-AV: E=Sophos;i="5.93,257,1654585200"; d="scan'208";a="751639982" Received: from jabish-mobl2.amr.corp.intel.com (HELO paris.amr.corp.intel.com) ([10.254.9.209]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2022 03:18:13 -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, keescook@chromium.org, mauro.chehab@linux.intel.com, intel-gfx-trybot@lists.freedesktop.org Subject: [PATCH v8 6/8] drm/i915: Check if the size is too big while creating shmem file Date: Tue, 23 Aug 2022 19:17:27 +0900 Message-Id: <20220823101729.2098841-7-gwan-gyeong.mun@intel.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220823101729.2098841-1-gwan-gyeong.mun@intel.com> References: <20220823101729.2098841-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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 339b0a9cf2d0..ca30060e34ab 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