Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2646927rwd; Wed, 17 May 2023 12:23:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7XZVgRIqsNUWfpZUqSz3k5dTOsYYthEUucPyk2ZDHB+7BODCLENMh1BPiclfzCnu7wdb1L X-Received: by 2002:a05:6a00:a21:b0:64a:fc0f:e0ca with SMTP id p33-20020a056a000a2100b0064afc0fe0camr1093108pfh.22.1684351422103; Wed, 17 May 2023 12:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684351422; cv=none; d=google.com; s=arc-20160816; b=UQqTUjmu+Iu6NSkf8mTCIPeYfV9i0ILfgn42EUici+RC/uqvslPw4O9uG2Eb+SLuoN lVebKv8d0acBv4w7k4p9ATjYlkbmQ9aMdQInSpIqatz+pRAaQKTxqa4Bf04ND1G4RKGg QvTfvb0XIUUFburFunMiaRs4LYKO35EaWbcTOYzNFCfVnXpSqqYsaxUBFQo1ZTL8csHN iotjz8wWwplHgg3Syo+lw8UAIgf5SgKB9Y0I9XPoQDpOYheamfhd7lbuZNvbbrl8DHKq dekdHUlM9wr1Z305x7La1fNFFfYaFOo/eQusEcBh/Hj5sX23LYefBBr5B+cnqgrF541V 2rJQ== 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=FOcRPuLGObm+Vg1R2GCaP1lmxZ7GfKsTU0IS+UkR3zs=; b=TA6BSxynfbiAmcHY/efBRVG3H55lo8IvsdE3COWJW/qsDzXYKNHXI0k30WWo4PW5P+ GuV7nk6VtUPLRkJUjy+A2PwwXGahksyNUMWQzlkqiIvkgksjQMXvHuj+uqN8AqTiGGw+ AQRgZ9rMOwm9dyKqZ+8VSyLAHdFtkNzDNMHPLO20T4rVuPdBa/lPsCLD9BLJGpk+uZBr 7+jyHJij8h2exumSNPWQAOCtgjueOJ3aBD63bBIVjyLv5YaB8fDTDkdm1FIkpuQJRFm4 wULmUUWdjdTQgLQtBKFaezcirhcN3mfdEqO8mHkM8MTf0G0+J/BuPxj/3rXusWk339SO +fGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SUqO4jCC; 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 x1-20020aa79561000000b0063b8ab7f91csi22489595pfq.365.2023.05.17.12.23.28; Wed, 17 May 2023 12:23: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=SUqO4jCC; 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 S229999AbjEQTOU (ORCPT + 99 others); Wed, 17 May 2023 15:14:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229989AbjEQTOR (ORCPT ); Wed, 17 May 2023 15:14:17 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9FF2D056 for ; Wed, 17 May 2023 12:14:05 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6439e6f5a33so836716b3a.2 for ; Wed, 17 May 2023 12:14:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1684350845; x=1686942845; 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=FOcRPuLGObm+Vg1R2GCaP1lmxZ7GfKsTU0IS+UkR3zs=; b=SUqO4jCCzRBEgKPabZ2BR1iWXlDt2bJ4YSx2nTK+jnAsmW8ztUDPnxFpi2XNxv89H0 xkQ2xhTIBVlUIXd65WUWWEmzgGVJRq5XXv4dHzNMp9TnfYmVeRGoc5/iYDZuxhtKLl+X R/owG4gwXqt6fPHMYaTSzJ+vYIB2PSQuBqtjw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684350845; x=1686942845; 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=FOcRPuLGObm+Vg1R2GCaP1lmxZ7GfKsTU0IS+UkR3zs=; b=XrnNYyf2B7kxYD4ldoutekli+aTQlEYvd3dyNJekXq/szh5P3X6fWmYUqQ3yiYeNeN gWh8rAuDN3Lmw3+Kyhb7pwFiZ1eA5btmB7sYfemfHHxN9UeOp3bGxVt5/j88Y4zwcp7s GcRUVGEjwlxd2+XZCQryZd24HxuRY3fL2js6MBp/PYYMA8MxpqgMSK6e6gewvF++yJR+ qUKAJ3M1hCthMT8DD1xS9J/ePG2uFQOWX5mvpI0NlZmpv/ob5+7ihXE1EsAVosVKCPBl Y6r3EcfIRrxcrEk9UfuHj1LS2P1dry98yg2WslvdgNn5iJiusIk+RiyVBOpgn7peZGPW 8NcQ== X-Gm-Message-State: AC+VfDxDI/DzOGz05hCuBq/3L6YjAofDTWYEvruSIscgZgmIe1PuTIh4 VE4ICEUQJoGRi2ttkHKZAWXYCA== X-Received: by 2002:a05:6a00:15c1:b0:64c:ae1c:3385 with SMTP id o1-20020a056a0015c100b0064cae1c3385mr866272pfu.32.1684350845462; Wed, 17 May 2023 12:14:05 -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 f13-20020aa782cd000000b0062e63cdfcb6sm16005552pfn.94.2023.05.17.12.14.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 12:14:05 -0700 (PDT) Date: Wed, 17 May 2023 12:14:04 -0700 From: Kees Cook To: Azeem Shaikh Cc: Tyrel Datwyler , linux-hardening@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Ellerman , Nicholas Piggin , Christophe Leroy , "James E.J. Bottomley" , "Martin K. Petersen" , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH] scsi: ibmvscsi: Replace all non-returning strlcpy with strscpy Message-ID: <202305171214.77A5A62DD@keescook> References: <20230517143409.1520298-1-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230517143409.1520298-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,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 Wed, May 17, 2023 at 02:34:09PM +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