<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/drivers/virt, branch v5.10.36</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.10.36</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.10.36'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2021-05-11T12:47:11Z</updated>
<entry>
<title>nitro_enclaves: Fix stale file descriptors on failed usercopy</title>
<updated>2021-05-11T12:47:11Z</updated>
<author>
<name>Mathias Krause</name>
<email>minipli@grsecurity.net</email>
</author>
<published>2021-04-29T16:59:41Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=ed9cfd60c7875b0597e672e89c0bad09a88307d2'/>
<id>urn:sha1:ed9cfd60c7875b0597e672e89c0bad09a88307d2</id>
<content type='text'>
commit f1ce3986baa62cffc3c5be156994de87524bab99 upstream.

A failing usercopy of the slot uid will lead to a stale entry in the
file descriptor table as put_unused_fd() won't release it. This enables
userland to refer to a dangling 'file' object through that still valid
file descriptor, leading to all kinds of use-after-free exploitation
scenarios.

Exchanging put_unused_fd() for close_fd(), ksys_close() or alike won't
solve the underlying issue, as the file descriptor might have been
replaced in the meantime, e.g. via userland calling close() on it
(leading to a NULL pointer dereference in the error handling code as
'fget(enclave_fd)' will return a NULL pointer) or by dup2()'ing a
completely different file object to that very file descriptor, leading
to the same situation: a dangling file descriptor pointing to a freed
object -- just in this case to a file object of user's choosing.

Generally speaking, after the call to fd_install() the file descriptor
is live and userland is free to do whatever with it. We cannot rely on
it to still refer to our enclave object afterwards. In fact, by abusing
userfaultfd() userland can hit the condition without any racing and
abuse the error handling in the nitro code as it pleases.

To fix the above issues, defer the call to fd_install() until all
possible errors are handled. In this case it's just the usercopy, so do
it directly in ne_create_vm_ioctl() itself.

Signed-off-by: Mathias Krause &lt;minipli@grsecurity.net&gt;
Signed-off-by: Andra Paraschiv &lt;andraprs@amazon.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Link: https://lore.kernel.org/r/20210429165941.27020-2-andraprs@amazon.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>virt: vbox: Do not use wait_event_interruptible when called from kernel context</title>
<updated>2021-03-04T10:37:18Z</updated>
<author>
<name>Hans de Goede</name>
<email>hdegoede@redhat.com</email>
</author>
<published>2021-01-21T15:07:54Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a9f8345145809fd28c0c9e25e600efc5bf3464ac'/>
<id>urn:sha1:a9f8345145809fd28c0c9e25e600efc5bf3464ac</id>
<content type='text'>
commit c35901b39ddc20077f4ae7b9f7bf344487f62212 upstream.

Do not use wait_event_interruptible when vbg_hgcm_call() gets called from
kernel-context, such as it being called by the vboxsf filesystem code.

This fixes some filesystem related system calls on shared folders
unexpectedly failing with -EINTR.

Fixes: 0532a1b0d045 ("virt: vbox: Implement passing requestor info to the host for VirtualBox 6.0.x")
Reported-by: Ludovic Pouzenc &lt;bugreports@pouzenc.fr&gt;
Signed-off-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Link: https://lore.kernel.org/r/20210121150754.147598-1-hdegoede@redhat.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>nitro_enclaves: Fixup type and simplify logic of the poll mask setup</title>
<updated>2020-11-09T17:20:36Z</updated>
<author>
<name>Andra Paraschiv</name>
<email>andraprs@amazon.com</email>
</author>
<published>2020-11-02T17:36:22Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=d9109fe0f30a1fba66b8623837fc3d3c1a031090'/>
<id>urn:sha1:d9109fe0f30a1fba66b8623837fc3d3c1a031090</id>
<content type='text'>
Update the assigned value of the poll result to be EPOLLHUP instead of
POLLHUP to match the __poll_t type.

While at it, simplify the logic of setting the mask result of the poll
function.

Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Reviewed-by: Alexander Graf &lt;graf@amazon.com&gt;
Signed-off-by: Andra Paraschiv &lt;andraprs@amazon.com&gt;
Link: https://lore.kernel.org/r/20201102173622.32169-1-andraprs@amazon.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>virt: vbox: simplify the return expression of vbg_input_open()</title>
<updated>2020-10-02T09:36:13Z</updated>
<author>
<name>Qinglang Miao</name>
<email>miaoqinglang@huawei.com</email>
</author>
<published>2020-09-21T13:11:13Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=03c95e591a894a5213aed4e0f2c434df1047e595'/>
<id>urn:sha1:03c95e591a894a5213aed4e0f2c434df1047e595</id>
<content type='text'>
Simplify the return expression.

Reviewed-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Signed-off-by: Qinglang Miao &lt;miaoqinglang@huawei.com&gt;
Link: https://lore.kernel.org/r/20200921131113.93459-1-miaoqinglang@huawei.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>nitro_enclaves: Add Makefile for the Nitro Enclaves driver</title>
<updated>2020-09-22T11:58:41Z</updated>
<author>
<name>Andra Paraschiv</name>
<email>andraprs@amazon.com</email>
</author>
<published>2020-09-21T12:17:29Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=0f5c7b7484394e26afc07c063290fb43c4ba42c7'/>
<id>urn:sha1:0f5c7b7484394e26afc07c063290fb43c4ba42c7</id>
<content type='text'>
Add Makefile for the Nitro Enclaves driver, considering the option set
in the kernel config.

Changelog

v9 -&gt; v10

* Update commit message to include the changelog before the SoB tag(s).

v8 -&gt; v9

* Remove -Wall flags, could use W=1 as an option for this.

v7 -&gt; v8

* No changes.

v6 -&gt; v7

* No changes.

v5 -&gt; v6

* No changes.

v4 -&gt; v5

* No changes.

v3 -&gt; v4

* No changes.

v2 -&gt; v3

* Remove the GPL additional wording as SPDX-License-Identifier is
  already in place.

v1 -&gt; v2

* Update path to Makefile to match the drivers/virt/nitro_enclaves
  directory.

Reviewed-by: Alexander Graf &lt;graf@amazon.com&gt;
Signed-off-by: Andra Paraschiv &lt;andraprs@amazon.com&gt;
Link: https://lore.kernel.org/r/20200921121732.44291-16-andraprs@amazon.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>nitro_enclaves: Add Kconfig for the Nitro Enclaves driver</title>
<updated>2020-09-22T11:58:41Z</updated>
<author>
<name>Andra Paraschiv</name>
<email>andraprs@amazon.com</email>
</author>
<published>2020-09-21T12:17:28Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=07499cc661a926eb4ca19604502e3f0bda2aa4bf'/>
<id>urn:sha1:07499cc661a926eb4ca19604502e3f0bda2aa4bf</id>
<content type='text'>
Add kernel config entry for Nitro Enclaves, including dependencies.

Changelog

v9 -&gt; v10

* Update commit message to include the changelog before the SoB tag(s).

v8 -&gt; v9

* No changes.

v7 -&gt; v8

* No changes.

v6 -&gt; v7

* Remove, for now, the dependency on ARM64 arch. x86 is currently
  supported, with Arm to come afterwards. The NE kernel driver can be
  built for aarch64 arch.

v5 -&gt; v6

* No changes.

v4 -&gt; v5

* Add arch dependency for Arm / x86.

v3 -&gt; v4

* Add PCI and SMP dependencies.

v2 -&gt; v3

* Remove the GPL additional wording as SPDX-License-Identifier is
  already in place.

v1 -&gt; v2

* Update path to Kconfig to match the drivers/virt/nitro_enclaves
  directory.
* Update help in Kconfig.

Reviewed-by: Alexander Graf &lt;graf@amazon.com&gt;
Signed-off-by: Andra Paraschiv &lt;andraprs@amazon.com&gt;
Link: https://lore.kernel.org/r/20200921121732.44291-15-andraprs@amazon.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>nitro_enclaves: Add logic for terminating an enclave</title>
<updated>2020-09-22T11:58:41Z</updated>
<author>
<name>Andra Paraschiv</name>
<email>andraprs@amazon.com</email>
</author>
<published>2020-09-21T12:17:27Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9c8eb50fe9e2bb8a2e725979e052fbf592b6b799'/>
<id>urn:sha1:9c8eb50fe9e2bb8a2e725979e052fbf592b6b799</id>
<content type='text'>
An enclave is associated with an fd that is returned after the enclave
creation logic is completed. This enclave fd is further used to setup
enclave resources. Once the enclave needs to be terminated, the enclave
fd is closed.

Add logic for enclave termination, that is mapped to the enclave fd
release callback. Free the internal enclave info used for bookkeeping.

Changelog

v9 -&gt; v10

* Update commit message to include the changelog before the SoB tag(s).

v8 -&gt; v9

* Use the ne_devs data structure to get the refs for the NE PCI device.

v7 -&gt; v8

* No changes.

v6 -&gt; v7

* Remove the pci_dev_put() call as the NE misc device parent field is
  used now to get the NE PCI device.
* Update the naming and add more comments to make more clear the logic
  of handling full CPU cores and dedicating them to the enclave.

v5 -&gt; v6

* Update documentation to kernel-doc format.
* Use directly put_page() instead of unpin_user_pages(), to match the
  get_user_pages() calls.

v4 -&gt; v5

* Release the reference to the NE PCI device on enclave fd release.
* Adapt the logic to cpumask enclave vCPU ids and CPU cores.
* Remove sanity checks for situations that shouldn't happen, only if
  buggy system or broken logic at all.

v3 -&gt; v4

* Use dev_err instead of custom NE log pattern.

v2 -&gt; v3

* Remove the WARN_ON calls.
* Update static calls sanity checks.
* Update kzfree() calls to kfree().

v1 -&gt; v2

* Add log pattern for NE.
* Remove the BUG_ON calls.
* Update goto labels to match their purpose.
* Add early exit in release() if there was a slot alloc error in the fd
  creation path.

Reviewed-by: Alexander Graf &lt;graf@amazon.com&gt;
Signed-off-by: Alexandru Vasile &lt;lexnv@amazon.com&gt;
Signed-off-by: Andra Paraschiv &lt;andraprs@amazon.com&gt;
Link: https://lore.kernel.org/r/20200921121732.44291-14-andraprs@amazon.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>nitro_enclaves: Add logic for starting an enclave</title>
<updated>2020-09-22T11:58:41Z</updated>
<author>
<name>Andra Paraschiv</name>
<email>andraprs@amazon.com</email>
</author>
<published>2020-09-21T12:17:26Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=111c775a5f0dc8c509c31ccfbf2209ec545107a0'/>
<id>urn:sha1:111c775a5f0dc8c509c31ccfbf2209ec545107a0</id>
<content type='text'>
After all the enclave resources are set, the enclave is ready for
beginning to run.

Add ioctl command logic for starting an enclave after all its resources,
memory regions and CPUs, have been set.

The enclave start information includes the local channel addressing -
vsock CID - and the flags associated with the enclave.

Changelog

v9 -&gt; v10

* Update commit message to include the changelog before the SoB tag(s).

v8 -&gt; v9

* Use the ne_devs data structure to get the refs for the NE PCI device.

v7 -&gt; v8

* Add check for invalid enclave CID value e.g. well-known CIDs and
  parent VM CID.
* Add custom error code for incorrect flag in enclave start info and
  invalid enclave CID.

v6 -&gt; v7

* Update the naming and add more comments to make more clear the logic
  of handling full CPU cores and dedicating them to the enclave.

v5 -&gt; v6

* Check for invalid enclave start flags.
* Update documentation to kernel-doc format.

v4 -&gt; v5

* Add early exit on enclave start ioctl function call error.
* Move sanity checks in the enclave start ioctl function, outside of the
  switch-case block.
* Remove log on copy_from_user() / copy_to_user() failure.

v3 -&gt; v4

* Use dev_err instead of custom NE log pattern.
* Update the naming for the ioctl command from metadata to info.
* Check for minimum enclave memory size.

v2 -&gt; v3

* Remove the WARN_ON calls.
* Update static calls sanity checks.

v1 -&gt; v2

* Add log pattern for NE.
* Check if enclave state is init when starting an enclave.
* Remove the BUG_ON calls.

Reviewed-by: Alexander Graf &lt;graf@amazon.com&gt;
Signed-off-by: Alexandru Vasile &lt;lexnv@amazon.com&gt;
Signed-off-by: Andra Paraschiv &lt;andraprs@amazon.com&gt;
Link: https://lore.kernel.org/r/20200921121732.44291-13-andraprs@amazon.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>nitro_enclaves: Add logic for setting an enclave memory region</title>
<updated>2020-09-22T11:58:41Z</updated>
<author>
<name>Andra Paraschiv</name>
<email>andraprs@amazon.com</email>
</author>
<published>2020-09-21T12:17:25Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7dc9d4309fdb7773df13a17e203c16966676f21a'/>
<id>urn:sha1:7dc9d4309fdb7773df13a17e203c16966676f21a</id>
<content type='text'>
Another resource that is being set for an enclave is memory. User space
memory regions, that need to be backed by contiguous memory regions,
are associated with the enclave.

One solution for allocating / reserving contiguous memory regions, that
is used for integration, is hugetlbfs. The user space process that is
associated with the enclave passes to the driver these memory regions.

The enclave memory regions need to be from the same NUMA node as the
enclave CPUs.

Add ioctl command logic for setting user space memory region for an
enclave.

Changelog

v9 -&gt; v10

* Update commit message to include the changelog before the SoB tag(s).

v8 -&gt; v9

* Use the ne_devs data structure to get the refs for the NE PCI device.

v7 -&gt; v8

* Add early check, while getting user pages, to be multiple of 2 MiB for
  the pages that back the user space memory region.
* Add custom error code for incorrect user space memory region flag.
* Include in a separate function the sanity checks for each page of the
  user space memory region.

v6 -&gt; v7

* Update check for duplicate user space memory regions to cover
  additional possible scenarios.

v5 -&gt; v6

* Check for max number of pages allocated for the internal data
  structure for pages.
* Check for invalid memory region flags.
* Check for aligned physical memory regions.
* Update documentation to kernel-doc format.
* Check for duplicate user space memory regions.
* Use directly put_page() instead of unpin_user_pages(), to match the
  get_user_pages() calls.

v4 -&gt; v5

* Add early exit on set memory region ioctl function call error.
* Remove log on copy_from_user() failure.
* Exit without unpinning the pages on NE PCI dev request failure as
  memory regions from the user space range may have already been added.
* Add check for the memory region user space address to be 2 MiB
  aligned.
* Update logic to not have a hardcoded check for 2 MiB memory regions.

v3 -&gt; v4

* Check enclave memory regions are from the same NUMA node as the
  enclave CPUs.
* Use dev_err instead of custom NE log pattern.
* Update the NE ioctl call to match the decoupling from the KVM API.

v2 -&gt; v3

* Remove the WARN_ON calls.
* Update static calls sanity checks.
* Update kzfree() calls to kfree().

v1 -&gt; v2

* Add log pattern for NE.
* Update goto labels to match their purpose.
* Remove the BUG_ON calls.
* Check if enclave max memory regions is reached when setting an enclave
  memory region.
* Check if enclave state is init when setting an enclave memory region.

Reviewed-by: Alexander Graf &lt;graf@amazon.com&gt;
Signed-off-by: Alexandru Vasile &lt;lexnv@amazon.com&gt;
Signed-off-by: Andra Paraschiv &lt;andraprs@amazon.com&gt;
Link: https://lore.kernel.org/r/20200921121732.44291-12-andraprs@amazon.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>nitro_enclaves: Add logic for getting the enclave image load info</title>
<updated>2020-09-22T11:58:41Z</updated>
<author>
<name>Andra Paraschiv</name>
<email>andraprs@amazon.com</email>
</author>
<published>2020-09-21T12:17:24Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=988b7a471726209330b739adafc54563cbdbf986'/>
<id>urn:sha1:988b7a471726209330b739adafc54563cbdbf986</id>
<content type='text'>
Before setting the memory regions for the enclave, the enclave image
needs to be placed in memory. After the memory regions are set, this
memory cannot be used anymore by the VM, being carved out.

Add ioctl command logic to get the offset in enclave memory where to
place the enclave image. Then the user space tooling copies the enclave
image in the memory using the given memory offset.

Changelog

v9 -&gt; v10

* Update commit message to include the changelog before the SoB tag(s).

v8 -&gt; v9

* No changes.

v7 -&gt; v8

* Add custom error code for incorrect enclave image load info flag.

v6 -&gt; v7

* No changes.

v5 -&gt; v6

* Check for invalid enclave image load flags.

v4 -&gt; v5

* Check for the enclave not being started when invoking this ioctl call.
* Remove log on copy_from_user() / copy_to_user() failure.

v3 -&gt; v4

* Use dev_err instead of custom NE log pattern.
* Set enclave image load offset based on flags.
* Update the naming for the ioctl command from metadata to info.

v2 -&gt; v3

* No changes.

v1 -&gt; v2

* New in v2.

Reviewed-by: Alexander Graf &lt;graf@amazon.com&gt;
Signed-off-by: Andra Paraschiv &lt;andraprs@amazon.com&gt;
Link: https://lore.kernel.org/r/20200921121732.44291-11-andraprs@amazon.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
