Re: [PATCH v6 6/7] Reimplement RLIMIT_MEMLOCK on top of ucounts

From: kernel test robot
Date: Mon Feb 15 2021 - 10:17:55 EST


Hi Alexey,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on kselftest/next]
[also build test ERROR on linux/master linus/master v5.11 next-20210212]
[cannot apply to hnaz-linux-mm/master]
[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/Alexey-Gladkov/Count-rlimits-in-each-user-namespace/20210215-204524
base: https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git next
config: xtensa-common_defconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/f009495a8def89a71b9e0b9025a39379d6f9097d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Alexey-Gladkov/Count-rlimits-in-each-user-namespace/20210215-204524
git checkout f009495a8def89a71b9e0b9025a39379d6f9097d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=xtensa

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

ipc/shm.c: In function 'newseg':
>> ipc/shm.c:653:5: error: passing argument 4 of 'hugetlb_file_setup' from incompatible pointer type [-Werror=incompatible-pointer-types]
653 | &shp->mlock_cred, HUGETLB_SHMFS_INODE,
| ^~~~~~~~~~~~~~~~
| |
| const struct cred **
In file included from ipc/shm.c:30:
include/linux/hugetlb.h:457:17: note: expected 'struct cred **' but argument is of type 'const struct cred **'
457 | struct cred **cred, int creat_flags,
| ~~~~~~~~~~~~~~^~~~
cc1: some warnings being treated as errors


vim +/hugetlb_file_setup +653 ipc/shm.c

592
593 /**
594 * newseg - Create a new shared memory segment
595 * @ns: namespace
596 * @params: ptr to the structure that contains key, size and shmflg
597 *
598 * Called with shm_ids.rwsem held as a writer.
599 */
600 static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
601 {
602 key_t key = params->key;
603 int shmflg = params->flg;
604 size_t size = params->u.size;
605 int error;
606 struct shmid_kernel *shp;
607 size_t numpages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
608 struct file *file;
609 char name[13];
610 vm_flags_t acctflag = 0;
611
612 if (size < SHMMIN || size > ns->shm_ctlmax)
613 return -EINVAL;
614
615 if (numpages << PAGE_SHIFT < size)
616 return -ENOSPC;
617
618 if (ns->shm_tot + numpages < ns->shm_tot ||
619 ns->shm_tot + numpages > ns->shm_ctlall)
620 return -ENOSPC;
621
622 shp = kvmalloc(sizeof(*shp), GFP_KERNEL);
623 if (unlikely(!shp))
624 return -ENOMEM;
625
626 shp->shm_perm.key = key;
627 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
628 shp->mlock_cred = NULL;
629
630 shp->shm_perm.security = NULL;
631 error = security_shm_alloc(&shp->shm_perm);
632 if (error) {
633 kvfree(shp);
634 return error;
635 }
636
637 sprintf(name, "SYSV%08x", key);
638 if (shmflg & SHM_HUGETLB) {
639 struct hstate *hs;
640 size_t hugesize;
641
642 hs = hstate_sizelog((shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK);
643 if (!hs) {
644 error = -EINVAL;
645 goto no_file;
646 }
647 hugesize = ALIGN(size, huge_page_size(hs));
648
649 /* hugetlb_file_setup applies strict accounting */
650 if (shmflg & SHM_NORESERVE)
651 acctflag = VM_NORESERVE;
652 file = hugetlb_file_setup(name, hugesize, acctflag,
> 653 &shp->mlock_cred, HUGETLB_SHMFS_INODE,
654 (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK);
655 } else {
656 /*
657 * Do not allow no accounting for OVERCOMMIT_NEVER, even
658 * if it's asked for.
659 */
660 if ((shmflg & SHM_NORESERVE) &&
661 sysctl_overcommit_memory != OVERCOMMIT_NEVER)
662 acctflag = VM_NORESERVE;
663 file = shmem_kernel_file_setup(name, size, acctflag);
664 }
665 error = PTR_ERR(file);
666 if (IS_ERR(file)) {
667 shp->mlock_cred = NULL;
668 goto no_file;
669 }
670
671 shp->shm_cprid = get_pid(task_tgid(current));
672 shp->shm_lprid = NULL;
673 shp->shm_atim = shp->shm_dtim = 0;
674 shp->shm_ctim = ktime_get_real_seconds();
675 shp->shm_segsz = size;
676 shp->shm_nattch = 0;
677 shp->shm_file = file;
678 shp->shm_creator = current;
679
680 /* ipc_addid() locks shp upon success. */
681 error = ipc_addid(&shm_ids(ns), &shp->shm_perm, ns->shm_ctlmni);
682 if (error < 0)
683 goto no_id;
684
685 list_add(&shp->shm_clist, &current->sysvshm.shm_clist);
686
687 /*
688 * shmid gets reported as "inode#" in /proc/pid/maps.
689 * proc-ps tools use this. Changing this will break them.
690 */
691 file_inode(file)->i_ino = shp->shm_perm.id;
692
693 ns->shm_tot += numpages;
694 error = shp->shm_perm.id;
695
696 ipc_unlock_object(&shp->shm_perm);
697 rcu_read_unlock();
698 return error;
699
700 no_id:
701 ipc_update_pid(&shp->shm_cprid, NULL);
702 ipc_update_pid(&shp->shm_lprid, NULL);
703 if (is_file_hugepages(file) && shp->mlock_cred)
704 user_shm_unlock(size, shp->mlock_cred);
705 fput(file);
706 ipc_rcu_putref(&shp->shm_perm, shm_rcu_free);
707 return error;
708 no_file:
709 call_rcu(&shp->shm_perm.rcu, shm_rcu_free);
710 return error;
711 }
712

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip