Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3417579rwd; Mon, 22 May 2023 13:29:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Fqu7PwBjwhf0gEYgpxeisfQTeu2e6GAq0fgZE1FLRgy3s9EREv/ABUEoVPmothg5run+p X-Received: by 2002:a05:6a00:15c7:b0:63b:8f08:9af3 with SMTP id o7-20020a056a0015c700b0063b8f089af3mr18350262pfu.7.1684787378307; Mon, 22 May 2023 13:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684787378; cv=none; d=google.com; s=arc-20160816; b=hUCcft0I/sl6LF2Ya5gXJDqHvrfEtaRPdp8sXy4hKP0B3RQVB5xSjtlgl9R2ds4IaC G5jC4lxoxZgh+6VtKMY/fwJSQATm7iZ3VAylTF5w3lleGBhGPFUfmPXN7WBJ9gCyh/Ni k2CRm6ilgGgOyh8d0qsz+TwFG3bwN8+CTJSruFwnrajyjfjlxJLt0cLJBg0SMjBkOr6z 4GcEpp8vZ7YXPJrlpHPijL4RV6Ib3fG0hblI6L51nymBGoD/AQwDo0FXIEgaLp5tE8AL eZz3MZ5L1r//3L/R8EF55HV1a+7nR82dlf09e0fdCmssaLKYIhJTUkbvnKfXGaDzs2TG sscg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=lqoDgNZ9G+pnENJHcgKxrrSDm2QXQ2DN2DVXwRpe84M=; b=syb9cvW0nXsP7X/j0hQ78GAC4vxDHbLqMVsllRVkxRsL5oOgb+d9ndX3sbDirCGZxg oTrfsE1jfCy5xCt51daRfXx/s5vyEwPuvx/9rfEe6LJCW49iGzPh8PY03lZUe78OsF0+ AIDHiyjfIbbicgwaf2TjAGPjwDDYcm/D0uKzh9I475gAVHwvV+78jK00rXZu8w4apc3s oXXLtgdZBrhPzWnPmbSiqVAU2jlvFPsE1Qw4fGF5g/VBcn2h6FNWxI4W2jWZGVk5jEsw 55dAJXd1rFUDBsTftnhFcedaHzKKY6tzVx9EzAe0uivfN2SZ8ahK/AWONI7U2QQqHCNW xkKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=THb6a7A4; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q189-20020a632ac6000000b00534748f9cd8si3508387pgq.644.2023.05.22.13.29.23; Mon, 22 May 2023 13:29:38 -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=@chromium.org header.s=google header.b=THb6a7A4; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233207AbjEVUQO (ORCPT + 99 others); Mon, 22 May 2023 16:16:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233203AbjEVUQL (ORCPT ); Mon, 22 May 2023 16:16:11 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B95BC4 for ; Mon, 22 May 2023 13:16:04 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-25372604818so3058184a91.2 for ; Mon, 22 May 2023 13:16:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1684786564; x=1687378564; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=lqoDgNZ9G+pnENJHcgKxrrSDm2QXQ2DN2DVXwRpe84M=; b=THb6a7A4+ZDhhztCUfCFsPY/zH0txXyjC+97nEgRFTe1FP6hH7wG4Rx1Ek+S2QkeNF rROT12GKEBSriZA/G+nXPcCRbwKUoWabsNyX9y4bwg6gYnpx4jqfuiWo86AeIMljKk3j mtLnQUhAfjXjiVaWPWRf4oLQqhq9xk4iIH0sk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684786564; x=1687378564; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lqoDgNZ9G+pnENJHcgKxrrSDm2QXQ2DN2DVXwRpe84M=; b=biMnS1cn2BK+b1S9X8IkWSywJVheDQt2BnCEnTquuYV/gJBGTJIAUfIDrof9DXoUp+ bGcDaHiEdtJrLAxdCrvkqrQnDf6bFgOJeNU6NnMvjtu3tTbDwascLOWRYAug9hoRzUXL FvhXJW4YM5IXdhm9E+YXVGzoB2PlLvjV3jE1OP0VUSFhLFhXDcAIm1TMOTKN1qde296p T8yFRUpforQk+MmHAIS/qfSBng0KJD5M76ItaX+qJQo+08UhAJcHanYg6EE2RWJyagwZ ieoHypkfURMM00i3LQT5H/BJi2/Lvm0HDcHzc6Qz+16xEdGoXJCrWbYymsQOhVCKj2Tx bn+w== X-Gm-Message-State: AC+VfDwiwfot9O0oaAVpHxZ7lzUtJMlRk376L2FdYANiocjLtBzjdzmn rCueLYfrffNXMB67j052ENtbFw== X-Received: by 2002:a17:90b:1003:b0:255:5bde:e6cc with SMTP id gm3-20020a17090b100300b002555bdee6ccmr5042944pjb.17.1684786564102; Mon, 22 May 2023 13:16:04 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id ei13-20020a17090ae54d00b0024744818bc5sm6340408pjb.9.2023.05.22.13.16.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 13:16:03 -0700 (PDT) Date: Mon, 22 May 2023 13:16:03 -0700 From: Kees Cook To: Azeem Shaikh Cc: 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: <202305221316.2817AA4FC@keescook> References: <20230522155228.2336755-1-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230522155228.2336755-1-azeemshaikh38@gmail.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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 -- Kees Cook