Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp9067854rwr; Thu, 11 May 2023 09:31:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5KRECa4tDP3Ul6MHcc3zfrOu2DRsbcVB0+h2RYIIpUtl1Ob98slFqyAPD+r73lYK85hUlG X-Received: by 2002:a92:d94f:0:b0:335:de72:23c8 with SMTP id l15-20020a92d94f000000b00335de7223c8mr3263730ilq.7.1683822672120; Thu, 11 May 2023 09:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683822672; cv=none; d=google.com; s=arc-20160816; b=wUOVZi3vHuUEZGNLGnBYuhS45ggI59GXsorncO1FttkrYV2aED8PoBy3sS5tc1p9AU ai9FCHLuN3NTVX4Te5WQ0dgoU/q4rSkW9gzPNfMFyw/qpiOhOXCj0QFnedu3JrSBDPOf WMJUdODjyiJqMSNHr7nQdUbImie3p+UNnyFwO3LSvRTZHJjZxa7WoMa5L5IXOvpG5RRD 626HTD8tEL1upqoDytIKVpN0MMYUiJisyq0ew12hTWzlH5ZsuZuBkq6UqYkS3JODYDjX +vpZFCtNhmTQ3Gm/zQkZbE3qDmjITxxI+nf6DcYEhJyKzvblahw3rgAtX3QcqUI/Qf/L XpoA== 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=heapyBOK3aV1fZtrL6FBCSipibEU/9iPf6nNQf6o/H8=; b=vIUvFsJLAwVn86meS7+6CP1UOyhJtBRdZcnr8LU/ihDXR4xIXLq3Svu+uUVJxh0mMC T+lwd584lBmoEBYxTfj36ZpV40LfRLbd5Z6G0uG4DkMmiyxIxVxV2JjfvgdYXI+5LMJ2 d8NGBBPfj3fA5aMzepPlezLa30IOEDkXdmY9H51yxbwKASiZAy8KZIRur6l7dcNJfNJR 9MF1Ta/0D6wo6/KdoMoIqU6LOKDcu+rswylmR7G5vhhouMVe4Gt5Sbq78vWedCSmDC5J Paw2GJhsXrz9QIHMAMLSTrjKpuUquTKHlVanNl6FEG26M/aZoqjCAYLyUFeTMwsi/ZIc Feig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fpLgr46G; 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 y3-20020a920903000000b003328376513bsi8895251ilg.119.2023.05.11.09.30.58; Thu, 11 May 2023 09:31:12 -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=fpLgr46G; 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 S238314AbjEKQVZ (ORCPT + 99 others); Thu, 11 May 2023 12:21:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238319AbjEKQVX (ORCPT ); Thu, 11 May 2023 12:21:23 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BA022101 for ; Thu, 11 May 2023 09:21:21 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-517c01edaaaso5892053a12.3 for ; Thu, 11 May 2023 09:21:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683822080; x=1686414080; 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=heapyBOK3aV1fZtrL6FBCSipibEU/9iPf6nNQf6o/H8=; b=fpLgr46GjmxVMykYNDwOPIDPvHafCefP8fNnepKPuq1erqsrurtMc293jCPXm5AJ/1 181Wlk1a4XNBgrUwPzQHmhoo7wwGmdwe6hvuqZuT8MDxsHxQCTuasgNNj85oze+hfZSh DJj4iRKF/NrcBtey8LbCWG+dblmVoazJENJwk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683822080; x=1686414080; 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=heapyBOK3aV1fZtrL6FBCSipibEU/9iPf6nNQf6o/H8=; b=ijnxZL1sddW1OEgS2MXn/SxVxTjWLYEr65vgD03UjR2Zz5HxSyKhwYlGfB7kHwBDVd 8QbuPDY6MTMc/bRIcTh9i1WrzGnvMLyVdjtJX29QS8fSA/gBeNV8yhQki5JOnHyZIXSP flzVi14RuVfKfDMDeTu27SkVGoiw41EfrniU7nHR5IonTrABxxmq8dJMo+jRBiAhNnHf r+VJcF0mEKQz+wP5NlH9BlWIayEoJpT7IqFGO1fH00cnDwDGBAA5PQIyO/feNU2dtdCC WUvPoZTuUyHss6Ya11jXTd+UB3imBKdbCVykT7udK1nJEHkLLhCJnFnn/cFXa3HhElV8 5l5w== X-Gm-Message-State: AC+VfDwa2JdWoNf3PTZyy6bPDKRNmM4eMS5Ihfjjc4Q+wMk/1gI8RDth Ut7j7RFgEHTAaOevTBSMIregIw== X-Received: by 2002:a17:902:eb4b:b0:1a6:7632:2b20 with SMTP id i11-20020a170902eb4b00b001a676322b20mr23433122pli.40.1683822080560; Thu, 11 May 2023 09: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 d12-20020a170902cecc00b001a6f7744a27sm6160602plg.87.2023.05.11.09.21.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 09:21:20 -0700 (PDT) Date: Thu, 11 May 2023 09:21:18 -0700 From: Kees Cook To: Azeem Shaikh Cc: Hans de Goede , linux-hardening@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] vboxsf: Replace all non-returning strlcpy with strscpy Message-ID: <202305110921.B62DD1BB@keescook> References: <20230510211146.3486600-1-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230510211146.3486600-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 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, May 10, 2023 at 09:11:46PM +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