<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/nfs/direct.c, branch linux-6.7.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.7.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.7.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2024-04-03T13:11:21Z</updated>
<entry>
<title>nfs: fix UAF in direct writes</title>
<updated>2024-04-03T13:11:21Z</updated>
<author>
<name>Josef Bacik</name>
</author>
<published>2024-03-01T16:49:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1daf52b5ffb24870fbeda20b4967526d8f9e12ab'/>
<id>urn:sha1:1daf52b5ffb24870fbeda20b4967526d8f9e12ab</id>
<content type='text'>
[ Upstream commit 17f46b803d4f23c66cacce81db35fef3adb8f2af ]

In production we have been hitting the following warning consistently

------------[ cut here ]------------
refcount_t: underflow; use-after-free.
WARNING: CPU: 17 PID: 1800359 at lib/refcount.c:28 refcount_warn_saturate+0x9c/0xe0
Workqueue: nfsiod nfs_direct_write_schedule_work [nfs]
RIP: 0010:refcount_warn_saturate+0x9c/0xe0
PKRU: 55555554
Call Trace:
 &lt;TASK&gt;
 ? __warn+0x9f/0x130
 ? refcount_warn_saturate+0x9c/0xe0
 ? report_bug+0xcc/0x150
 ? handle_bug+0x3d/0x70
 ? exc_invalid_op+0x16/0x40
 ? asm_exc_invalid_op+0x16/0x20
 ? refcount_warn_saturate+0x9c/0xe0
 nfs_direct_write_schedule_work+0x237/0x250 [nfs]
 process_one_work+0x12f/0x4a0
 worker_thread+0x14e/0x3b0
 ? ZSTD_getCParams_internal+0x220/0x220
 kthread+0xdc/0x120
 ? __btf_name_valid+0xa0/0xa0
 ret_from_fork+0x1f/0x30

This is because we're completing the nfs_direct_request twice in a row.

The source of this is when we have our commit requests to submit, we
process them and send them off, and then in the completion path for the
commit requests we have

if (nfs_commit_end(cinfo.mds))
	nfs_direct_write_complete(dreq);

However since we're submitting asynchronous requests we sometimes have
one that completes before we submit the next one, so we end up calling
complete on the nfs_direct_request twice.

The only other place we use nfs_generic_commit_list() is in
__nfs_commit_inode, which wraps this call in a

nfs_commit_begin();
nfs_commit_end();

Which is a common pattern for this style of completion handling, one
that is also repeated in the direct code with get_dreq()/put_dreq()
calls around where we process events as well as in the completion paths.

Fix this by using the same pattern for the commit requests.

Before with my 200 node rocksdb stress running this warning would pop
every 10ish minutes.  With my patch the stress test has been running for
several hours without popping.

Signed-off-by: Josef Bacik &lt;josef@toxicpanda.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>pNFS: Fix the pnfs block driver's calculation of layoutget size</title>
<updated>2024-01-25T23:44:44Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2023-11-17T11:25:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a075613766994c8673c1f2d3cd05d86baa5dd233'/>
<id>urn:sha1:a075613766994c8673c1f2d3cd05d86baa5dd233</id>
<content type='text'>
[ Upstream commit 8a6291bf3b0eae1bf26621e6419a91682f2d6227 ]

Instead of relying on the value of the 'bytes_left' field, we should
calculate the layout size based on the offset of the request that is
being written out.

Reported-by: Benjamin Coddington &lt;bcodding@redhat.com&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
Fixes: 954998b60caa ("NFS: Fix error handling for O_DIRECT write scheduling")
Reviewed-by: Benjamin Coddington &lt;bcodding@redhat.com&gt;
Tested-by: Benjamin Coddington &lt;bcodding@redhat.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>NFS: More fixes for nfs_direct_write_reschedule_io()</title>
<updated>2023-09-13T15:51:11Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2023-09-04T16:34:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b11243f720ee5f9376861099019c8542969b6318'/>
<id>urn:sha1:b11243f720ee5f9376861099019c8542969b6318</id>
<content type='text'>
Ensure that all requests are put back onto the commit list so that they
can be rescheduled.

Fixes: 4daaeba93822 ("NFS: Fix nfs_direct_write_reschedule_io()")
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>NFS: Use the correct commit info in nfs_join_page_group()</title>
<updated>2023-09-13T15:51:11Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2023-09-04T16:34:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b193a78ddb5ee7dba074d3f28dc050069ba083c0'/>
<id>urn:sha1:b193a78ddb5ee7dba074d3f28dc050069ba083c0</id>
<content type='text'>
Ensure that nfs_clear_request_commit() updates the correct counters when
it removes them from the commit list.

Fixes: ed5d588fe47f ("NFS: Try to join page groups before an O_DIRECT retransmission")
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>NFS: More O_DIRECT accounting fixes for error paths</title>
<updated>2023-09-13T15:51:10Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2023-09-04T16:34:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8982f7aff39fb526aba4441fff2525fcedd5e1a3'/>
<id>urn:sha1:8982f7aff39fb526aba4441fff2525fcedd5e1a3</id>
<content type='text'>
If we hit a fatal error when retransmitting, we do need to record the
removal of the request from the count of written bytes.

Fixes: 031d73ed768a ("NFS: Fix O_DIRECT accounting of number of bytes read/written")
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>NFS: Fix O_DIRECT locking issues</title>
<updated>2023-09-13T15:50:57Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2023-09-04T16:34:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7c6339322ce0c6128acbe36aacc1eeb986dd7bf1'/>
<id>urn:sha1:7c6339322ce0c6128acbe36aacc1eeb986dd7bf1</id>
<content type='text'>
The dreq fields are protected by the dreq-&gt;lock.

Fixes: 954998b60caa ("NFS: Fix error handling for O_DIRECT write scheduling")
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>NFS: Fix error handling for O_DIRECT write scheduling</title>
<updated>2023-09-11T15:29:38Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2023-09-04T16:34:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=954998b60caa8f2a3bf3abe490de6f08d283687a'/>
<id>urn:sha1:954998b60caa8f2a3bf3abe490de6f08d283687a</id>
<content type='text'>
If we fail to schedule a request for transmission, there are 2
possibilities:
1) Either we hit a fatal error, and we just want to drop the remaining
   requests on the floor.
2) We were asked to try again, in which case we should allow the
   outstanding RPC calls to complete, so that we can recoalesce requests
   and try again.

Fixes: d600ad1f2bdb ("NFS41: pop some layoutget errors to application")
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>NFS: Fix a potential data corruption</title>
<updated>2023-08-24T17:24:15Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2023-08-19T21:22:14Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=88975a55969e11f26fe3846bf4fbf8e7dc8cbbd4'/>
<id>urn:sha1:88975a55969e11f26fe3846bf4fbf8e7dc8cbbd4</id>
<content type='text'>
We must ensure that the subrequests are joined back into the head before
we can retransmit a request. If the head was not on the commit lists,
because the server wrote it synchronously, we still need to add it back
to the retransmission list.
Add a call that mirrors the effect of nfs_cancel_remove_inode() for
O_DIRECT.

Fixes: ed5d588fe47f ("NFS: Try to join page groups before an O_DIRECT retransmission")
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>NFS: Fix a use after free in nfs_direct_join_group()</title>
<updated>2023-08-17T13:30:38Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2023-08-09T01:17:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=be2fd1560eb57b7298aa3c258ddcca0d53ecdea3'/>
<id>urn:sha1:be2fd1560eb57b7298aa3c258ddcca0d53ecdea3</id>
<content type='text'>
Be more careful when tearing down the subrequests of an O_DIRECT write
as part of a retransmission.

Reported-by: Chris Mason &lt;clm@fb.com&gt;
Fixes: ed5d588fe47f ("NFS: Try to join page groups before an O_DIRECT retransmission")
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
</content>
</entry>
<entry>
<title>NFS: Clean up O_DIRECT request allocation</title>
<updated>2023-02-14T19:22:33Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2023-01-19T21:33:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=70e9db69f927bb378db9aaa807cc83ae550779a9'/>
<id>urn:sha1:70e9db69f927bb378db9aaa807cc83ae550779a9</id>
<content type='text'>
Rather than adjusting the index+offset after the call to
nfs_create_request(), add a function nfs_page_create_from_page() that
takes an offset.

Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
</feed>
