Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7899619rwr; Wed, 10 May 2023 14:28:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7v3dWVxWWtpqhJiDDmXttVbRcRxyHUH3HMm7u64+/FiGpB5/nOFtlg5o+w8UkvrUamOzGT X-Received: by 2002:a17:90a:f48e:b0:24b:4e7b:c689 with SMTP id bx14-20020a17090af48e00b0024b4e7bc689mr18097878pjb.35.1683754127708; Wed, 10 May 2023 14:28:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683754127; cv=none; d=google.com; s=arc-20160816; b=rhRvmuYhjNINSEtLABQbASEFpU7WrJpev0EmIJNS3LknDSLDrzgkGHnMjlY8U1J1Yd iLNLZ1GFQkLGmON1HTVaESsrg/MrT5n0pQgCthdNKF5+XZYrH0+JxtQCmg6bmZoWCldm klP++s9hZi3rBARZjwhjko93kNZcx6QTZ1Y8pkr+vnzEicz60du6jMRYEep6Rn+5RURG r8M7Hj6Zk0OBym6FaLVKHC3J0nLHTvRQvJdCmckqKxWZtCSlyIAwchEipVuOJcnhQ8f7 iESlyHldpk1rnUGphoyaFdXlPrB50Z2x/3pxWr9h1b0bdUh+d6hVO6TGs63cv/m0gbfQ BXKQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=PoxYWqBDKCkglae/wVRmkD/Q+O27CAC7GMcB4xk3Kxc=; b=C69i9eyCnPhWAdZqW87qdBgBmDQHOg4bIEFtOYVfvMKfUKn3m6jy774dSOrnoOL1vS F7EjCvPaPj4jGKwvA7H4R6ueGFiuWw7OFrvmxh525671o/xAs7W4x5t4yTrHdWfFA8ji kO+Typ1N65jpe0CAsl3sV3nZl/WPSlKIXmMuPoFARCMc0MJ4+qC/lHsya61JrXpdmlfU DracenybmCX3VbKkct6uosqZ5dwHQz+/Ksuhc0NnsDJlE71omDfKl9oGb1FClO5akVP6 iqKBoxiIaaB0MZe/GClRv8Yx0E3dQECm3tIuAJcWqdSsl5t9Q4+BG3pHE5OC/fEXry3Z 1B3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=QAFvSr5w; 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 h13-20020a17090ac38d00b0024dd283436dsi18442263pjt.54.2023.05.10.14.28.33; Wed, 10 May 2023 14:28:47 -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=QAFvSr5w; 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 S237034AbjEJVMo (ORCPT + 99 others); Wed, 10 May 2023 17:12:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236905AbjEJVMn (ORCPT ); Wed, 10 May 2023 17:12:43 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AB531FD9; Wed, 10 May 2023 14:12:42 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-33131d7a26eso54588065ab.0; Wed, 10 May 2023 14:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683753161; x=1686345161; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PoxYWqBDKCkglae/wVRmkD/Q+O27CAC7GMcB4xk3Kxc=; b=QAFvSr5wgoMG5tPGtXxtetTgQVI82X+nCX6TetzodfLfHHCbN/Ct2WkWTE/jcMtZbz 2pJJDoZfD23LMQnNw9eWr02eGSsSd3fLYlhiyGP40cuNXWBCgk3wgDDTl2A7GnOTMLHO tfJgn/VPTpWfMUafx7ocr/uKB+NzoiIkLg4piINxXmk3mUpSMtILiKbCSywAejLoMhbz pNr7LxEGa3M3tITk6YulFVrknOkp4eEanXq7fOx65YsFbHy8JaSgYYe0OE7r7vDfpiGd X+kv1QyaXfFTTPXLM4ITWgYRTGsda6Bo9tubMf+u/H2tPShwM2zAg9J+hMctnPCgZglJ UHfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683753161; x=1686345161; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PoxYWqBDKCkglae/wVRmkD/Q+O27CAC7GMcB4xk3Kxc=; b=P3f0K7FcEJ4BHknABK1a+1/XPF+PsvJ7+Tg7pGOto23e3g1z9ZkLJyj1bAi2PMcYoh 3Td7n8fWAtTtz0a04TJ+l3dapQq6OUxc6OA1HgRWrzsxVSu0Ko7ksRLtgOQQrt7UNCWZ Wxn+ANcxiaMJZ4WDrNJWoXAJjqjrzQ8Cp5QzMfIon4CWgCY5tUJRGg8Y0od2WeTx+z/R 5TJEaXyrQPyutsSGQFlVNmTp7Q5GNJH8/134gLwCeYMMSsaniMXexypYcWaW4lqIUuUs TcVqP9mmDHb+6aH7Ri6W813akVFwxK5EndnXVNVDERMTDQakzkU78Chplb2NUwIlC0LX ErBw== X-Gm-Message-State: AC+VfDxzHL1hm0MDIa7ZOa00Nt3rqDx4fJploa1DCy79XwnaYppv32+I MMjH0KjjEqFnTH0TCTY7Kx0= X-Received: by 2002:a92:d4ca:0:b0:331:96e5:678d with SMTP id o10-20020a92d4ca000000b0033196e5678dmr13353290ilm.21.1683753160952; Wed, 10 May 2023 14:12:40 -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 h4-20020a92c084000000b003317ebbc426sm1869030ile.47.2023.05.10.14.12.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 14:12:40 -0700 (PDT) From: Azeem Shaikh To: Hans de Goede Cc: linux-hardening@vger.kernel.org, Azeem Shaikh , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] vboxsf: Replace all non-returning strlcpy with strscpy Date: Wed, 10 May 2023 21:11:46 +0000 Message-ID: <20230510211146.3486600-1-azeemshaikh38@gmail.com> X-Mailer: git-send-email 2.40.1.521.gf1e218fcd8-goog 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 --- fs/vboxsf/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/vboxsf/super.c b/fs/vboxsf/super.c index d2f6df69f611..1fb8f4df60cb 100644 --- a/fs/vboxsf/super.c +++ b/fs/vboxsf/super.c @@ -176,7 +176,7 @@ static int vboxsf_fill_super(struct super_block *sb, struct fs_context *fc) } folder_name->size = size; folder_name->length = size - 1; - strlcpy(folder_name->string.utf8, fc->source, size); + strscpy(folder_name->string.utf8, fc->source, size); err = vboxsf_map_folder(folder_name, &sbi->root); kfree(folder_name); if (err) { -- 2.40.1.521.gf1e218fcd8-goog