Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp195864rwb; Mon, 26 Sep 2022 11:02:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5NRiNYPyEv0budZRxq7dz+T0BBgwqO4GL35dH7n810XaiPgB9vlZS3EaUbubbnm4aXltik X-Received: by 2002:a17:90a:6ac5:b0:200:3216:d5fd with SMTP id b5-20020a17090a6ac500b002003216d5fdmr26711280pjm.191.1664215341235; Mon, 26 Sep 2022 11:02:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664215341; cv=none; d=google.com; s=arc-20160816; b=k15MzlfHBWzXejQSHWX0DAFDeaqDbp/JHxXrZvI9sr8YYbUqeJ3gN8l/UBYW/huENZ 7UEK3yD8rSd5pIOJ64MDny2yDt04IRU8D7OX/vMfHCiXNkXX7+v0b1lv5TMAaboI6gW+ 2kMlpIJitR/FGFZNFAInMfiDT4zR9CIZ7aw1Ex3mm/QZR5RDn5+4ujK1BoZHRrpNEnNu yxarEkAR5lKbIxjcoVSfcPBMBXvbNQrSHWGWMHkv3G1TDNFiuVroQB5IMD0l/yD3P+v+ gF1G+UQW7KRG6r3vtfxbtlzyvMzaUWG92lFPjjBPnjw9LFlZGV0/TqubGtF+pIxh1BI+ BabQ== 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=dU8J0soo8lnmV98PB4HVlecBAo5aeTEILEF2rt+wZlb7w8vNn95lreA5Z7k0FZvpRo YkxQpCA9dJT7j02y59ee8hhcZ+ZQfOvf/worb3yncOwC3g+P4bSeP4LDb3AYGg+mWXGC lE1a7Ur+/67IoNdgcHTUFKCrkazykM9PQQsPJIEwEc+8H68sl2A/6FuVSOpdgVy2oGkY ljfJsIyIideXTjUJ2WnSxHaA0yKoHWQlRacwnFVrnoK6QExPShL1kQKHLdKYVAtnQ80t agfxvtKmqWe1h8L41vR+4Av56uODc7aRu+hEoe6hftiY0C+ejUCDRNw92pXC/EBxJwyJ NNEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UlxoSb2R; 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 w1-20020a17090ac98100b0020254dfb1ccsi11199314pjt.114.2022.09.26.11.02.03; Mon, 26 Sep 2022 11:02:21 -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=UlxoSb2R; 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 S229781AbiIZQtG (ORCPT + 99 others); Mon, 26 Sep 2022 12:49:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbiIZQrz (ORCPT ); Mon, 26 Sep 2022 12:47:55 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F48581693; Mon, 26 Sep 2022 08:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664206875; x=1695742875; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fusilmdSQD+FIBKYeUukiHJrxKRQ3B5pPSTTQeO8rTk=; b=UlxoSb2RNmdWKQjXTNT4rKXYAukKaYSAh/ACoKulFSNZ5Fd9OtpXQXkA sjvYZahTUQCSgT9nAu4uXhnRvghazP9w7aqZ6JBlryiNSzJdA5bWrq0Qt Tqgxfq9pBgL5sWB+2gS/GFDvgwirYdvA8nTPmihpf2HjS/5B/Ei9woxm+ Lus2F68dzdx+xflGW4XUDyqjLgo0i9KMN8IWHibWLGK6eIvr5CNcEh3l4 VnG7Z8GXtAymTwBMV504hhj2Ibynia4Sap7C5SIVH24svIsi03OqLaibo VWVyFVILtB/LlxOub4d5GFcJRMjL8QggL2J0lDAEPXYQwa4AOg7kOBXK3 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="298661664" X-IronPort-AV: E=Sophos;i="5.93,346,1654585200"; d="scan'208";a="298661664" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2022 08:41:14 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="763481046" X-IronPort-AV: E=Sophos;i="5.93,346,1654585200"; d="scan'208";a="763481046" Received: from bsochack-mobl2.ger.corp.intel.com (HELO paris.ger.corp.intel.com) ([10.249.128.215]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2022 08:41:06 -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@redhat.com, daniel@ffwll.ch, andi.shyti@linux.intel.com, andrzej.hajda@intel.com, keescook@chromium.org, mauro.chehab@linux.intel.com, linux@rasmusvillemoes.dk, vitor@massaru.org, dlatypov@google.com, ndesaulniers@google.com, trix@redhat.com, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-sparse@vger.kernel.org, nathan@kernel.org, gustavoars@kernel.org, luc.vanoostenryck@gmail.com Subject: [PATCH v12 7/9] drm/i915: Check if the size is too big while creating shmem file Date: Mon, 26 Sep 2022 18:39:51 +0300 Message-Id: <20220926153953.3836470-8-gwan-gyeong.mun@intel.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220926153953.3836470-1-gwan-gyeong.mun@intel.com> References: <20220926153953.3836470-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.2 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 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