Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3417649rwd; Mon, 22 May 2023 13:29:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5H06NPgzf/a0yMp4WCE7cnS+3B0kXeKSX6IvbRixCzswrploVaumwobj9H/hjJCLdCb/gf X-Received: by 2002:a05:6a20:1585:b0:104:50ce:297d with SMTP id h5-20020a056a20158500b0010450ce297dmr13427577pzj.40.1684787382801; Mon, 22 May 2023 13:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684787382; cv=none; d=google.com; s=arc-20160816; b=hIre14s8oT5JarNm11JXV6YxpbATA+LW8+Cdecm9mw+oyKHpuXq/ZzbCTZRzkJFjsg sH2eiBLI0mnbYfZhLwmIXOy77hcPVgcaZDtULfdJJ/f2f0EvEOz38dE8YAauucJ/n51d pJfZ7PazlwgYNljpNn/3ckoM2X+C+NgAUInePl9hQgnMVJ8QSC5qjIU5fWbM518vlkVS LqpEvKj4QYDIplHjTbGQYdCjrFWoh4vF1JtzkD253CBEK+WwkbZsJv/LfYVSnDLWrSjT RceSKHgbx561smkN6KYAyOdfxOHel/6DyK8VG8KLuoT9SJoP1pPBJQ3ySKr5nmIwIwsW gkUQ== 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=/Tk3bD9idbrl9PK1wi5VEyItHEpJJoo8tWtDD672a6E=; b=k1wnVYJjtHc1nuPRLSOGA7w3DWStNYRr0XN48zGgHKY2Jazv1G24mpJ1lx1BO0gV+y 9h/AyUhx9CvO+Wq3E1OCdqkD/USj30yWmqSuhmGOnNZw22NIT1LhIhzrE80hAFHYkh3M iKEUj50CneUoLrANRoII33+nP9fEB4rftXIDxD05jwCe+e4jPj9csPLziGwYjDAifa+s AuP92I8K/4agdj0XKRzhFw7hK2OSMe1pXaRJxbk0eV0ALjLPgWRfBzmanLNrQO1eJZ5R mJCiJ8tf53Qi8lROnFRe2ae4Nq/7itis0vEaB8LL0ftjF9EXm8NUd7m8gIoNYArrQvNz bbuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CLjZcbee; 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 i7-20020a639d07000000b0050f975790dcsi5493260pgd.464.2023.05.22.13.29.14; Mon, 22 May 2023 13:29:42 -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=CLjZcbee; 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 S235258AbjEVURT (ORCPT + 99 others); Mon, 22 May 2023 16:17:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234889AbjEVUQm (ORCPT ); Mon, 22 May 2023 16:16:42 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43491186 for ; Mon, 22 May 2023 13:16:26 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1ae6b4c5a53so34208865ad.2 for ; Mon, 22 May 2023 13:16:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1684786586; x=1687378586; 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=/Tk3bD9idbrl9PK1wi5VEyItHEpJJoo8tWtDD672a6E=; b=CLjZcbeeJRsWfyBj8z/QVwLw/ENfE5+A1dPkMRNzX87xKEByhVIPvwWqQm4vMwpfHx LkuslqD3tJGP5ZErdH8X4BGmRzZsFV6FOZtqvKaAwxu+bJS4PEowjRWKQf08zVeZOnNS nCUd+51z44rEqWO2oc6lzbzLBxNDbL4CuXt+U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684786586; x=1687378586; 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=/Tk3bD9idbrl9PK1wi5VEyItHEpJJoo8tWtDD672a6E=; b=DJp0w6UwsfcswKW7o4eFDg8exFlxnKA1e6EkDyFDm3PBDLQCkUDbNSSAKJ6FC2VYow xn8CiEQi7QNL//Oncd3BvxE07rjuQIqaZOP0WyZT9BX4dTokONkV/wp6PeO9wi4b0JwN bRH6AIYnmpUHH4eqY8IDNeYGb8ZzpEvAhtCqn0vr4oDDpmWNhuP5dNFQIwDvRbrHewJa YLen02bYOO5Ce8EVSD3FsgxrXB3dNOP40583X2RKWS5kp799EWYHbPtxXtXFOF+zJcen ASU5oHZ91jU2YNnojVlZK5Wk36Q+NMTQNml0ceO8zt9hyJebYZXYh9IzPiw8qniqZwoj 9gRA== X-Gm-Message-State: AC+VfDw800RZUdHgBUXeGo/2tY5B6Z0LyQ4RVPvGHI/3f1bBgsvzWQWe Ms32yjT2Yv5DbuZ7qBnMaA8wZA== X-Received: by 2002:a17:902:ec86:b0:1a6:a8e5:9240 with SMTP id x6-20020a170902ec8600b001a6a8e59240mr13889786plg.4.1684786585815; Mon, 22 May 2023 13:16:25 -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 l6-20020a170902f68600b001ab2b415bdbsm5247910plg.45.2023.05.22.13.16.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 13:16:25 -0700 (PDT) Date: Mon, 22 May 2023 13:16:24 -0700 From: Kees Cook To: Azeem Shaikh Cc: Russell King , 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: <202305221316.C0D13F1@keescook> 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> 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=unavailable 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. > > [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