From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org
Subject: Re: [PATCH] vhost-vdpa: honor CAP_IPC_LOCK
Date: Tue, 2 Mar 2021 04:51:23 -0500 [thread overview]
Message-ID: <20210302044918-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20210302091418.7226-1-jasowang@redhat.com>
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
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vhost-vdpa: honor CAP_IPC_LOCK
Date: Tue, 2 Mar 2021 04:51:23 -0500 [thread overview]
Message-ID: <20210302044918-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20210302091418.7226-1-jasowang@redhat.com>
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
next prev parent reply other threads:[~2021-03-02 9:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-02 9:14 [PATCH] vhost-vdpa: honor CAP_IPC_LOCK Jason Wang
2021-03-02 9:14 ` Jason Wang
2021-03-02 9:51 ` Michael S. Tsirkin [this message]
2021-03-02 9:51 ` Michael S. Tsirkin
2021-03-02 10:52 ` Jason Wang
2021-03-02 10:52 ` Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210302044918-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.