vhost-vdpa: honor CAP_IPC_LOCK
Subsystems (5)
PATCH 1/1 vhost-vdpa: honor CAP_IPC_LOCK
When CAP_IPC_LOCK is set we should not check locked memory against rlimit as what has been implemented in mlock().
--- drivers/vhost/vdpa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/vhost/vdpa.c +2 -1
@@ -638,7 +638,8 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,mmap_read_lock (dev->mm); lock_limit =rlimit (RLIMIT_MEMLOCK ) >>PAGE_SHIFT ; -if (npages +atomic64_read (&dev->mm->pinned_vm) > lock_limit) { +if (!capable (CAP_IPC_LOCK ) && + (npages +atomic64_read (&dev->mm->pinned_vm) > lock_limit)) { ret = -ENOMEM ; goto unlock; }
Signature · 6 lines
2.18.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerQuoted 4 lines · Jason Wang
When
CAP_IPC_LOCKis set we should not check locked memory against rlimit as what has been implemented inmlock().Signed-off-by Jason Wang <[email protected]>
Indeed and it's not just mlock.
Documentation/admin-guide/perf-security.rst:
RLIMIT_MEMLOCK and perf_event_mlock_kb resource constraints are ignored for processes with the CAP_IPC_LOCK capability.
and let's add a Fixes: tag?
Quoted 20 lines
--- drivers/vhost/vdpa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/vhost/vdpa.c +2
-1@@ -638,7 +638,8 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,mmap_read_lock (dev->mm); lock_limit =rlimit (RLIMIT_MEMLOCK ) >>PAGE_SHIFT ; -if (npages +atomic64_read (&dev->mm->pinned_vm) > lock_limit) { +if (!capable (CAP_IPC_LOCK ) && + (npages +atomic64_read (&dev->mm->pinned_vm) > lock_limit)) { ret = -ENOMEM ; goto unlock; }Signature · 1 line
2.18.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 5 lines · Michael S. Tsirkin
Quoted 4 lines · Jason Wang
When
CAP_IPC_LOCKis set we should not check locked memory against rlimit as what has been implemented inmlock().Signed-off-by Jason Wang <[email protected]>
Quoted 8 lines
Indeed and it's not just mlock.
Documentation/admin-guide/perf-security.rst:
RLIMIT_MEMLOCKandperf_event_mlock_kbresource constraints are ignored for processes with theCAP_IPC_LOCKcapability.and let's add a Fixes: tag?
Sure, V2 is posted.
Thanks
Quoted 12 lines
Quoted 12 lines
--- drivers/vhost/vdpa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/vhost/vdpa.c +0
-0@@ -638,7 +638,8 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,mmap_read_lock (dev->mm);
Quoted 9 lines
Quoted 9 lines
drivers/vhost/vdpa.c +2
-1lock_limit =rlimit (RLIMIT_MEMLOCK ) >>PAGE_SHIFT ; -if (npages +atomic64_read (&dev->mm->pinned_vm) > lock_limit) { +if (!capable (CAP_IPC_LOCK ) && + (npages +atomic64_read (&dev->mm->pinned_vm) > lock_limit)) { ret = -ENOMEM ; goto unlock; }Signature · 1 line
2.18.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization