Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp78860rwd; Tue, 30 May 2023 16:34:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6RM8I180J/6oymA2NsAcw6xtSlSeaNjHoTcUxTJpmTXgttMm0gT6+BrqM6Na/fXILpuQ97 X-Received: by 2002:a17:902:7007:b0:1af:b682:7a78 with SMTP id y7-20020a170902700700b001afb6827a78mr2989922plk.52.1685489681438; Tue, 30 May 2023 16:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685489681; cv=none; d=google.com; s=arc-20160816; b=Pd8GStJrcI5f/sLJX44XPHsLObuF6xKDWzC5EyxUEk7VEpD3zZAg7ZsZfb6y0K5I0v b4X8OJMkocStfIh9e58AQyzlauU/LddaoKW2zl+hPps85ZVFr9MQWLQpZ36k2oUkIymv cnfBGffvClKCl+amUMnGFaxzznZkEqOWScc1hP6zZOKNxXTRF3boQEAyZVPsbmMCfufe HYHYokCWwQ8CT+5IMSRZ4/bkiO7RCCnq8MsplCCVbWNAnl5hqyavdFg1y1hs1TyeObQL Oaulo+Y3n7jg6AE63HD+pksJDIY+W2ssh7A0JhEFGK8UzfWmYsObhQ+jZnIRrvUDAaVc EciQ== 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=olkd5FdK39xwOU4GbWWKQgW5dE56bKupA6Kog3J0D9U=; b=z4f/1H/L//FHOqZvIf108fPFDMorZuEurtXCDWLB4+VOMm7ClDlOmiUbgEzs5Any21 ljXoylR8njGPPGdpmXXgDUkbiyzAEJpCNzjDTHfz58kocP1XzupimZ0frM9WpWZUvt5m hBuKjCHnT2iARRNWZ55OkjfgYkzXZ2SkY1jAS5gFqZbl9S8pLn8V6mmw8HEPvAb1Bjoh Nxf/iTyCenS7zXBRHTJWH18N8OgLbbJY9RWbarVsgEvHl2QqaSquvXCuoZltF/FVTEdI kgRMQpxr+ghGjzwz+KXEpGwOx9u2B8voWCif78vMf1c8d862DdDhRomaWg8IY9f8gTrk l/Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=I66Txfyw; 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 t8-20020a170902e84800b001ae7c64654bsi12596174plg.387.2023.05.30.16.34.29; Tue, 30 May 2023 16:34:41 -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=I66Txfyw; 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 S231348AbjE3XVw (ORCPT + 99 others); Tue, 30 May 2023 19:21:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233898AbjE3XVt (ORCPT ); Tue, 30 May 2023 19:21:49 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08E1AE5E for ; Tue, 30 May 2023 16:21:21 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-64d5b4c400fso5695264b3a.1 for ; Tue, 30 May 2023 16:21:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685488880; x=1688080880; 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=olkd5FdK39xwOU4GbWWKQgW5dE56bKupA6Kog3J0D9U=; b=I66TxfywFbovbwxMYfgVqGu6OQ15EAfC3r2Nk3gU4AlgjbxZUqZpUbVpAQIfdtnc0h FXdv3YrEUG2H/4wiPbkwiLFyuNcTd0PSOSnje+7kLQbCtU2x4t9OprLMMRCowpallEeS F/GnpmvW0w9OTMOmfTk+HT/pzqBqo7VJ/JVhM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685488880; x=1688080880; 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=olkd5FdK39xwOU4GbWWKQgW5dE56bKupA6Kog3J0D9U=; b=SXPTRZmTJJhXYgFAcrtdSHGqeyP/1G6SAus1teTeDwTMOCj3dtE5PvTVce3rGcMNhY g2ZDyzWgJZiVzF44liXU6uFRcF/vyLDWVELXigfY1jwyjcZe5uWvp1kq398EDB9iEBZT yZbgKN5cI1uD6U/Rsy+46VVj1B+4fas+mlBZFfwcvN2V+EhDIib/NQVNxNFrwpfGp/oq nsL/0l9EK6OwSmpdkobmCqADOanFVP6SnNsoB6yuBgij+6orapfOjbXrCG4n1M49fHtm T2ruDUMNfTvdW7LGQz6tJntD/pAm43ZhJ/avFV64If2McMSxYGkGl3J4fqnmZlvt347U LlXQ== X-Gm-Message-State: AC+VfDyaJi8Ov2DBJ6tVMTxm2Zi0y+uy/3EAuFG6/N68GVtXhWifCH0I MoKZ3V7vCP6C3AkWICcfKu/gEQ== X-Received: by 2002:a05:6a00:1787:b0:645:cfb0:2779 with SMTP id s7-20020a056a00178700b00645cfb02779mr4255573pfg.26.1685488880576; Tue, 30 May 2023 16:21:20 -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 u25-20020a62ed19000000b0063f2e729127sm2171189pfh.144.2023.05.30.16.21.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 16:21:20 -0700 (PDT) Date: Tue, 30 May 2023 16:21:19 -0700 From: Kees Cook To: Azeem Shaikh Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Alim Akhtar , Avri Altman , Bart Van Assche , linux-scsi@vger.kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" Subject: Re: [PATCH] scsi: ufs: Replace all non-returning strlcpy with strscpy Message-ID: <202305301621.3D086C4C@keescook> References: <20230530164131.987213-1-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230530164131.987213-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=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 Tue, May 30, 2023 at 04:41:31PM +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