Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9755062rwd; Wed, 21 Jun 2023 11:21:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ46d5fLxovkaoAQa9PRKMyZA+poCJyBNFt9CnjOhvcbxVrJvkZvm1B9UHw9sRLN8n8J+3yZ X-Received: by 2002:a05:6808:1450:b0:3a0:34c2:646d with SMTP id x16-20020a056808145000b003a034c2646dmr8449384oiv.21.1687371699189; Wed, 21 Jun 2023 11:21:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687371699; cv=none; d=google.com; s=arc-20160816; b=uZON0wl8rMkibvFjcEtLcpmFyAVSlqcI7jyWC13ydl4TXLHtV0isMA+oDQVqEbuwYG 9J4IHRSMJro+IpTnOs1D6ELPhnaUl5oixsA9ziTNYj27OZgaUscBy+AzE5J6jKB5PEFf hTYM3AIIB6dgqBg+M6jiT8uAU97wxUVGYj1qkE3UFH3f3nQ8gYTOpGqspK8zUGTgXBtN qu2ZcDHBspZpRWCV3iZZ1AO2sd2xZBY5RZH1nsiXp3lfWk3oyxigcrSAasVDz78WUwrP 7s1nTIjzuHpHJMQLV+f0U0mDoTU3UIaBNYjwyDCEyf9ZpusCCw91ysgBKUUwSgjwzKH6 gNpA== 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=NtCU2aNHiXALlbRX9I4DukzgSyp1YjBiNC4CphoFrEw=; b=adSOvGghV9H/q3cMJqnQtsf8cPiTpdf+N3USvvymETt35KuI6McCkZF4QrFbWiWQ7R +ZldQmVRZlgSrZxp1vj0P5fDPjMHeX74VitWzfo1TWg4M1I9gIroL7uctl1LSEemsbNi vAyl1V1kywhmh89vfHm56NbbQDYdLDwrl9tJRv2Evkh89ppqqPOFdl1siXZi7gX2Sy/2 8pRmQZRl8cYvJPMXYbVnhi9L9oT6GRf67FsDSr8ZMLdj35U4vcfMYe1anQpBN8ih+Ckg C7U2D79wFVx4ac5mLrE+TR9fWYgUS4UlWbJ87i93ol35oEVLRc7k6jIy5NmmMbM9xzta 7g6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EqOdfYun; 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 v21-20020a637a15000000b0053faf4483fasi4607618pgc.143.2023.06.21.11.21.27; Wed, 21 Jun 2023 11:21:39 -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=EqOdfYun; 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 S230518AbjFUSKD (ORCPT + 99 others); Wed, 21 Jun 2023 14:10:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231429AbjFUSJk (ORCPT ); Wed, 21 Jun 2023 14:09:40 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CD101BC3 for ; Wed, 21 Jun 2023 11:09:38 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-25e83a63143so4617297a91.3 for ; Wed, 21 Jun 2023 11:09:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1687370978; x=1689962978; 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=NtCU2aNHiXALlbRX9I4DukzgSyp1YjBiNC4CphoFrEw=; b=EqOdfYunj6JALtj6gBMDXY1XZ1NuBHwdT6XXru7HPOH40ch1whOqrIXaaidsAZDU3c Fyo49GFMqwN5ola8kxFJPPzHnSTASl4xCJIP6q5pNko7QF/Nq7b3hAnUWDPFGJS2E85F NsvAwizAbJH+Sdjb0+9M5uQSkL7rxy7YsCFNE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687370978; x=1689962978; 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=NtCU2aNHiXALlbRX9I4DukzgSyp1YjBiNC4CphoFrEw=; b=b2HpzhdskQMCNlq0tWBBrbI4QliceOa3HZa6YltLQuu9tuqADnA7cnyrqcWSjntrP+ /x7dau1Bmzlqc/u6T5KOZgwA6e5ig0eJNNGkYtRCTLvojGdpBK9BH9qnSwud55uT9uSX EoIXtjx2oGZPVMkAAslbvGpXJaj30XCHAUN75VO+vpcZUaWZwW+115gfFX1HbQ3zWk24 iDiNn7JZtuDXTKF9wLPO1hgeXaZHK+5wLpiXetyl7zdFagOejMJX/bqCQSow/Wt/wfxH 9Vq8sX6fy66G5R8ErK1Bc5BTe0tUODm7e50SHCIL9UUP97o/rffltk4hIAU8ZItj5ELS F/OQ== X-Gm-Message-State: AC+VfDx1UseQaFpfWjgxqtLILUg6tW/mmXAvZhu8EmEwavwwPwlIa4dZ 0I2WISWIg7az0wGsqDOkNUPeyA== X-Received: by 2002:a17:90b:38c8:b0:260:fd64:a20 with SMTP id nn8-20020a17090b38c800b00260fd640a20mr2364445pjb.9.1687370977767; Wed, 21 Jun 2023 11:09:37 -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 x18-20020a17090abc9200b002533ce5b261sm9274479pjr.10.2023.06.21.11.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 11:09:37 -0700 (PDT) Date: Wed, 21 Jun 2023 11:09:36 -0700 From: Kees Cook To: Azeem Shaikh Cc: "James E.J. Bottomley" , "Martin K. Petersen" , Bodo Stroesser , linux-hardening@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] scsi: target: tcmu: Replace strlcpy with strscpy Message-ID: <202306211109.72E5989586@keescook> References: <20230621030033.3800351-1-azeemshaikh38@gmail.com> <20230621030033.3800351-3-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230621030033.3800351-3-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,URIBL_BLOCKED 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 Wed, Jun 21, 2023 at 03:00:33AM +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