From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795914929; b=fDlDcAEdr0KfwS2oZuCQT8dlJhIUA53ms3Ck624fJP1D6NrgW8uJq/QyYynszEUdd17i 8kn5HVZhvpEM+KrBiihNj6dh9MFBYyuNqo64Jk+i6PBBCqhL9AGtSSX0wd1U2qlx9u8ax MclR7wt1FhtxlLsxMlQt+eCkvdQwXGw35FvgeGuimeZLTCGANqcWlMOJqhC2k4Bf3jwiZ KntnXrFlDfcgpw0DUjfTKVnicaQE17TPRh2bKC1ohH/odIDh98QWPrgWt55a9gIUHED5t rVFvF1xXqjAJhb+r5wlupRiZrDRMB9aCiawpTxm0w3sRnhuRmJ98MRkcbJHOHxBSrsg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795914929; h=Received:DKIM-Signature:Message-ID:Subject:From:To:Cc:Date: In-Reply-To:References:Content-Type:Content-Transfer-Encoding: User-Agent:MIME-Version; bh=hzogYRbMN9Uotco67FgnUGaVbICxju5QKdo4nPcuutw=; b=1V7GEAPwpDULdhkR67kqswps7QmhmifeBHXhJV1jMB5F0dT9L9zGqamhF4CbwJCVh1CY /HVj8Dmlk8TvFgVMAI+Faib/n05SrFS6ON8ROHn0c1gnMDqvLgBpv1ZnuexotPuu8eeIu nMExPhRHBxiq9ThnTysGOabmeAcEDNoiXvx/jScvSlVOXqC2Ccp6L+IuhcTpnBPMS+jf7 UQy+RDnMTODbaeNyrR+/r0gdlZSU2wdoKILd+H+yzAyg7j8hJyeQjRh5jJOV3BjqoEQHV +c1MIW5wCl+tg2/W2cCxPUc3PcSMf3uwv8Db2Z57Vj0R+xUoCszWtxN/3JN+/VG4PyQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="Jy/oWhoU"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EF23606A31C; Sun, 29 Nov 2026 01:15:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Jy/oWhoU Received: by smtp.kernel.org (Postfix) with ESMTPSA id E21BE1F000C1; Sun, 29 Nov 2026 01:15:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795914929; bh=hzogYRbMN9Uotco67FgnUGaVbICxju5QKdo4nPcuutw=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Jy/oWhoUaevUs98rGYxXesVquDOGyLWeyR+qv2XIgqOh1rndKR3/aSnNChRDZ/wBM FBo7wbpzrXAGgWDMpDFJbq7vtSguWrM1dktLkmv/14KqBZbVT/D1j4tZg933gxJ7Ei RTFVcsuXpFzBT98lGcC3+wHUBc7p6wiOqalUnnYU07OyaDb1iHd+M9mSczj0VIeyRt TM9UrLZH7itu+ILTIjVlN6Xy2BBB5q8luZhW8/WaY0KpdvASXt1X/56pgWtypRquTS 6qeYPoXrZVoxsZKRfShXHvyIE7ur+uHLblIFDJUAHO5zLeItdFoc1PM8exHQkXnxGU Lq7ndLHKv34rg== Message-ID: <80c8d48380cf6e677f4414bd867546681d013d1d.camel@kernel.org> Subject: Re: [PATCH] NFS: clamp WRITE reply count to the requested count From: Trond Myklebust To: Cheng Yongkang , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sat, 28 Nov 2026 20:15:27 -0500 In-Reply-To: <20261025180311.349348-1-teel4res@gmail.com> References: <20261025180311.349348-1-teel4res@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.62.1 (3.62.1-1.fc45) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Sun, 2026-10-25 at 11:03 -0700, Cheng Yongkang wrote: > nfs_writeback_update_inode() uses the server's WRITE reply count for > the > size update before nfs_writeback_result() compares it with the > request. > That comparison only rejects a smaller count, so a server can return > a > count larger than the request, make nfs_writeback_check_extend() set > fattr->size beyond the requested extent, and grow the client inode's > i_size. >=20 > Clamp the reply count to args.count before the size update.=C2=A0 This > keeps > the attribute barrier and completion accounting within the write the > client actually issued. >=20 > The inflation was reproduced 3/3 times with a fake NFSv4.0 server > that > answered a 1-byte WRITE with count 0x40000000; with this clamp the > client keeps i_size at 1.=C2=A0 A reply with the requested count still > gives > i_size=3D1. >=20 > Assisted-by: LLM > Signed-off-by: Cheng Yongkang > --- > =C2=A0fs/nfs/write.c | 7 +++++++ > =C2=A01 file changed, 7 insertions(+) >=20 > diff --git a/fs/nfs/write.c b/fs/nfs/write.c > index 623e7ef..0dbcaeb 100644 > --- a/fs/nfs/write.c > +++ b/fs/nfs/write.c > @@ -1467,6 +1467,13 @@ void nfs_writeback_update_inode(struct > nfs_pgio_header *hdr) > =C2=A0=09struct nfs_fattr *fattr =3D &hdr->fattr; > =C2=A0=09struct inode *inode =3D hdr->inode; > =C2=A0 > +=09/* > +=09 * A server may report more bytes than the request asked > for.=C2=A0 Do not > +=09 * let that count extend the inode size or the attribute > barrier. > +=09 */ > +=09if (hdr->res.count > hdr->args.count) > +=09=09hdr->res.count =3D hdr->args.count; > + If your server reports that it wrote more bytes than than the client actually sent, then it is very, very broken. Do not use it! --=20 Trond Myklebust Linux NFS client maintainer, Hammerspace trondmy@kernel.org, trond.myklebust@hammerspace.com