From nobody Tue Jul 11 00:49:49 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4R0Mhs32Pmz4dQ7x; Tue, 11 Jul 2023 00:49:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4R0Mhs2Z0dz4GKV; Tue, 11 Jul 2023 00:49:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689036589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Vqj/2iLd4qW04AbeBEAXugsaJyU8QisMmScu81o+pZ4=; b=RdQzIdlYDzBEA4GP6fy265foDaEfiharFp+PegwIPjID0qMpSS9Qnebj4bw/z1bCK4YsFK Xt5N6lyGK4LcJndzYEcwKK0MvQcd7SJm1RirbkSJfRBiBBhZRzdnV9fn35IFy+9MjTw/Lm B6TIWro2R5wJQizbXkjofv72jVduL/rx6HwRxSNLxQ+PWBZ4Hy8VtpDMPF+naiOqfAkurp GhzNfHgdYbc3aG2aDr93siC/YcWINt0NJ8Yiq1ajTLushBe4ANrJ0zX++RHSl2F5Rxr8tJ fNZpkexyGX1orfHJbOLoajPgWZ+O8wiZ2mej1MxKEgwwDNBiHMNQEafKWLYpBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689036589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Vqj/2iLd4qW04AbeBEAXugsaJyU8QisMmScu81o+pZ4=; b=aA9kIoQnmZ+NAZZBcSDEuDDGpSWdguGFrmgec9Qb33uFKiGy7VhfUnM+VrKtjNuPY1YJ6V omTIlxa8t+jdBwwg8/NQPdTud9IfoF0LHRBLsjGcJg49BpEmcprHFNnGYX37Qb0ptqW247 Khd4m+1RzptAmNUj9Scf7dnGTGVSmgyLG5phvkUjtRJxY7BdstuojQP0voszHdoOGuI3cl 3Xwo32RU33NmRP4+5o3XdWdD5EHAtVHKydP92pJiS9+fAobGBmaguVwlIUzojLomf7UHpn zcwMxJd6ltmo1mASCSqo9gpGmeGqyO+hvVOEuDNLPQr/LJkV5a1OlwABXQNpFw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689036589; a=rsa-sha256; cv=none; b=wfb8RSxecBQA3IsbTpDTYv85banM+56n/5Nmbh7tbF90sAM0yyv3EMkmbJYFuIuGtx7cVU 7CmsoovtAbsj62M2EwRPl3aVVpMlSNtNYOnYFN9XLHVABVcIejFxqaJaUIxJNyhMSk27ps MfKiXLmLeCFRtWJoPDgCaC8JVup80pesLfye7QDQSaGcDeJcu03Oi32/PLQhh2q+jPoxu1 62joMfX1BmlUt+cWiPFdqLw7iqXGBX42XT1SzkUgtlO4spnk8HEaSod0jTZcbxvlcOwUdK +C6uJm41HGl5w5nLxGpTMn7xvAJCSHdCTvsg/rlroG+cMN4Mz0BVkAQmxo58oA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4R0Mhs1dMlz15Tv; Tue, 11 Jul 2023 00:49:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36B0nn2d082767; Tue, 11 Jul 2023 00:49:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36B0nnxN082765; Tue, 11 Jul 2023 00:49:49 GMT (envelope-from git) Date: Tue, 11 Jul 2023 00:49:49 GMT Message-Id: <202307110049.36B0nnxN082765@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 7e4c6b2163fb - main - msdosfs: zero partially valid extended cluster List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7e4c6b2163fbed6be92b1e19f0eec4da973cfaec Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7e4c6b2163fbed6be92b1e19f0eec4da973cfaec commit 7e4c6b2163fbed6be92b1e19f0eec4da973cfaec Author: Konstantin Belousov AuthorDate: 2023-07-06 01:51:07 +0000 Commit: Konstantin Belousov CommitDate: 2023-07-11 00:49:09 +0000 msdosfs: zero partially valid extended cluster It contains arbitrary garbage, which is not cleared by vfs_bio_clrbuf() which only zeroes invalid portions of the pages. Reported by: Maxim Suhanov Discussed with: so Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/fs/msdosfs/msdosfs_denode.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c index 7acd90c8e713..ce7058b3ae60 100644 --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -498,6 +498,7 @@ deextend(struct denode *dep, u_long length, struct ucred *cred) struct msdosfsmount *pmp = dep->de_pmp; struct vnode *vp = DETOV(dep); struct buf *bp; + off_t eof_clusteroff; u_long count; int error; @@ -536,13 +537,19 @@ deextend(struct denode *dep, u_long length, struct ucred *cred) * B_CACHE | B_DELWRI but with invalid pages, and cannot be * neither written out nor validated. * - * Fix it by proactively clearing extended pages. + * Fix it by proactively clearing extended pages. Need to do + * both vfs_bio_clrbuf() to mark pages valid, and to zero + * actual buffer content which might exist in the tail of the + * already valid cluster. */ error = bread(vp, de_cluster(pmp, dep->de_FileSize), pmp->pm_bpcluster, NOCRED, &bp); if (error != 0) goto rewind; vfs_bio_clrbuf(bp); + eof_clusteroff = de_cn2off(pmp, de_cluster(pmp, dep->de_FileSize)); + vfs_bio_bzero_buf(bp, dep->de_FileSize - eof_clusteroff, + pmp->pm_bpcluster - dep->de_FileSize + eof_clusteroff); if (!DOINGASYNC(vp)) (void)bwrite(bp); else if (vm_page_count_severe() || buf_dirty_count_severe())