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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 594D3C77B7A for ; Wed, 24 May 2023 13:41:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235349AbjEXNlG (ORCPT ); Wed, 24 May 2023 09:41:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235338AbjEXNlD (ORCPT ); Wed, 24 May 2023 09:41:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DCCF19D; Wed, 24 May 2023 06:40:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C984A63554; Wed, 24 May 2023 13:40:34 +0000 (UTC) Received: from rdvivi-mobl4 (unknown [192.55.54.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPSA id 65486C433D2; Wed, 24 May 2023 13:40:31 +0000 (UTC) Date: Wed, 24 May 2023 09:40:28 -0400 From: Rodrigo Vivi To: Kees Cook Cc: Azeem Shaikh , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , linux-hardening@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, David Airlie , Daniel Vetter , John Harrison , Matthew Brost , Ashutosh Dixit , Lionel Landwerlin , Umesh Nerlige Ramappa , dri-devel@lists.freedesktop.org Subject: Re: [PATCH] drm/i915: Replace all non-returning strlcpy with strscpy Message-ID: References: <20230522155228.2336755-1-azeemshaikh38@gmail.com> <202305221316.2817AA4FC@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202305221316.2817AA4FC@keescook> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 22, 2023 at 01:16:03PM -0700, Kees Cook wrote: > On Mon, May 22, 2023 at 03:52:28PM +0000, Azeem Shaikh wrote: > > strlcpy() reads the entire source buffer first. > > This read may exceed the destination size limit. > > This is both inefficient and can lead to linear read > > overflows if a source string is not NUL-terminated [1]. > > In an effort to remove strlcpy() completely [2], replace > > strlcpy() here with strscpy(). > > No return values were used, so direct replacement is safe. > > > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy > > [2] https://github.com/KSPP/linux/issues/89 > > > > Signed-off-by: Azeem Shaikh > > Reviewed-by: Kees Cook pushed to drm-intel-next. Thanks for the patch and review. > > -- > Kees Cook