<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/nfs/dir.c, branch linux-4.4.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.4.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.4.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2020-10-14T07:46:20Z</updated>
<entry>
<title>nfs: Fix security label length not being reset</title>
<updated>2020-10-14T07:46:20Z</updated>
<author>
<name>Jeffrey Mitchell</name>
</author>
<published>2020-09-15T21:42:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c8bf391fcdd18466363d493922a9ba500aeb17fd'/>
<id>urn:sha1:c8bf391fcdd18466363d493922a9ba500aeb17fd</id>
<content type='text'>
[ Upstream commit d33030e2ee3508d65db5644551435310df86010e ]

nfs_readdir_page_filler() iterates over entries in a directory, reusing
the same security label buffer, but does not reset the buffer's length.
This causes decode_attr_security_label() to return -ERANGE if an entry's
security label is longer than the previous one's. This error, in
nfs4_decode_dirent(), only gets passed up as -EAGAIN, which causes another
failed attempt to copy into the buffer. The second error is ignored and
the remaining entries do not show up in ls, specifically the getdents64()
syscall.

Reproduce by creating multiple files in NFS and giving one of the later
files a longer security label. ls will not see that file nor any that are
added afterwards, though they will exist on the backend.

In nfs_readdir_page_filler(), reset security label buffer length before
every reuse

Signed-off-by: Jeffrey Mitchell &lt;jeffrey.mitchell@starlab.io&gt;
Fixes: b4487b935452 ("nfs: Fix getxattr kernel panic and memory overflow")
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>NFS: Remove superfluous kmap in nfs_readdir_xdr_to_array</title>
<updated>2020-03-20T08:06:18Z</updated>
<author>
<name>Petr Malat</name>
</author>
<published>2020-03-13T20:24:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=dc369d74c17ed41154ee7419cb94512c4757e9f6'/>
<id>urn:sha1:dc369d74c17ed41154ee7419cb94512c4757e9f6</id>
<content type='text'>
Array is mapped by nfs_readdir_get_array(), the further kmap is a result
of a bad merge and should be removed.

This resource leakage can be exploited for DoS by receptively reading
a content of a directory on NFS (e.g. by running ls).

Fixes: 67a56e9743171 ("NFS: Fix memory leaks and corruption in readdir")
Signed-off-by: Petr Malat &lt;oss@malat.biz&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>NFS: Directory page cache pages need to be locked when read</title>
<updated>2020-02-14T21:29:59Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2020-02-02T22:53:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a93b2fce19d7331f9f19d1abb9a534ffa94e3476'/>
<id>urn:sha1:a93b2fce19d7331f9f19d1abb9a534ffa94e3476</id>
<content type='text'>
[ Upstream commit 114de38225d9b300f027e2aec9afbb6e0def154b ]

When a NFS directory page cache page is removed from the page cache,
its contents are freed through a call to nfs_readdir_clear_array().
To prevent the removal of the page cache entry until after we've
finished reading it, we must take the page lock.

Fixes: 11de3b11e08c ("NFS: Fix a memory leak in nfs_readdir")
Cc: stable@vger.kernel.org # v2.6.37+
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
Reviewed-by: Benjamin Coddington &lt;bcodding@redhat.com&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: Fix bool initialization/comparison</title>
<updated>2020-02-14T21:29:59Z</updated>
<author>
<name>Thomas Meyer</name>
</author>
<published>2017-10-07T14:02:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9818f3668fa1ee489c921966d4fd61e5ef2213bd'/>
<id>urn:sha1:9818f3668fa1ee489c921966d4fd61e5ef2213bd</id>
<content type='text'>
[ Upstream commit 6089dd0d731028531fb1148be9fd33274ff90da4 ]

Bool initializations should use true and false. Bool tests don't need
comparisons.

Signed-off-by: Thomas Meyer &lt;thomas@m3y3r.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: Fix memory leaks and corruption in readdir</title>
<updated>2020-02-14T21:29:59Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2020-02-02T22:53:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0b0223f9c3a82bec63a41f2b85029ef2bdae76d4'/>
<id>urn:sha1:0b0223f9c3a82bec63a41f2b85029ef2bdae76d4</id>
<content type='text'>
[ Upstream commit 4b310319c6a8ce708f1033d57145e2aa027a883c ]

nfs_readdir_xdr_to_array() must not exit without having initialised
the array, so that the page cache deletion routines can safely
call nfs_readdir_clear_array().
Furthermore, we should ensure that if we exit nfs_readdir_filler()
with an error, we free up any page contents to prevent a leak
if we try to fill the page again.

Fixes: 11de3b11e08c ("NFS: Fix a memory leak in nfs_readdir")
Cc: stable@vger.kernel.org # v2.6.37+
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
Reviewed-by: Benjamin Coddington &lt;bcodding@redhat.com&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: Fix a typo in nfs_rename()</title>
<updated>2017-12-16T09:33:55Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2017-11-06T20:28:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c02608144e79ab71f5121937fc95521f131d5447'/>
<id>urn:sha1:c02608144e79ab71f5121937fc95521f131d5447</id>
<content type='text'>
[ Upstream commit d803224c84be067754db7fa58a93f36f61566493 ]

On successful rename, the "old_dentry" is retained and is attached to
the "new_dir", so we need to call nfs_set_verifier() accordingly.

Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>NFS: revalidate "." etc correctly on "open".</title>
<updated>2017-12-05T10:22:51Z</updated>
<author>
<name>NeilBrown</name>
</author>
<published>2017-08-25T07:34:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a61474fa8749f67ef18aa2104b48b0b56ea654b7'/>
<id>urn:sha1:a61474fa8749f67ef18aa2104b48b0b56ea654b7</id>
<content type='text'>
commit b688741cb06695312f18b730653d6611e1bad28d upstream.

For correct close-to-open semantics, NFS must validate
the change attribute of a directory (or file) on open.

Since commit ecf3d1f1aa74 ("vfs: kill FS_REVAL_DOT by adding a
d_weak_revalidate dentry op"), open() of "." or a path ending ".." is
not revalidated reliably (except when that direct is a mount point).

Prior to that commit, "." was revalidated using nfs_lookup_revalidate()
which checks the LOOKUP_OPEN flag and forces revalidation if the flag is
set.
Since that commit, nfs_weak_revalidate() is used for NFSv3 (which
ignores the flags) and nothing is used for NFSv4.

This is fixed by using nfs_lookup_verify_inode() in
nfs_weak_revalidate().  This does the revalidation exactly when needed.
Also, add a definition of .d_weak_revalidate for NFSv4.

The incorrect behavior is easily demonstrated by running "echo *" in
some non-mountpoint NFS directory while watching network traffic.
Without this patch, "echo *" sometimes doesn't produce any traffic.
With the patch it always does.

Fixes: ecf3d1f1aa74 ("vfs: kill FS_REVAL_DOT by adding a d_weak_revalidate dentry op")
cc: stable@vger.kernel.org (3.9+)
Signed-off-by: NeilBrown &lt;neilb@suse.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>NFS: only invalidate dentrys that are clearly invalid.</title>
<updated>2017-07-27T22:06:08Z</updated>
<author>
<name>NeilBrown</name>
</author>
<published>2017-07-05T02:22:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d2fa4057b11eaad41716c612ceb9338aa634c4eb'/>
<id>urn:sha1:d2fa4057b11eaad41716c612ceb9338aa634c4eb</id>
<content type='text'>
commit cc89684c9a265828ce061037f1f79f4a68ccd3f7 upstream.

Since commit bafc9b754f75 ("vfs: More precise tests in d_invalidate")
in v3.18, a return of '0' from -&gt;d_revalidate() will cause the dentry
to be invalidated even if it has filesystems mounted on or it or on a
descendant.  The mounted filesystem is unmounted.

This means we need to be careful not to return 0 unless the directory
referred to truly is invalid.  So -ESTALE or -ENOENT should invalidate
the directory.  Other errors such a -EPERM or -ERESTARTSYS should be
returned from -&gt;d_revalidate() so they are propagated to the caller.

A particular problem can be demonstrated by:

1/ mount an NFS filesystem using NFSv3 on /mnt
2/ mount any other filesystem on /mnt/foo
3/ ls /mnt/foo
4/ turn off network, or otherwise make the server unable to respond
5/ ls /mnt/foo &amp;
6/ cat /proc/$!/stack # note that nfs_lookup_revalidate is in the call stack
7/ kill -9 $! # this results in -ERESTARTSYS being returned
8/ observe that /mnt/foo has been unmounted.

This patch changes nfs_lookup_revalidate() to only treat
  -ESTALE from nfs_lookup_verify_inode() and
  -ESTALE or -ENOENT from -&gt;lookup()
as indicating an invalid inode.  Other errors are returned.

Also nfs_check_inode_attributes() is changed to return -ESTALE rather
than -EIO.  This is consistent with the error returned in similar
circumstances from nfs_update_inode().

As this bug allows any user to unmount a filesystem mounted on an NFS
filesystem, this fix is suitable for stable kernels.

Fixes: bafc9b754f75 ("vfs: More precise tests in d_invalidate")
Signed-off-by: NeilBrown &lt;neilb@suse.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>NFSv4: Don't perform cached access checks before we've OPENed the file</title>
<updated>2017-06-14T11:16:26Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2015-12-27T02:54:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e8a1086ae191d157598b596909bb95aa95f22af4'/>
<id>urn:sha1:e8a1086ae191d157598b596909bb95aa95f22af4</id>
<content type='text'>
commit 762674f86d0328d5dc923c966e209e1ee59663f2 upstream.

Donald Buczek reports that a nfs4 client incorrectly denies
execute access based on outdated file mode (missing 'x' bit).
After the mode on the server is 'fixed' (chmod +x) further execution
attempts continue to fail, because the nfs ACCESS call updates
the access parameter but not the mode parameter or the mode in
the inode.

The root cause is ultimately that the VFS is calling may_open()
before the NFS client has a chance to OPEN the file and hence revalidate
the access and attribute caches.

Al Viro suggests:
&gt;&gt;&gt; Make nfs_permission() relax the checks when it sees MAY_OPEN, if you know
&gt;&gt;&gt; that things will be caught by server anyway?
&gt;&gt;
&gt;&gt; That can work as long as we're guaranteed that everything that calls
&gt;&gt; inode_permission() with MAY_OPEN on a regular file will also follow up
&gt;&gt; with a vfs_open() or dentry_open() on success. Is this always the
&gt;&gt; case?
&gt;
&gt; 1) in do_tmpfile(), followed by do_dentry_open() (not reachable by NFS since
&gt; it doesn't have -&gt;tmpfile() instance anyway)
&gt;
&gt; 2) in atomic_open(), after the call of -&gt;atomic_open() has succeeded.
&gt;
&gt; 3) in do_last(), followed on success by vfs_open()
&gt;
&gt; That's all.  All calls of inode_permission() that get MAY_OPEN come from
&gt; may_open(), and there's no other callers of that puppy.

Reported-by: Donald Buczek &lt;buczek@molgen.mpg.de&gt;
Link: https://bugzilla.kernel.org/show_bug.cgi?id=109771
Link: http://lkml.kernel.org/r/1451046656-26319-1-git-send-email-buczek@molgen.mpg.de
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Signed-off-by: Paul Menzel &lt;pmenzel@molgen.mpg.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>NFS: Ensure we revalidate attributes before using execute_ok()</title>
<updated>2017-06-14T11:16:26Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2015-12-29T00:30:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=53302082836607e38d4cb7e239dbd77ff5d8b137'/>
<id>urn:sha1:53302082836607e38d4cb7e239dbd77ff5d8b137</id>
<content type='text'>
commit 5c5fc09a1157a11dbe84e6421c3e0b37d05238cb upstream.

Donald Buczek reports that NFS clients can also report incorrect
results for access() due to lack of revalidation of attributes
before calling execute_ok().
Looking closely, it seems chdir() is afflicted with the same problem.

Fix is to ensure we call nfs_revalidate_inode_rcu() or
nfs_revalidate_inode() as appropriate before deciding to trust
execute_ok().

Reported-by: Donald Buczek &lt;buczek@molgen.mpg.de&gt;
Link: http://lkml.kernel.org/r/1451331530-3748-1-git-send-email-buczek@molgen.mpg.de
Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Signed-off-by: Paul Menzel &lt;pmenzel@molgen.mpg.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
