Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1447297lqm; Thu, 2 May 2024 15:34:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/kfmguU2tyFTQquecZVrXP9MAopXcJo5SoijwbBwCvJDAP0Eu5gXnav/p6+nrQ7savleoHTvP80zAExIAHpYZdTKgdJDqeOJmh0zL3g== X-Google-Smtp-Source: AGHT+IHCmmpkmwDhJzqSxD4Co8OBeeAOD/kepMLjNgsXzoLF8iykcdzLvWvglc1lzMZQs398HXVx X-Received: by 2002:a25:81c7:0:b0:dbd:1dfd:8b8 with SMTP id n7-20020a2581c7000000b00dbd1dfd08b8mr1256719ybm.24.1714689257437; Thu, 02 May 2024 15:34:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714689257; cv=pass; d=google.com; s=arc-20160816; b=uayW1/XCG91gBnp6J+I//Wj8DfzlTID++SYmm7dwLjJEv33BAzWvXyJKGcZyQlUzcQ WKif5ZkAUIboaenjNcWKudf7piNYU2Z8OS5V3yVSKnqhXsHNvCHBwAlKEcU0/5uhs1qk S9ocuKC3T+igQxX9Q17dbyFPE8JCpclsXSlj2YfksePkLyS9S2Jj+YlCuZolMoClQHne xZo+sKXt+6EgetGmMRH3tQ3cRw0BRqofESmKg+Il3PaHyiRjlTt/nsbldIgz0t1YFs6I 08Ebzv1g3udL6Eng2U2hUXSxJ7Qfv3q05181i8e39S4zlSgOzsxlREN0IKTU1dhYOkZA 3Oyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=syonTmYD8c0TYLT7ugjKF/sEjFnMsTQVi6C/fR41bxY=; fh=koODXbzdJ0DdyXnahALB69THVHG4bahKTyRMP4bhx7c=; b=lsZ8RcuFFRYDT5rjihC5Tro73EsfwOGVorY6kCwV7XAy9tmbY1A5FHFtY/XjyQB4oU 4TXvoFYz6ErJCwsAjTVu7A48UZG9i10PwGsEILUWtF1TbTit+8weh8ReVssfREfSng49 I18Zgd8EIoki4xvjBQrtISvcpPnuxuPtbQlwTJ/5Enwmw6RmdivXDbv13qPMgr2RKaPL Xb6IS4nf7KN22smtipnqAAOy9/2diFmdJT/IK0Sc6OqEQn2e7eo30W5yrUDwgiquIZzf kBAXRYvTiVcCAcNrFBp9GSKMak2UQpoEfBMh8ZtE+nd/poQfG0G365AaIsTi1hFw+N7F SDYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IdyzE2iU; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-167003-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167003-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u12-20020ac858cc000000b0043ad3e63ee3si2070459qta.148.2024.05.02.15.34.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 15:34:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167003-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IdyzE2iU; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-167003-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167003-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 207181C20BAA for ; Thu, 2 May 2024 22:34:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73A1420322; Thu, 2 May 2024 22:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="IdyzE2iU" Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E8611B978 for ; Thu, 2 May 2024 22:33:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714689227; cv=none; b=BVs8btWJ+afaiTUu7Pa87JN0n5WlMuTcyCdC6dLoSAJ5Q5fGJEuZs6JPY/SSPtZViNT2KCt7zwNIHaeUkue9rj+peadsvlPjp2xdSrpiVWPpVEpvGRPyAaH8u5VU5dgcVgnTVZZSsB1jZFEUZZlTmvqpYXWOZdz0kBUCPyoUCj4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714689227; c=relaxed/simple; bh=P8oJtedy3HXH20Pj7T8DcdEaOEqGIej1pz81IGBrmfY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aHyAkCrLoN2VNgx9gK0AazbNqCxUiQcA0ZPWYZqwD9bUDRhnMoXH3eLaqame9XHnKh8NePBNQZem9VrKZ6mLbtGcR3R1iT4YUns0CbVmng1Do3XAviKA4yO8RH+HuDmkhXXrEywweTROmQ1i28tQBJ0p+CokwKt4i5p3OeyG1rc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=IdyzE2iU; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1e5c7d087e1so74038455ad.0 for ; Thu, 02 May 2024 15:33:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714689225; x=1715294025; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=syonTmYD8c0TYLT7ugjKF/sEjFnMsTQVi6C/fR41bxY=; b=IdyzE2iUNgNuVl5SDzOXszjPPyfM6BIpLvpDd3fgRvRReHLSybEKA2fgrw8R+XaaDN hAJiQi9hb+pk9VnFvinXfag9eyKjHc+c2UujHIhzKvvNEaJknwDbbwjhuMShWgb7ibY6 KrG5/VwKfWO/qywEhttHeDLC3DTLIH3JWxiss= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714689225; x=1715294025; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=syonTmYD8c0TYLT7ugjKF/sEjFnMsTQVi6C/fR41bxY=; b=bIM+KACgzxpOC4CkTMfu7hodxxd/UbXR8sD0sHiU2FALAQRN7+nqIs6bEQu1LBX2Lr AIYkrzSy5psfJ5hRS8jLXJ/NuPmhGZsowSIiNM6yt9X9LJGx4Nd/Nr2JRZY98KCpFUmU ieayJWmUI6wKsXqBDtgK0DSa2vSrWm6B5aXoGtGT02ihNVv+D52CuQk9bB4ZXksvz50Z Ucx/O3yYkYzZ3RIKzTmh5Stl+yNlFU2gmRuvqkUbd6RHO7AYgP7I9RE67GxZGmYshGKg mdHnCqfaPCMAHjcAnN0qZwdYt8duz8n+ua3/OM8jXL2yLk/IKdDPq7uYVmI1vjcYgNIh iGLg== X-Forwarded-Encrypted: i=1; AJvYcCVruC8i5w5v10+lFo20k/e+KE3F1FZtAyMY2eWt/ncHsAu8NrudjeNWyeXtL5VKgGa4TAqDqyfpATPtqsLjYwpAcXE9sbsRlrg+2pAl X-Gm-Message-State: AOJu0YyZDeKTev5qGRRyIgrX4ekegCyoGcJUtJtMKGPxgn8IL520Grcj y2+j2YZ7HENv6TXJRWoFekRg9CD7y2XOuplqsZFr7sHOsOGEopZhUOTOzKlwjw== X-Received: by 2002:a17:902:bb8d:b0:1e6:68d0:d6c1 with SMTP id m13-20020a170902bb8d00b001e668d0d6c1mr934693pls.40.1714689225425; Thu, 02 May 2024 15:33:45 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id y2-20020a17090264c200b001eb2eac7012sm1885713pli.138.2024.05.02.15.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 15:33:42 -0700 (PDT) From: Kees Cook To: Christian Brauner Cc: Kees Cook , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Andi Shyti , Lucas De Marchi , Matt Atwood , Matthew Auld , Nirmoy Das , Jonathan Cavitt , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Al Viro , Jan Kara , Zack Rusin , Broadcom internal kernel review list , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Will Deacon , Peter Zijlstra , Boqun Feng , Mark Rutland , Kent Overstreet , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Andrew Morton , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH 3/5] drm/i915: Do not directly manipulate file->f_count Date: Thu, 2 May 2024 15:33:38 -0700 Message-Id: <20240502223341.1835070-3-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240502222252.work.690-kees@kernel.org> References: <20240502222252.work.690-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1418; i=keescook@chromium.org; h=from:subject; bh=P8oJtedy3HXH20Pj7T8DcdEaOEqGIej1pz81IGBrmfY=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBmNBTDTJYtS4zv8xaeAG0nbcBc+V98YhNpyJSpC aI+gh9aiHmJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZjQUwwAKCRCJcvTf3G3A Jj8cD/oDPHTNltydyOxjPKQZBsKvSQLMCwHO4DniBHjFHb53bO32xnSinmbDfMMW6W+37gvrw8+ HE6zUQkGh6uuZsI+sQEoqKgttjLhXt9oHFUm4OxoD0XufetWCTKTscDgXMU1JnsNj8DboYt4rpJ YmSi0hs6QUUf5hOHAUXAKfGs5W7DLp6tpj4rGdmFqMXpkgD3QrChXAj6i8RDdUrhyk9B2pBuY+4 sLgAOFTS0sj9z31xdOO8K3DRa/huLmrWWbAxb8bM8wIR0JFY0lbyIDpDRceiptDZaIJ6SDuE+tn 8hO23F2XRQBqC2khO22JbW5VDa0wCLX1gHTzNFPXb1tP/0vGKwSn9hsEgK1Cs4O8uH/j+XXx3Fu ERZsO42/LUneZufeL5Yn/IXSKnnFBz50uY0DLgUUDbyVaGRt5r41lZ6VS+ICzQdfv0Np/iFVmVj 4QbPjG3GeAvApJNmze6/hNVFC53hBO3XzEb5rZp6CQ0esedaZROBpIP6JhlqTAT/UsP6lYFZCjN mf5dE8DHcNPFgiFNkrVlemIs+i2cWQzPwKMzqlMsJhnW3wYbbkhwnRCZcWpBFOiCxbnTuQiPXd0 MQTHMYZNA3iJPXlf8SU5ArabrMEfY+TNTBgUTOjKDUiIcn8B6Ykj8rc7hA4qkFA9Q3afzMjfC7m Uvjb+C8zzpXuOpg== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit The correct helper for taking an f_count reference is get_file(). Use it and check results. Signed-off-by: Kees Cook --- Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi Cc: Tvrtko Ursulin Cc: David Airlie Cc: Daniel Vetter Cc: Andi Shyti Cc: Lucas De Marchi Cc: Matt Atwood Cc: Matthew Auld Cc: Nirmoy Das Cc: Jonathan Cavitt Cc: intel-gfx@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/i915/gt/shmem_utils.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c index bccc3a1200bc..dc25e6dc884b 100644 --- a/drivers/gpu/drm/i915/gt/shmem_utils.c +++ b/drivers/gpu/drm/i915/gt/shmem_utils.c @@ -38,8 +38,9 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj) void *ptr; if (i915_gem_object_is_shmem(obj)) { - file = obj->base.filp; - atomic_long_inc(&file->f_count); + file = get_file(obj->base.filp); + if (!file) + return ERR_PTR(-ESRCH); return file; } -- 2.34.1