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 C89CCC52D7F for ; Sat, 17 Aug 2024 10:38:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6DC1F10E07B; Sat, 17 Aug 2024 10:38:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="kkormY1/"; dkim-atps=neutral Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by gabe.freedesktop.org (Postfix) with ESMTPS id E0CC210E149; Thu, 15 Aug 2024 16:07:06 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 42C3DCE1C93; Thu, 15 Aug 2024 16:07:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFAF3C32786; Thu, 15 Aug 2024 16:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723738022; bh=qqxyCTA5TmWr5/A46fa7vWod1K1SOVf9QMKqUeF+GaQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kkormY1/pTUeSX2KTR4sj/oWRFGWUu885mMvanjRamSt68is7jAqCFNr0P6+FtEvk rGVsSCI8EM+mb+pZrSsp08gy/U8s+gUMEJgPjzrv5bRh0FgfWb+wCuwCRmD61HWxY9 m2fuuDxyL4ZJN6fmvWhwdqDEU8GVk4Mc6DnIGrA8PvGM0GNT+lfMhqIu2efO8hSWSD A7jfF0a7nNwAaGQ9EnxGFenW3Rmlg/DlHSVUCQ4vKW2M/Ua/9UdTgXfvH8jfzHEfwB itLzq+3Dkc4W8DQJMg/AQ/NnN3EuU8JBqrTPyGzG1DtCEhkCEXTsWW5VzhaD1oZuI3 iVRzsccxccwBg== Date: Thu, 15 Aug 2024 09:07:01 -0700 From: Kees Cook To: Jani Nikula Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Andy Shevchenko Subject: Re: [PATCH v2 1/2] string: add mem_is_zero() helper to check if memory area is all zeros Message-ID: <202408150906.28A920F62@keescook> References: <20240814100035.3100852-1-jani.nikula@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240814100035.3100852-1-jani.nikula@intel.com> X-Mailman-Approved-At: Sat, 17 Aug 2024 10:38:10 +0000 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 Wed, Aug 14, 2024 at 01:00:34PM +0300, Jani Nikula wrote: > Almost two thirds of the memchr_inv() usages check if the memory area is > all zeros, with no interest in where in the buffer the first non-zero > byte is located. Checking for !memchr_inv(s, 0, n) is also not very > intuitive or discoverable. Add an explicit mem_is_zero() helper for this > use case. > > Signed-off-by: Jani Nikula Reviewed-by: Kees Cook -- Kees Cook