From nobody Mon Jan 01 22:27:13 2024 X-Original-To: fs@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 4T3rFY4CRVz55kD5 for ; Mon, 1 Jan 2024 22:27:13 +0000 (UTC) (envelope-from bugzilla-noreply@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 4T3rFY1yL7z4SJD for ; Mon, 1 Jan 2024 22:27:13 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704148033; a=rsa-sha256; cv=none; b=Hu6kE1HhNC86/dN0mh99+JKS2cBueW9ZZa2bLMbFJM/xr+Yc8WTu5FRBJjeHQT5ccbqO0p +Tn7QbDHXUPOyXZ9czuzxk0pxlNfNvL5+/mdczBSstbwooT1OuXylm+/zyJBgKezqhU3IG KW5nIW8+N3mUHRbuOxPw2afcRDFJ/IgJeEQf0h9fW9EWpf04tKgcyTydR5a2uj2kHtRLHP ZqLnQWzXdlUD2/kBX4UOfFIZzNRN0LPIQSWjB5JBaIZgnCywWth3b6b1Sz8Dtu1o/JrcxD odmBZX7VAPHZ8HNuxsC7nsmhSFClzuRkAN2wR5f9aJiO4epUsYuEp21WolBhdA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704148033; 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: in-reply-to:in-reply-to:references:references; bh=k1tKpmIS8ClIRBamXxTMzexdatdlsYdlm4vS/boBIz0=; b=kd3c0wzsFB7K0u/U4xjfHUPb5nuaeObLCuViECyXnqkRZu0uNbRzJl1BidKfdgrNEvUFR1 pLse5zl7YwQFQ/VwaJr87rpqa8eDgMlDKl3uVDiWKwzi/4ta2y5GKqnswA6JljX91rRWfA B9nUaSujP5/rnmJNZIwXMwN2dDwl/2O+Rch3+vTpnKuWvtSJZSdGO8YeDoGD4CxPqbwteW cjyhnJI24Rf00GdZ/blpyR69YI6/sjIXDNGDCTfIzvNgjOI4ZLxIeJ7QkEGhR+FzuDif6V ZBAqonCpvhBZ44YoN6K3W6xaY+Sn/Yowy6RK2E8YgHzsFAXv/vzfB2rSgq4+aQ== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 4T3rFY0wQczbZh for ; Mon, 1 Jan 2024 22:27:13 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 401MRD3C082724 for ; Mon, 1 Jan 2024 22:27:13 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 401MRDMh082723 for fs@FreeBSD.org; Mon, 1 Jan 2024 22:27:13 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: fs@FreeBSD.org Subject: [Bug 276002] nfscl: data corruption using both copy_file_range and mmap'd I/O Date: Mon, 01 Jan 2024 22:27:13 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 15.0-CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: kib@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: fs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Filesystems List-Archive: https://lists.freebsd.org/archives/freebsd-fs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-fs@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D276002 --- Comment #38 from Konstantin Belousov --- (In reply to Rick Macklem from comment #34) This sounds as an interesting theory, but please note that read-ahead initiators in nfs_clbio.c checks that the B_CACHE buffer flag is not set. This should prevent a situation where we have constructed buffer with valid (might be dirty) pa= ges but not valid content recorded at buf cache layer. But lets recheck the theory anyway, the patch below should prevent RA when there are writeable mappings: commit 2234d9d4f7595a78bf10c08b1e6b12d2115799cd Author: Konstantin Belousov Date: Tue Jan 2 00:22:44 2024 +0200 nfsclient: do not do (unlocked) read-ahead by nfsiod if there are write= able mappings diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c index e6486af55daf..1f92fe0a4cf3 100644 --- a/sys/fs/nfsclient/nfs_clbio.c +++ b/sys/fs/nfsclient/nfs_clbio.c @@ -481,9 +481,13 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int iof= lag, struct ucred *cred) on =3D uio->uio_offset - (lbn * biosize); /* - * Start the read ahead(s), as required. + * Start the read ahead(s), as required. Do not do + * read-ahead if there are writeable mappings, since + * unlocked read by nfsiod could obliterate changes + * done by userspace. */ - if (nmp->nm_readahead > 0) { + if (nmp->nm_readahead > 0 && + vp->v_object->un_pager.vnp.writemappings =3D=3D 0) { for (nra =3D 0; nra < nmp->nm_readahead && nra < seqcou= nt && (off_t)(lbn + 1 + nra) * biosize < nsize; nra++) { rabn =3D lbn + 1 + nra; @@ -671,6 +675,7 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int iofl= ag, struct ucred *cred) */ NFSLOCKNODE(np); if (nmp->nm_readahead > 0 && + vp->v_object->un_pager.vnp.writemappings =3D=3D 0 && (bp->b_flags & B_INVAL) =3D=3D 0 && (np->n_direofoffset =3D=3D 0 || (lbn + 1) * NFS_DIRBLKSIZ < np->n_direofoffset) && --=20 You are receiving this mail because: You are the assignee for the bug.=