Re: [PATCH 3/3] vhost: pass kthread user to check RLIMIT_NPROC

From: Mike Christie
Date: Thu Jun 24 2021 - 12:19:16 EST


On 6/24/21 3:26 AM, kernel test robot wrote:
>>> drivers/vhost/vhost.c:599:57: sparse: sparse: dereference of noderef expression
> vim +599 drivers/vhost/vhost.c
>
> 581
> 582 /* Caller should have device mutex */
> 583 long vhost_dev_set_owner(struct vhost_dev *dev)
> 584 {
> 585 struct task_struct *worker;
> 586 int err;
> 587
> 588 /* Is there an owner already? */
> 589 if (vhost_dev_has_owner(dev)) {
> 590 err = -EBUSY;
> 591 goto err_mm;
> 592 }
> 593
> 594 vhost_attach_mm(dev);
> 595
> 596 dev->kcov_handle = kcov_common_handle();
> 597 if (dev->use_worker) {
> 598 worker = kthread_create_for_user(vhost_worker, dev,
> > 599 current->real_cred->user,
> 600 "vhost-%d", current->pid);

It looks like I should be doing something like get_uid(current_user())
then a free_uid() when doing using the user_struct.

Will fix.