Bug 1905208

Summary: CVE-2020-35513 kernel: fix nfsd failure to clear umask after processing an open or create [rhel-7]
Product: Red Hat Enterprise Linux 7 Reporter: J. Bruce Fields <bfields>
Component: kernelAssignee: J. Bruce Fields <bfields>
kernel sub component: NFS QA Contact: Murphy Zhou <xzhou>
Status: CLOSED ERRATA Docs Contact:
Severity: low    
Priority: low CC: allarkin, nmurray, plambri, rik.theys, rsable, xzhou, yieli, yoyang
Version: 7.9Keywords: Security, SecurityTracking, Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: kernel-3.10.0-1160.14.1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-02-02 12:00:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1904388, 1911309, 1911634    

Description J. Bruce Fields 2020-12-07 18:14:00 UTC
A new attribute was added to NFSv4.2 allowing clients to pass create mode and umask separately when creating new objects.  The server implemented tihs by setting the process umask before calling into the vfs to create the object.  Unfortunately, the server forgot to clear the umask afterwards.  The effect is that a later RPC processed by the same server thread could set the wrong permissions on a newly-created object.

The incorrect permissions will always be more restrictive than necessary, which may limit security impact.  Also, I don't think we've seen reports of users running into this.  Still, it seems like a pretty bad bug, affecting RHEL since 7.4.

Fixed by b5396f6101cb "nfsd: fix incorrect umasks", which backports easily.

Comment 3 J. Bruce Fields 2020-12-08 18:04:25 UTC
*** Bug 1903303 has been marked as a duplicate of this bug. ***

Comment 4 J. Bruce Fields 2020-12-08 18:11:32 UTC
(In reply to J. Bruce Fields from comment #0)
> Also, I don't think we've seen reports of
> users running into this.

I take that back, see bug 1903303.

To reproduce this you need client processes using a mixture of different umasks, I wonder how frequent that is in typical environments.  You also need a mixture of 4.2 and non-4.2 clients.  I think we'll be seeing more of this as people upgrade.  So this should be backported to z-stream.

Comment 5 Rik Theys 2020-12-08 20:47:16 UTC
Hi,

(In reply to J. Bruce Fields from comment #10 of bug 1903303)
> > That could explain why I couldn't trigger it on another server. The 4.2
> > traffic setting the umask must be hitting the server at the right time to
> > trigger this?
> 
> Right.  A non-NFSv4.2 create may end up applying the umask of a previous
> NFSv4.2 create.

If that's really what is happening, it's strange that the resulting umask getting applied is always removing access for the owner of the file. That's a _very_ unlikely umask to be using, no?
In my case, the resulting permissions were 0. I really doubt any of our users is using a umask that removes their own permissions and is generating enough traffic to trigger this so easily. Or am I missing something?

So while it seems plausible it's this bug, I'm not 100% convinced.

In our environment, users access their home directory over NFS so having a mixture of umasks is not that unlikely. We have clients running CentOS 7, 8 and Fedora, so different NFS versions.


Regards,
Rik

Comment 7 J. Bruce Fields 2020-12-09 15:13:40 UTC
(In reply to Rik Theys from comment #5)
> (In reply to J. Bruce Fields from comment #10 of bug 1903303)
> > Right.  A non-NFSv4.2 create may end up applying the umask of a previous
> > NFSv4.2 create.
> 
> If that's really what is happening, it's strange that the resulting umask
> getting applied is always removing access for the owner of the file. That's
> a _very_ unlikely umask to be using, no?

Traditionally (before the new NFSv4.2 feature), the client applies the umask before it sends the OPEN or CREATE.  With this bug, the server is applying a *second* umask, masking out additional bits.

> In our environment, users access their home directory over NFS so having a
> mixture of umasks is not that unlikely. We have clients running CentOS 7, 8
> and Fedora, so different NFS versions.

Thanks for the additional background.

Comment 11 Augusto Caringi 2020-12-21 21:05:08 UTC
Patch(es) committed on kernel-3.10.0-1160.14.1.el7

Comment 18 Alex 2021-01-24 11:44:13 UTC
*** Bug 1911634 has been marked as a duplicate of this bug. ***

Comment 19 Alex 2021-01-24 11:46:42 UTC
*** Bug 1911635 has been marked as a duplicate of this bug. ***

Comment 20 Alex 2021-01-24 11:47:59 UTC
*** Bug 1911636 has been marked as a duplicate of this bug. ***

Comment 24 errata-xmlrpc 2021-02-02 12:00:57 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: kernel security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:0336