Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp69125rwd; Tue, 30 May 2023 16:23:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7cgti1vA6PUA7CXQRHXjv9xm0cXfv4Fe+V8LxIJ0lxPOzYri60ngTkqjMNXcJzPriDQG4p X-Received: by 2002:a17:903:120f:b0:1ab:11c8:777a with SMTP id l15-20020a170903120f00b001ab11c8777amr4067668plh.13.1685489024297; Tue, 30 May 2023 16:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685489024; cv=none; d=google.com; s=arc-20160816; b=Ay+CJMUitRq6hAHlmEM06LIa+Cg7RMo2WFmBOO3U71mkuckRLHuhx0xdo4zp8qrfol JTSuVVUTc6Y/0mIcJg+xMUvHJbCbb7G54NtNV+1Xg60sIfrOUzuaFDN8fYhIiPKxdnAq rPSY0qB4GjFOXT3gJSbMuVuTjzWqGwaBPk/dO81cvlr7MyXibR+3wCqSqCDZh2ErBQ9G S1sbUrWRTu5rZ4hSSFrc1Tc2/sbXn+DFP+PYQtN/+o9/NNUeaI58ykv2hD1bNFIP0CrK PAc9ie/9/hzc2abo2SMImgAIoCpvQPU4oUi/n6q+7XQqEmiTiE8zi7Pe14BlbvHhZv7X B8kw== 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=kJ6a9RtH2F2C5B3qsSQMBizrWtQVR2WGvbW6bWVaocA=; b=UFwkjDSM3K89rUFbs13gUp97Ek/xtSV1tDcz/j7XN870s7vrpprJbwLLVqkdTd62iC 9d1y9b/hcRx2XRCdqkaqjyQ12hRk5JB391dRW8YQeWiF7X1uTBySsmsWYQ5v0Km9uGGQ Q2JQVs2hMIVu3soeFtBB8oTzjwu9wuXSSsLU+C6DJ9HMsrzkKmX2khqy179RkUUO83OS 6D4jBbTQZdYDHHk8TdENnJ8mJHyewbGZJdY+wkjcJLqheSdJwSpymeT8Rcuk+GwA7SBY G+oe0AwA/y+6Z1r9gzguCiOKyRKzl9zFEMi4lKuXtrDqloIrO7+eRy5b1q04r7H7Wkrq ZG9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gcrM0wof; 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 x21-20020a170902821500b001a97e24eb34si9251813pln.201.2023.05.30.16.23.30; Tue, 30 May 2023 16:23:44 -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=gcrM0wof; 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 S233884AbjE3XVF (ORCPT + 99 others); Tue, 30 May 2023 19:21:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233800AbjE3XVC (ORCPT ); Tue, 30 May 2023 19:21:02 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00447129 for ; Tue, 30 May 2023 16:20:55 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-25669acf1b0so2862342a91.0 for ; Tue, 30 May 2023 16:20:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685488855; x=1688080855; 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=kJ6a9RtH2F2C5B3qsSQMBizrWtQVR2WGvbW6bWVaocA=; b=gcrM0wofjm3uTk2EqNaBReNhxZhQOm2fsXojumGzkhhMcX5YZeWAyb/hi7Z/f1B5/j VPApEkU3QnJHTT+Kn3Dj9YwPgoDLxMLJi5TIBEt6rbTjGjKhdaQjQRV0sFxry15VZl3u mksosL1lOmQAyskBHC3HRUpxVXByfu0Bsa0Uc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685488855; x=1688080855; 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=kJ6a9RtH2F2C5B3qsSQMBizrWtQVR2WGvbW6bWVaocA=; b=MPVT6ZW1aV0cTxT5l5BlvgVtvkPLjX7sFXZqTZ65b22l5rqJQW/A67dxZTLRdtAg0R EGIKBsFWMgADXnGuDeteeqy6MJZIvbe2tWvKHCNqhwzy6yoGB/0sjMTD/d7Th6ch9t46 TN1wscJrIBy/i4p/Uhd9whh+GnUMhe8HsRBV/F6zVVs69Dxxq0pi7nQDrCeAFai/i+rW sDSnJ8bjID0ujyN0YyaZaDy/J2KyNx9yWtD9FbGGkBDmILumME1rgRZalVS+uoiPz0vf ldcNbSsPa++49BvUXCsugkjrPLiitnPxGfIoHdg9sNd/c1u2l8fjWFPcSNikVARq4k3m L/EQ== X-Gm-Message-State: AC+VfDwrlrXgi9Y+uh+Exvf9YF7Vu532FlWtxDUnhR29uQhDpOdZmwBq J06nvxEEUv3cGH/jueh8x9541g== X-Received: by 2002:a17:90a:6c64:b0:247:2874:a6a6 with SMTP id x91-20020a17090a6c6400b002472874a6a6mr3936156pjj.2.1685488855367; Tue, 30 May 2023 16:20:55 -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 o2-20020a17090a678200b0023fcece8067sm3510889pjj.2.2023.05.30.16.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 16:20:54 -0700 (PDT) Date: Tue, 30 May 2023 16:20:54 -0700 From: Kees Cook To: Azeem Shaikh Cc: Dinh Nguyen , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] nios2: Replace all non-returning strlcpy with strscpy Message-ID: <202305301620.346CC541@keescook> References: <20230530162358.984149-1-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230530162358.984149-1-azeemshaikh38@gmail.com> X-Spam-Status: No, score=-2.3 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,URIBL_BLOCKED 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 Tue, May 30, 2023 at 04:23:58PM +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