virtiofsd: stay below fs.file-max sysctl value (CVE-2020-10717)
authorStefan Hajnoczi <stefanha@redhat.com>
Fri, 1 May 2020 14:06:44 +0000 (15:06 +0100)
committerDr. David Alan Gilbert <dgilbert@redhat.com>
Fri, 1 May 2020 17:41:56 +0000 (18:41 +0100)
commit8c1d353d107b4fc344e27f2f08ea7fa25de2eea2
treebb20ce88beefdd687a4c4eac62820dbaafe8c1d6
parent6dbb716877728ce4eb51619885ef6ef4ada9565f
virtiofsd: stay below fs.file-max sysctl value (CVE-2020-10717)

The system-wide fs.file-max sysctl value determines how many files can
be open.  It defaults to a value calculated based on the machine's RAM
size.  Previously virtiofsd would try to set RLIMIT_NOFILE to 1,000,000
and this allowed the FUSE client to exhaust the number of open files
system-wide on Linux hosts with less than 10 GB of RAM!

Take fs.file-max into account when choosing the default RLIMIT_NOFILE
value.

Fixes: CVE-2020-10717
Reported-by: Yuval Avrahami <yavrahami@paloaltonetworks.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20200501140644.220940-3-stefanha@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
tools/virtiofsd/helper.c