* [PATCH] vhost-vdpa: honor CAP_IPC_LOCK
@ 2021-03-02 9:14 Jason Wang
2021-03-02 9:51 ` Michael S. Tsirkin
0 siblings, 1 reply; 3+ messages in thread
From: Jason Wang @ 2021-03-02 9:14 UTC (permalink / raw)
To: mst, jasowang, kvm; +Cc: virtualization, netdev, linux-kernel
When CAP_IPC_LOCK is set we should not check locked memory against
rlimit as what has been implemented in mlock().
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
drivers/vhost/vdpa.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index ef688c8c0e0e..e93572e2e344 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -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;
}
--
2.18.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] vhost-vdpa: honor CAP_IPC_LOCK
2021-03-02 9:14 [PATCH] vhost-vdpa: honor CAP_IPC_LOCK Jason Wang
@ 2021-03-02 9:51 ` Michael S. Tsirkin
2021-03-02 10:52 ` Jason Wang
0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2021-03-02 9:51 UTC (permalink / raw)
To: Jason Wang; +Cc: kvm, virtualization, netdev, linux-kernel
On Tue, Mar 02, 2021 at 04:14:18AM -0500, Jason Wang wrote:
> When CAP_IPC_LOCK is set we should not check locked memory against
> rlimit as what has been implemented in mlock().
>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
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?
> ---
> drivers/vhost/vdpa.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index ef688c8c0e0e..e93572e2e344 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -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;
> }
> --
> 2.18.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vhost-vdpa: honor CAP_IPC_LOCK
2021-03-02 9:51 ` Michael S. Tsirkin
@ 2021-03-02 10:52 ` Jason Wang
0 siblings, 0 replies; 3+ messages in thread
From: Jason Wang @ 2021-03-02 10:52 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: kvm, virtualization, netdev, linux-kernel
On 2021/3/2 5:51 下午, Michael S. Tsirkin wrote:
> On Tue, Mar 02, 2021 at 04:14:18AM -0500, Jason Wang wrote:
>> When CAP_IPC_LOCK is set we should not check locked memory against
>> rlimit as what has been implemented in mlock().
>>
>> Signed-off-by: Jason Wang <jasowang@redhat.com>
> 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?
Sure, V2 is posted.
Thanks
>
>> ---
>> drivers/vhost/vdpa.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
>> index ef688c8c0e0e..e93572e2e344 100644
>> --- a/drivers/vhost/vdpa.c
>> +++ b/drivers/vhost/vdpa.c
>> @@ -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;
>> }
>> --
>> 2.18.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-03 4:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-02 9:14 [PATCH] vhost-vdpa: honor CAP_IPC_LOCK Jason Wang
2021-03-02 9:51 ` Michael S. Tsirkin
2021-03-02 10:52 ` Jason Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).