Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3711395rwd; Mon, 22 May 2023 19:20:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Nrtdpq6g9pKTLvk3xzBEXwG/g8ZMffPNG8fxxJ+2n5L8iuRKkj+3UWviWRjhem2pk8LP1 X-Received: by 2002:a05:6a20:5482:b0:10b:71c:20c5 with SMTP id i2-20020a056a20548200b0010b071c20c5mr8901660pzk.51.1684808425292; Mon, 22 May 2023 19:20:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684808425; cv=none; d=google.com; s=arc-20160816; b=rM5xkow6TZgXf7FZhbYVFWCwI+t3SYG8sKYuqT7Q1YG9VpkuoBtK5JpRileIZi5r2O eV5v9QtLQRhH17M5THalhuf3kkkI5FSbMlPqqr71SdAwgn1/MxJcaXoHTaH7kB1iZ9HP uwgo5raBBKeKa86RoVFdaGvU8PZNvQ3wLyvDxUPEdlhw5qJnivZahZNDQVHNbu/1RBVR ZRi4IJk0Q96YiPJWt1298ryZZANFYll2fX1dIIN/1w8Tuo2PDCFyCdvO4Fw4AqxpMXUh wV0owU/5efbJi5GNTXPfn4icQ4Z0J5DMZhgkOBsggvtFPCGkhvr2dNGOqVPAvDK6thEi V7CQ== 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=VJfHoPjEdJerv/4mP+VuPfal6WpQQrTrUh+1isiZJiY=; b=ctkbIzhL0r4syatMR1wkJZcx8L9N7wnyEJX4mFp/j6qJ5ppyzdvMoYRQnDKUQ1ChIc IO08cZSdE66/YnasHv+fUTgujDX4PaUcnLG4y5Nazaf7OwLd1SN2Ipai8X/poWoKQDwM dDDaunTNgNIiA2eBYo7bg+xKqZGHAS+9CUb54Sxk3LorLflTzxcuBuWwvCuLzUw1Hrwd 8osvlVYyvw9tOPA743gt8R5mP5NakvJWH+IZH6LU0g8Ic3amYwpCzorNiaQiWOHv2AUv 5C+eIb2v4wAeSAGeQ6S1sJeYWu+wUVSDRhN7pAPh6xdgINtzVovl5yBLd3J4fJOnYRAy BC/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ebjFmD3E; 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 i71-20020a63874a000000b0053b8d203368si3293925pge.822.2023.05.22.19.20.12; Mon, 22 May 2023 19:20:25 -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=ebjFmD3E; 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 S232565AbjEWCMD (ORCPT + 99 others); Mon, 22 May 2023 22:12:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232139AbjEWCMB (ORCPT ); Mon, 22 May 2023 22:12:01 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8BBDE0; Mon, 22 May 2023 19:12:00 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-76c5749b10fso81691539f.2; Mon, 22 May 2023 19:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684807920; x=1687399920; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=VJfHoPjEdJerv/4mP+VuPfal6WpQQrTrUh+1isiZJiY=; b=ebjFmD3EYsiS45a/YwY1gxAJpmXDKpnFV6dz4beCOni1z8I4ePEbgGJDWv84H5g3Qi phMjOew7/29ZJLkPHZD+m0FlmbYHRhPoe1AZ5DpLuf307CdMClssLYGZLErYm0I5KSlC jnY5TFvKSq6npdmxeE/lDl9rK4cuRHqS5Ry6ovMX1YbiKSnTY4YUck/HsiUtB2oApDdi /ezho9onmjgkEHEVO88c8Xk4A5ypY5MdPvLmTLTjAc5lLypcDnWsq+8vNNJca9uxcsBA NaCvp7Vc3v+H4lInMS3bwUHA3XtH57I5VP8KC0BwnrmGgwBuRefnLtVrPB2Xpx4UNFSc Ph/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684807920; x=1687399920; 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=VJfHoPjEdJerv/4mP+VuPfal6WpQQrTrUh+1isiZJiY=; b=ecRID5KbEd5yrOfpR7EdtVQFkhqFcgNA1U+bPrfeqjLhWfvaXf5/zb6MxQ8kVTxY+H upRZpbPlM0mverZLm4Y6PsqqKULXYasA24I9e7bvCVZpnPSHf2K82VQyH24IaaCrsq7i oDcAvh5p6Jv3Qw4IO0No85URtcuRyHIkF98+Q3L1dlike6CaMfL/ayll47K6IEyMejA3 XUMgYSavOjnXvCwDgCZ0TZc+W7F90KXbQ7ZhoGdIGKnjrcM3t8wpaEMPnKwvRYBjl6Yz 9JOT7Gea/Td5dnbvhTS7ppxvODL+O7TQoPPbP4hNtGKOWZxFHnVkzIJCsa8Q/7HYPukB sQwQ== X-Gm-Message-State: AC+VfDw5P+PRhxaNMklh0AOwZs7umhhU0dFg0pHpfcMPZXTT7Cc4zJx4 bbdRkSCNJJbH0u0axrPCoPE= X-Received: by 2002:a6b:910:0:b0:76c:570f:ac84 with SMTP id t16-20020a6b0910000000b0076c570fac84mr7450163ioi.15.1684807920022; Mon, 22 May 2023 19:12:00 -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 b59-20020a0295c1000000b00418507eef02sm2080544jai.31.2023.05.22.19.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 19:11:59 -0700 (PDT) From: Azeem Shaikh To: Sakari Ailus Cc: linux-hardening@vger.kernel.org, Azeem Shaikh , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, Sakari Ailus , Pavel Machek , Lee Jones Subject: [PATCH] i2c: Replace all non-returning strlcpy with strscpy Date: Tue, 23 May 2023 02:11:50 +0000 Message-ID: <20230523021150.2406032-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/leds/flash/leds-as3645a.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/leds/flash/leds-as3645a.c b/drivers/leds/flash/leds-as3645a.c index bb2249771acb..7dc574b18f5f 100644 --- a/drivers/leds/flash/leds-as3645a.c +++ b/drivers/leds/flash/leds-as3645a.c @@ -651,8 +651,8 @@ static int as3645a_v4l2_setup(struct as3645a *flash) }, }; - strlcpy(cfg.dev_name, led->dev->kobj.name, sizeof(cfg.dev_name)); - strlcpy(cfgind.dev_name, flash->iled_cdev.dev->kobj.name, + strscpy(cfg.dev_name, led->dev->kobj.name, sizeof(cfg.dev_name)); + strscpy(cfgind.dev_name, flash->iled_cdev.dev->kobj.name, sizeof(cfgind.dev_name)); flash->vf = v4l2_flash_init(