Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3119315rwd; Mon, 22 May 2023 08:56:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5polOaRBtsa9EyUzamUHHRv2Ol5TROf2L6UD5+XD6zquzp0rETXeX3Ke/3oDu8zzvaF8Dm X-Received: by 2002:a05:6a20:8f0d:b0:101:2f83:5fba with SMTP id b13-20020a056a208f0d00b001012f835fbamr4200607pzk.31.1684770969192; Mon, 22 May 2023 08:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684770969; cv=none; d=google.com; s=arc-20160816; b=iJG/sFEJlEpZrS+Q5oQpBVnj6qzARL09UQTr3DnRCg/onBX8bsGOrnQR6rHQcHtVNy GCFv6QRPnGLc39Azq0/lsRIJ1IMTwyXpsR2IzweWx/KrLfFMdxcwoqBJl5mj3fZ9s6VX 3EfuqOBtc/2bE2sqHIR+AeZ2B1VbZbmcX3lWNWyNlaGUNp+0941KLEC96fIpjp9tHv45 y6lReHsGac1H36VPmT3QAuimRDmc77KzEtIEJkSC++vhMOSHyXA8q65GWbAXBYOpqRxT l285VspzqLv3Gdg99ooCVXIFsRaUgyI9rnuseUBB2LxNuiALxAf8IPRpwpCbtHuJNbp9 mWAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=FGZB0BLWCtOoXyFqMRziafXS39k9XZRqjcukX9G4FJY=; b=CQ7BSp+Zf9c7sHH5LZhauo5p4MCzDboundfF3kmEDgz3QffZ8DS7GnjRVUxzjBg5i6 GXhabCaSyWIHZG+gI4wI4cNRhnowIM9QFfQrP3jCFMH/QG5rLHqewq8DJWJbJQlB2TDn Wvt01lARBmGkb7UMHvDIyOVlK9sBshTnFClh282eYZmojOFXX5P5J8DAooy/CylyjWxJ fwCxlG1iWnX4xWnc9ygYYspAP9kKtSikMF3jTqhZob8RrEKaYOz2u0ARIHnUHa7E9jpD DJ1S6bQk6jMpaVkkSCbke9bVJ8XwrohCqx7h9iG+lpc6SATwBquKTYlIp6RdKaXf4Jet R50Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=FaHtcdzk; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a29-20020a63705d000000b0052c688e6608si4849414pgn.505.2023.05.22.08.55.56; Mon, 22 May 2023 08:56:09 -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=@gmail.com header.s=20221208 header.b=FaHtcdzk; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234381AbjEVPwg (ORCPT + 99 others); Mon, 22 May 2023 11:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234588AbjEVPwc (ORCPT ); Mon, 22 May 2023 11:52:32 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 269679E; Mon, 22 May 2023 08:52:32 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id e9e14a558f8ab-33823abc8a4so15375255ab.3; Mon, 22 May 2023 08:52:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684770751; x=1687362751; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FGZB0BLWCtOoXyFqMRziafXS39k9XZRqjcukX9G4FJY=; b=FaHtcdzkdup+GumaJ45Fo02SZy1fX3GJRn633/fLcAmnpNi5q6NOU3nSUZSdnnA03n 2CMLwJoMaosxKnGgH/agh0HqXPkdeIgCSrXBYuOUCFPzv07teBhZ3zTzDOn4+6fzO7uH bpkkPs2OGkn6ZEm6/nRQe0FDxmwzyEBDf9ve9CT8aYHPHApi9NxH0QxpfImEfkdGALwF ajUs/tM/rExv3923dLsNLbfbbx/SkAzcxDoqT9j+StG5sMK5OOZCMkGJyMISGX4h0Yvd 2m/nNqhPiUTt3Rv7Pk4ohNaBqOVlzwktKa8GH5tmC+3ApFxo/1aRNIU7oInSObuLoJi1 d4Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684770751; x=1687362751; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FGZB0BLWCtOoXyFqMRziafXS39k9XZRqjcukX9G4FJY=; b=OCTTvXnqqUQrc6ZMN0qsiqZbAd9eSNvUuLDWYUXOFFhr23ntu+CqiYjsj7CELYonrm BWTBl5JZuXwl/fTRicGo0Ru0+QYgnX2lOdjUKDjbCCeWCrolrn4bOvWT7NBKdlvLQLEe njJTeqNx/uQ1GBdPqcizp8yP8yLSBVIt4YIBuNbc3Q69Q78M0JUeaP0UVqG662rLM0eC 7miDtCy0TJzj7k+gpmy5TM3RcrODBJwkBRKPaFKv8e0mOChrmf5dB1P/8LskU20v+rbC ePx5hdJjFWeAgIC4JGzgyL9htA2MnoLQEJautR1MJ7Fnav4uPoJYJXWuga8icLSKnNcv 3BPw== X-Gm-Message-State: AC+VfDzrIgdpV9MESaVna5baa9DstsjE0c0z6oWPR8yn4+S+bg0bgHqV HXHskCuhZyKuIJYfI6vPxZg= X-Received: by 2002:a92:603:0:b0:32e:41ce:e521 with SMTP id x3-20020a920603000000b0032e41cee521mr7113138ilg.8.1684770751296; Mon, 22 May 2023 08:52:31 -0700 (PDT) Received: from azeems-kspp.c.googlers.com.com (54.70.188.35.bc.googleusercontent.com. [35.188.70.54]) by smtp.gmail.com with ESMTPSA id p23-20020a02b397000000b00411bc1340c0sm1799779jan.8.2023.05.22.08.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 08:52:30 -0700 (PDT) From: Azeem Shaikh To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin Cc: linux-hardening@vger.kernel.org, Azeem Shaikh , 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: [PATCH] drm/i915: Replace all non-returning strlcpy with strscpy Date: Mon, 22 May 2023 15:52:28 +0000 Message-ID: <20230522155228.2336755-1-azeemshaikh38@gmail.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,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 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 --- drivers/gpu/drm/i915/selftests/i915_perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/selftests/i915_perf.c b/drivers/gpu/drm/i915/selftests/i915_perf.c index 24dde5531423..d4608b220123 100644 --- a/drivers/gpu/drm/i915/selftests/i915_perf.c +++ b/drivers/gpu/drm/i915/selftests/i915_perf.c @@ -28,7 +28,7 @@ alloc_empty_config(struct i915_perf *perf) oa_config->perf = perf; kref_init(&oa_config->ref); - strlcpy(oa_config->uuid, TEST_OA_CONFIG_UUID, sizeof(oa_config->uuid)); + strscpy(oa_config->uuid, TEST_OA_CONFIG_UUID, sizeof(oa_config->uuid)); mutex_lock(&perf->metrics_lock);