Mike Christie
2021-Jun-24 03:08 UTC
[PATCH 3/3] vhost: pass kthread user to check RLIMIT_NPROC
This has vhost pass in the user to the kthread API, so the process doing
the ioctl has its RLIMIT_NPROC checked and its processes count
incremented.
Signed-off-by: Mike Christie <michael.christie at oracle.com>
---
drivers/vhost/vhost.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 5ccb0705beae..141cca6fd50a 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -595,8 +595,9 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
dev->kcov_handle = kcov_common_handle();
if (dev->use_worker) {
- worker = kthread_create(vhost_worker, dev,
- "vhost-%d", current->pid);
+ worker = kthread_create_for_user(vhost_worker, dev,
+ current->real_cred->user,
+ "vhost-%d", current->pid);
if (IS_ERR(worker)) {
err = PTR_ERR(worker);
goto err_worker;
--
2.25.1
kernel test robot
2021-Jun-24 08:26 UTC
[PATCH 3/3] vhost: pass kthread user to check RLIMIT_NPROC
Hi Mike,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on vhost/linux-next]
[also build test WARNING on linux/master linus/master v5.13-rc7]
[cannot apply to next-20210623]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url:
https://github.com/0day-ci/linux/commits/Mike-Christie/kthread-pass-in-user-and-check-RLIMIT_NPROC/20210624-110925
base: https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
config: riscv-randconfig-s032-20210622 (attached as .config)
compiler: riscv64-linux-gcc (GCC) 9.3.0
reproduce:
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-341-g8af24329-dirty
#
https://github.com/0day-ci/linux/commit/daae0f4bb5ef7264d67cab20da37192754f885b8
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review
Mike-Christie/kthread-pass-in-user-and-check-RLIMIT_NPROC/20210624-110925
git checkout daae0f4bb5ef7264d67cab20da37192754f885b8
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=riscv
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>
sparse warnings: (new ones prefixed by >>)>> 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);
601 if (IS_ERR(worker)) {
602 err = PTR_ERR(worker);
603 goto err_worker;
604 }
605
606 dev->worker = worker;
607 wake_up_process(worker); /* avoid contributing to loadavg */
608
609 err = vhost_attach_cgroups(dev);
610 if (err)
611 goto err_cgroup;
612 }
613
614 err = vhost_dev_alloc_iovecs(dev);
615 if (err)
616 goto err_cgroup;
617
618 return 0;
619 err_cgroup:
620 if (dev->worker) {
621 kthread_stop(dev->worker);
622 dev->worker = NULL;
623 }
624 err_worker:
625 vhost_detach_mm(dev);
626 dev->kcov_handle = 0;
627 err_mm:
628 return err;
629 }
630 EXPORT_SYMBOL_GPL(vhost_dev_set_owner);
631
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all at lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 29454 bytes
Desc: not available
URL:
<http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20210624/1a6089e5/attachment-0001.gz>