Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3149258rwd; Mon, 22 May 2023 09:16:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Fzk7JzwYCKLDws0pIirgqy/SZ0WnFrgTawxR0NQUwGlDFfDAZyzNrWLhixqaZ8IpzK0ao X-Received: by 2002:a05:6a20:6f0a:b0:d5:73ad:87c2 with SMTP id gt10-20020a056a206f0a00b000d573ad87c2mr9388162pzb.56.1684772191551; Mon, 22 May 2023 09:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684772191; cv=none; d=google.com; s=arc-20160816; b=Jn+G4dfZNZhzhZos1rgrUjOQy7NDGJWPqz6lqcbPUIABePZmmNHDlZpXlCI7QHyWab OQViN91aKsfZzXexuOSkDPzMO32BE71BeFl19fkGevGe+h50N4OjNthuavbOuJVbExvs cqLc9obdjLZkFFoVvZMP0To+gJ1JJK2rkE7hCr7Cw+I2hORp8Kl9YzYntiu7qaKriASc bEU7Vf7pIIRAGxMI6ILfRMLOye2kKL8JOSb3oBwKlWRuQQnV0mLr7lKx+DAnfqMsS2tQ xeAI3JfmzVx0u1VYay4h1WFSWZ3kLtQhPSrGD1jUJpwkn1sNM7AokLCqpGbl+lydC4h1 BsJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=kbVu+js/u49UVSKkc3Whb+MdTHWX0VoM6dHArdtJbQI=; b=aAcul3F/Mhaj+zjRDLYUwtEYRs+aqGT5BHy5SSBvKAygEIvjRhDb90l//Eq+X+fsQW 2VWycEajKJ3N39P0xvZqvqsJGp4sa+g1IpDQG7slO2ohG33Cy6KweqpvIx6TbNrTti9B Wvripn6GngfPKPKmiuoX/XpEY+jpSdcqt+j9JTHnrRUuVDWkaOb3MlTU/z2T0oQtX73Z ruM2K1Rdoy5ucww90xx8Y4lbhzPoHC0NsL/NoJzwOGCm617O7J/6R/oq34x1JLjONuKX /Ele0h3DbFyRu/ztQKbZTf95VVRFg+uyBFTa11HrbE0/XZpAUvSGcoqbCZYtRxXQFf1z +IAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=wKGo5FF9; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 19-20020a631553000000b0053071bc497dsi5013078pgv.90.2023.05.22.09.16.16; Mon, 22 May 2023 09:16:31 -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=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=wKGo5FF9; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233410AbjEVQEQ (ORCPT + 99 others); Mon, 22 May 2023 12:04:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230237AbjEVQEO (ORCPT ); Mon, 22 May 2023 12:04:14 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6730C1; Mon, 22 May 2023 09:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kbVu+js/u49UVSKkc3Whb+MdTHWX0VoM6dHArdtJbQI=; b=wKGo5FF9Sv1SMb8FRQ1zB/vGMN 8IR3y7Ttvy3shfgEg6LMq4kvEIUNezlX4y/XPKd41Pdq//gTGjkqqHgcoq3v2bi2mtub7WBW3qaBE pO53wVAbKaO16or8TfpbZVg0kHeHy4EjqRJF/0zXhn+g+bz80wtz4GCR+yanVkXPrgeewHmnuKeWj Hgq5f30ZWlA6R9AIcOek8Lv9vzxKVRQFjgMaDMh1d6+WbPh2BKAWqESX4sIWarrKI4flVCqC3tqEF NaLbECBcIs62U3ziVE7CCFysdwyPO4B9H32JcsbDpxXfJeIrV8NadCYpXMNK39KcK0ewVPeFSm8tx P3UQQHdQ==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:43546) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q1815-00077K-8R; Mon, 22 May 2023 17:04:11 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q1813-00084G-L4; Mon, 22 May 2023 17:04:09 +0100 Date: Mon, 22 May 2023 17:04:09 +0100 From: "Russell King (Oracle)" To: Azeem Shaikh Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org Subject: Re: [PATCH] drm/i2c: tda998x: Replace all non-returning strlcpy with strscpy Message-ID: References: <20230522155350.2337029-1-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230522155350.2337029-1-azeemshaikh38@gmail.com> Sender: Russell King (Oracle) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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:53:50PM +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. ... > memset(&cec_info, 0, sizeof(cec_info)); > - strlcpy(cec_info.type, "tda9950", sizeof(cec_info.type)); > + strscpy(cec_info.type, "tda9950", sizeof(cec_info.type)); Please explain how: 1) a C string can not be NUL terminated. 2) this source string could be longer than I2C_NAME_SIZE (20 bytes) which is unlikely to ever shrink. I'm not saying I disagree with the patch, but the boilerplate commit message isn't correct for this change, and is actually misleading for what the patch actually is. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!