From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10A6CC77B75 for ; Tue, 23 May 2023 17:21:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237314AbjEWRVm (ORCPT ); Tue, 23 May 2023 13:21:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237719AbjEWRVl (ORCPT ); Tue, 23 May 2023 13:21:41 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0BF2E49 for ; Tue, 23 May 2023 10:21:19 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1ae3fe67980so72819385ad.3 for ; Tue, 23 May 2023 10:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1684862479; x=1687454479; 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=W5S5txlWNiYeKIEfhmZSeDGPnfFSDx5ycbWVRYMu5dI=; b=lrP15ZPaMmvR5rJuYAASPnbjeZYvXf0yiRkQ1CYjnypEMU5zoEvMLZj19GdPCI4/Mw rREjfwYPpbtcDBkm/f3CycHsjt9YkV7+bxsmMn7DBiv0eYJLrZVL/HN3LcP+D2rUlDXu duzHtKUI9GwcyIORlYUQ/LA+xWG9QFbCmK5H4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684862479; x=1687454479; 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=W5S5txlWNiYeKIEfhmZSeDGPnfFSDx5ycbWVRYMu5dI=; b=EUZivW1oFg9K+W4GJtWT8GmMN/cVN07+89VTrZuMcpRGkGvjLCApxgfL8LexSV6KOA /rQLKl9l7h7Kei6QcqXIPFd/quv58+gMo1Aq/p4NEZzEoNUvdbiYc4oGv6WgkroJiNij IIkj60Qu6Q+wD3FxVE9dno9qV3EnPv37yBXKwdt4T74D09FlGVMQTnfJUqbBLYr62woe IRPII/fG0+G9ikg5QqrYalHu3Tgf90uXNjYnpSyjilJYYzDvb4dglXXNYzF69EIlY6f1 ENKun7Rnbk83SPDWbPNmb45qHOnLAaLSTSh1eillne1xOZKxiP1VTd7tBBAPzHonzFJt Ch7g== X-Gm-Message-State: AC+VfDyckgtNhxMQ1VIB72UFBME/fRyoHbOKd48hwy7P5A0t7iPirE8N NGaU+MC63agIni+1CCpN1VmLBQ== X-Google-Smtp-Source: ACHHUZ5AGolyDK1desZRPBO2wmeKuC8o8zbGl++vcoBBGTrXyygK4a5Hm6SfJkUiqsEdeZ2tdi1ABQ== X-Received: by 2002:a17:902:dace:b0:1ae:43a8:2759 with SMTP id q14-20020a170902dace00b001ae43a82759mr15495847plx.58.1684862479082; Tue, 23 May 2023 10:21:19 -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 iw17-20020a170903045100b001aaed524541sm7032578plb.227.2023.05.23.10.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 10:21:18 -0700 (PDT) Date: Tue, 23 May 2023 10:21:18 -0700 From: Kees Cook To: Azeem Shaikh Cc: Pavel Machek , Lee Jones , linux-hardening@vger.kernel.org, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] leds: Replace all non-returning strlcpy with strscpy Message-ID: <202305231021.DFA0C4F7D@keescook> References: <20230523021451.2406362-1-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230523021451.2406362-1-azeemshaikh38@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On Tue, May 23, 2023 at 02:14:51AM +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