From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1CA5AC54FB3 for ; Mon, 2 Jun 2025 13:10:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9CB8E10E520; Mon, 2 Jun 2025 13:10:27 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="SC5Gahko"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id A9C0410E520 for ; Mon, 2 Jun 2025 13:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748869827; x=1780405827; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=JTf+/sW1h9AZeu+i9OMWXb/oYWCvRJVBIij7i3b+iRk=; b=SC5GahkogeWTyE0exmgK9fPyCiepqYnlONQIV79C6CS6gH9apLZBDRwB n7dFYoYtEhS0DeAku1sG2yB8yIi01QodXawrQEGMiTh/l27OgYFwE3we2 KZ/kks6aUD8OGZoOhAGWy+b+X33/SQY1/v6rwck9q3eJIoLRNcNgOakn9 85RJD8/AIPwfY6kCyYaO176sKsjUPz6RhjcO1C9SsGXMmxmcWayqSl66B 1j07Jjs5Nve/55Ii76VuLfHVyEFYANUlpiRcil6TT2WsI9XdI9a9BGAhf /9Tdg08YNXDXON6DVPPEoN4UptIRUWEt13LQVH7e2DOlY3JoACLMPEGrY A==; X-CSE-ConnectionGUID: +CFKLKxwTaerxkNCRExXSw== X-CSE-MsgGUID: IOqKZYahQM2wm3MJ/34tVQ== X-IronPort-AV: E=McAfee;i="6700,10204,11451"; a="61926878" X-IronPort-AV: E=Sophos;i="6.16,203,1744095600"; d="scan'208";a="61926878" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2025 06:10:27 -0700 X-CSE-ConnectionGUID: 6pSu9W09TIymrqWLNrNwlw== X-CSE-MsgGUID: fPmvRllDRmeDuC+dNpLUdA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,203,1744095600"; d="scan'208";a="145478266" Received: from oandoniu-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.245.193]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2025 06:10:25 -0700 From: Jani Nikula To: Kees Cook Cc: "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org, intel-gfx@lists.freedesktop.org Subject: Re: i915 utils: range_overflows*() In-Reply-To: <202505301026.126AB6FFC@keescook> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <202505301026.126AB6FFC@keescook> Date: Mon, 02 Jun 2025 16:10:21 +0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Fri, 30 May 2025, Kees Cook wrote: > On Fri, May 30, 2025 at 10:44:31AM +0300, Jani Nikula wrote: >> >> Hi Kees - >> >> drivers/gpu/drm/i915/i915_utils.h has a handful of helper macros for >> checking range overflows: range_overflows(), range_overflows_t(), >> range_overflows_end(), and range_overflows_end_t(). >> >> Looks like the first one has also been copy-pasted to >> include/drm/drm_buddy.h. >> >> Feels like include/linux/overflow.h would be the right place for (some >> version of) them. >> >> Thoughts? > > Sure, yes! They need some documentation too. :) And probably some > renaming. It looks like range_overflows() is not end-inclusive, but > range_overflows_end() is? And the _t variants are forcing explicit > types (like max_t, but unlike struct_size_t). Ah, naming. As we all know, NP in NP-complete actually stands for "naming problem". It's hard to come up with a good name, but presented with one, it's quick to verify it is indeed good. Ideas for the hard part? BR, Jani. -- Jani Nikula, Intel