Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp8719938rwd; Tue, 20 Jun 2023 20:21:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4h6cfEZbkZ9a5DCRgf+zo2SEiTablUJH+owFaXGPEAC1oT1YPU+gXfTPRIDludsCku6zqz X-Received: by 2002:a17:903:2450:b0:1b5:31f8:2450 with SMTP id l16-20020a170903245000b001b531f82450mr17714429pls.51.1687317660200; Tue, 20 Jun 2023 20:21:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687317660; cv=none; d=google.com; s=arc-20160816; b=CmIvZUtyu8O9aXI+dSSK/rRy6oxZsxaOLYiv9eftDFxduhSmVaBExbJMbfHiqHvwv5 IDh5x01qdPslrLkB8ITm7hlHXZXMWgJa21bqh1ycVdEK0FtfBf6EoyWNShPQSfnSfebo 1ZAl2CygRn83duCln/PRoxw+cELvvU2SPoSRHnW+idp/Sy1d56IBg7zfqwtyeUU/pfXd vx1OmOD0UwjscqEHZRKfI9SrntrI/D0Zt23x9QNOlCpApArRizlHGbALUMY2xThO+qO9 k5n6KnmFJXnDgbrsNYi1sQg/s7xpXkMYb024t/Bbu3QT1nCf1LVGnTjpkPk+sfcWftgu AMog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9i3TwOUjrba6y/sZ16lkUZi/PKa7z6zduQ0cJPwPLqg=; b=KMZBBg1nzs7IkYlOp5+6HLqkwjKXwoQzxM7gTjWvTZwX+rbNAmlPRNVNK84pbLLSaT TpRXMN5vR937FGoHbbymHOoZeKU8USBb7IWIuSdxMDpg2t6ptcLOzuT0+wf6l/nG8nB3 V1Oxe0xDEXoTd2yoMikivc/FjoMGxHEOB3R/HZPeRwuLB5mespVSlx/upizR9QmKGkCi wqTrgPjjBaJdDqxKx8Tn3oxHNTNTMEnYYs5xwxCDRh+e8yjPqr3FvHYtychvsIAc1DYP BmD691Msbl3P4r0KIv4WCDst2i2k+kYE3wzl1PhtoR3Ob5F281W3E+jPHfPGRyxsIY+N 6PrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="KzJ4T/Hp"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z5-20020a170903018500b001b3da77c1f1si3310768plg.194.2023.06.20.20.20.42; Tue, 20 Jun 2023 20:21:00 -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=@gmail.com header.s=20221208 header.b="KzJ4T/Hp"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230050AbjFUDBX (ORCPT + 99 others); Tue, 20 Jun 2023 23:01:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230030AbjFUDBO (ORCPT ); Tue, 20 Jun 2023 23:01:14 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C717A19B6; Tue, 20 Jun 2023 20:01:07 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-340bba768acso26378875ab.2; Tue, 20 Jun 2023 20:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687316466; x=1689908466; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9i3TwOUjrba6y/sZ16lkUZi/PKa7z6zduQ0cJPwPLqg=; b=KzJ4T/HpsfXuydpnH5TcpZW3RZy68kv09P93asfMP/FwSRCRDaCrwxIyh/j24Dfq0+ xAnYbxEhSYfYilQOdTz6isg3cTnormzf2gSO8/Py5wuEmTOZ9lx6B977xnnpcI0VW67j gvPsQNS/NEu1LKWiPN/K/ZLNEJlSSh/VjHcdsZyKHMhQnbbScUTcjgosvYccUrfeS3S2 QRQoEumHUPnUBYHzTboO5XL3qgQOh8O6I5/hzQJpmatN9lgYSYcMAQH4PeRicSzkvWnY MGLTNQZrLXr7SHhMREY3cWf30rUzrYahIBq8xx9yHp5jbHIalORjY5K+5LMkCAoJ1a9S 0KHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687316466; x=1689908466; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9i3TwOUjrba6y/sZ16lkUZi/PKa7z6zduQ0cJPwPLqg=; b=h9w6jt9sNLM69dHENyihm+HPO4innwu/3QAUBsrEhuPHVpb0tfCw5Qn1dY9PpBdCsc UU7LsFn9A8oH6p7DZJDKliP6HAZQYNWSYC2Jv9hkn42twwO7OSjZukIJs+1j4Lfj72Eo gfELBT5CFbxzeZfermXxQUaUN8OZfznJd/mQsfSqeuRA1g3JTPo3ZvMYOZyKDAkckI2i pZlHjJPZt3/j1QRglnngjPVCtwlc7zV7MFNQrEQfsXW5Mn+WYVHHP2cSBctc9ZKs9gsf uamfl3DSXhkp5K8yPMe7NvcVJCjkzI5KsH+NoNZ6svy4jqxLS8ZDhHwMjvZ2lXp1C+Rt jHPg== X-Gm-Message-State: AC+VfDwvG62KTF9Nwtbh2Tn4rpbuS74V9545Ul6lKHvroJxfiKHHjmIS O+00GXDsxYI3WymELjtPX+A= X-Received: by 2002:a92:d4c4:0:b0:332:e5aa:f9b8 with SMTP id o4-20020a92d4c4000000b00332e5aaf9b8mr592276ilm.13.1687316466620; Tue, 20 Jun 2023 20:01:06 -0700 (PDT) Received: from azeems-kspp.c.googlers.com.com (54.70.188.35.bc.googleusercontent.com. [35.188.70.54]) by smtp.gmail.com with ESMTPSA id x6-20020a029706000000b0042682dd951dsm1035008jai.87.2023.06.20.20.01.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 20:01:06 -0700 (PDT) From: Azeem Shaikh To: "James E.J. Bottomley" , "Martin K. Petersen" , Bodo Stroesser Cc: linux-hardening@vger.kernel.org, Azeem Shaikh , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] scsi: Replace strlcpy with strscpy Date: Wed, 21 Jun 2023 03:00:32 +0000 Message-ID: <20230621030033.3800351-2-azeemshaikh38@gmail.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230621030033.3800351-1-azeemshaikh38@gmail.com> References: <20230621030033.3800351-1-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 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 --- drivers/scsi/ncr53c8xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index 4458449c960b..35869b4f9329 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c @@ -4555,7 +4555,7 @@ static void ncr_detach(struct ncb *np) char inst_name[16]; /* Local copy so we don't access np after freeing it! */ - strlcpy(inst_name, ncr_name(np), sizeof(inst_name)); + strscpy(inst_name, ncr_name(np), sizeof(inst_name)); printk("%s: releasing host resources\n", ncr_name(np)); -- 2.41.0.162.gfafddb0af9-goog