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 A7D2EC7EE2F for ; Tue, 23 May 2023 17:20:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237740AbjEWRU4 (ORCPT ); Tue, 23 May 2023 13:20:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237431AbjEWRUu (ORCPT ); Tue, 23 May 2023 13:20:50 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 238F8C2 for ; Tue, 23 May 2023 10:20:49 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-52c30fbccd4so6754556a12.0 for ; Tue, 23 May 2023 10:20:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1684862448; x=1687454448; 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=T+vO/cCzHwQuFnPVrGLDZXukRrxNDu5SHC6BXOa81Zs=; b=hTrpGv/LdaPA65qPf/L+BSDkbT6zxNZTQPjO/67q6q9Xdc3oYNnP6YT9VTuIFvwA2n zzddg+xmleQpDg8/38lvv8BZYegLr+KluMOfzUuair0+1TpySYCCpJhlWYGOgB9PEhXt X+fTUDs9r+oaJYcBZwZTy6oX1F0dGqIStzIwY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684862448; x=1687454448; 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=T+vO/cCzHwQuFnPVrGLDZXukRrxNDu5SHC6BXOa81Zs=; b=HySY39Yu3IYte6e4jR+3eN/4+j/L/wlObG7Fkd3L6LdbV8Ckz1ePCbjCPeVdimpkMW C5gSAqK/cIyOv02JcdxZeX3kBcS1g3sFlfpVvSQDOPSr2I+22+wMmQoLBB3yUeGO5RLL YTVXZip+mNQ8P9zadlVcjSZIFScZk5pW3zqfX7TEix0Arjz6GFIOgb9Fn7xt/YJl7Bum o/R8GB501yi/36efJgWISHIUvgFZb1NJNfW1a9TukL+jR+J2eBxPxrK8QoRvN6bA+PeB eXgIixw00ooQLX7e94np0TEFrNpBsMrgeWvmxHuLJIkZeirvD9zKyKw3kjuoYg2EEq/3 FimQ== X-Gm-Message-State: AC+VfDzv/PR/ifRtPxTHMHLGj+U3ikTzzyFxcPl5/cXTVoQRiwgD9KqY DSob/o2ubdWqq0cuQIU+8hH3q4uzsqT4fRHe8OQ= X-Google-Smtp-Source: ACHHUZ4P8xDP0TNAyj32JLK4hmrdVTDjOgl2B0qIzRYWdP+XmmGQKtfRjG2ZNIm+vY9oedRsM1SR9Q== X-Received: by 2002:a17:903:428a:b0:1ac:4a41:d38d with SMTP id ju10-20020a170903428a00b001ac4a41d38dmr13144028plb.51.1684862448641; Tue, 23 May 2023 10:20:48 -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 o18-20020a170902d4d200b001ae44e2f425sm7007182plg.223.2023.05.23.10.20.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 10:20:48 -0700 (PDT) Date: Tue, 23 May 2023 10:20:47 -0700 From: Kees Cook To: Azeem Shaikh Cc: Qiang Zhao , linux-hardening@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Li Yang , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] soc: fsl: qe: Replace all non-returning strlcpy with strscpy Message-ID: <202305231020.37C95FD@keescook> References: <20230523021425.2406309-1-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230523021425.2406309-1-azeemshaikh38@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 23, 2023 at 02:14:25AM +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