Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp74760rwd; Tue, 30 May 2023 16:30:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7CpqUVTY8Pk5v1Nt5r5t/HRW8Eo8uqx5rBuxknOnNDeW3WfpEZUFmLmgJKwjkaq5UDXMPT X-Received: by 2002:a05:6a00:1825:b0:64d:1e10:5000 with SMTP id y37-20020a056a00182500b0064d1e105000mr4617684pfa.14.1685489449034; Tue, 30 May 2023 16:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685489449; cv=none; d=google.com; s=arc-20160816; b=gwgfOSWXtUbG+TvCQ7q4ja8r7ZZdUjCB7uXiIkFxCW8x4558WOjKwVKT1WjRFK5CuX nduHQLPnc/OGEtDV21kWYcQ/2p72AIjjrFZvDE+NxnioR8AXcjKkPT+Ggh0+R8Ll7aFR zz5Qbp4UNQN3EVjmp4lboROSlD3cVOG9ODymjB8XF6a6UWvhMG3CU1MG8Oo0NB/y/7ek Eqk149y4thg9BfJ7oWEejT1zNYuK/1rr/FELGmRCQDjs3PrZUEH8Stf9DsZBgzC4cNYx +Dj5rPBQscmRtRHS5SLIhXSN5aOvnpe1iPXKTa0W9BJz42GGy9kDZT6xiLJxqVo80dX3 oV1Q== 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=IRZs/nBDDXW8hF6u2e1Wo2UXvn96rgveDiIWpS60WGY=; b=xZyYtJGtPwVayx5U7fBy4phAEmBLni+Gz00OOmsw/WvoU09dbBz2nW+7Gh2MyvQNzs e64PdozW4TOrO+FJhaDVgH0dNss8H/+i9WZHOfNMyhVv/cwcKD0hlBizm8KcUEm6l4n0 aMylxb2Bqc1/x9m3saT7Z3wU0gyiZlAmUH2ls34yZ4igZ6SsaCQN5BGCmKPQS/2ZVhnN KulfQ1iwsZYxMk/4i/SF1jfKqXm2+DjDUZUCLtDWPEjMq571LC/Dv2HAKvEpHknvsEk8 sS2wMvzRo/XAZATqDr+TOFd9wBWFZOYh2fQ7bYXCbgH6OfzADQZiZgxOxOnonGQyrTdN /V0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PEbjfLdx; 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 c20-20020a6566d4000000b0053439c1712esi8350580pgw.713.2023.05.30.16.30.37; Tue, 30 May 2023 16:30:49 -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=PEbjfLdx; 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 S233869AbjE3XSY (ORCPT + 99 others); Tue, 30 May 2023 19:18:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233852AbjE3XSL (ORCPT ); Tue, 30 May 2023 19:18:11 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82473186 for ; Tue, 30 May 2023 16:17:50 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-53fbf2c42bfso899831a12.3 for ; Tue, 30 May 2023 16:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685488669; x=1688080669; 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=IRZs/nBDDXW8hF6u2e1Wo2UXvn96rgveDiIWpS60WGY=; b=PEbjfLdxYEC5I+F/kOYnuFocUEL0W6zEKS+ZeM8Tp8kj+0TX4vs7zeOjMUUxpEMaUg 2UkmXa1W8MWhwREV0tpYJAOUSqoNySdONFhTLeKsPtAGpm5i3p8qreXro7IMSJuKZ5Ao b5gNXVVDzX4e2emY9dZjDpPCK25JKyQlCcRuM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685488669; x=1688080669; 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=IRZs/nBDDXW8hF6u2e1Wo2UXvn96rgveDiIWpS60WGY=; b=K0TGGRgPQS2TfXuBe1g4s0Wg0gwEWAFtfdG/TY7LEh4aywTAy/yQRjw4OiwbhmeyB+ XLIr3tKgA5iL3S++xIzTHhrLsU8+HxfLPB06MamAti+j2HR1ZnbPTBrd0ohIeIcU7tsP LWbkAHfMG725xiwUrLf2rOeQO6C7ouCelbcCYfXq4kwrex7+Y3ydPIFgXaN5Sbyd4v0w PY+VG1cKUW8eu+/tvSPsmA1PKKbSZs9cjvSD+XNq+UslUu7GPSaWrOWwW8yC/e4sQsG0 aO4Xqi2oETZe/ssOpK2m5qn2+63l9WqRD2T57507cdOeczIksJHAVRboGz1CDsijAZok /xLw== X-Gm-Message-State: AC+VfDxi6pBhjTHTZTAuxeikQms69OkQ0u6/aOceo9sl+O4EqzovGCo4 K8NJX6yQjDzPBs+ZKIqR5pKDQQ== X-Received: by 2002:a17:903:244e:b0:1ae:5fb0:4256 with SMTP id l14-20020a170903244e00b001ae5fb04256mr4777826pls.57.1685488669724; Tue, 30 May 2023 16:17:49 -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 c2-20020a170902b68200b001aaf2e7b06csm10739048pls.132.2023.05.30.16.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 16:17:49 -0700 (PDT) Date: Tue, 30 May 2023 16:17:48 -0700 From: Kees Cook To: Azeem Shaikh Cc: Matthew Wilcox , linux-hardening@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" Subject: Re: [PATCH] scsi: sym53c8xx: Replace all non-returning strlcpy with strscpy Message-ID: <202305301617.2D0EC7BCA9@keescook> References: <20230530160323.412484-1-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230530160323.412484-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:03:23PM +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