From: kernel test robot <lkp@intel.com>
To: Khadija Kamran <kamrankhadijadj@gmail.com>,
linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Serge Hallyn <serge@hallyn.com>, Paul Moore <paul@paul-moore.com>,
James Morris <jmorris@namei.org>,
linux-security-module@vger.kernel.org,
Stephen Smalley <stephen.smalley.work@gmail.com>,
Eric Paris <eparis@parisplace.org>,
selinux@vger.kernel.org, ztarkhani@microsoft.com,
alison.schofield@intel.com
Cc: oe-kbuild-all@lists.linux.dev,
Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [PATCH] lsm: constify the 'mm' parameter in security_vm_enough_memory_mm()
Date: Thu, 24 Aug 2023 21:03:34 +0800 [thread overview]
Message-ID: <202308242024.q4KF0YIN-lkp@intel.com> (raw)
In-Reply-To: <ZOWtBTKkfcc8sKkY@gmail.com>
Hi Khadija,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on pcmoore-selinux/next pcmoore-audit/next linus/master v6.5-rc7 next-20230824]
[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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Khadija-Kamran/lsm-constify-the-mm-parameter-in-security_vm_enough_memory_mm/20230823-145455
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/ZOWtBTKkfcc8sKkY%40gmail.com
patch subject: [PATCH] lsm: constify the 'mm' parameter in security_vm_enough_memory_mm()
config: arc-randconfig-001-20230824 (https://download.01.org/0day-ci/archive/20230824/202308242024.q4KF0YIN-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230824/202308242024.q4KF0YIN-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308242024.q4KF0YIN-lkp@intel.com/
All errors (new ones prefixed by >>):
>> mm/util.c:928:5: error: conflicting types for '__vm_enough_memory'; have 'int(struct mm_struct *, long int, int)'
928 | int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
| ^~~~~~~~~~~~~~~~~~
In file included from mm/util.c:2:
include/linux/mm.h:3199:12: note: previous declaration of '__vm_enough_memory' with type 'int(const struct mm_struct *, long int, int)'
3199 | extern int __vm_enough_memory(const struct mm_struct *mm, long pages, int cap_sys_admin);
| ^~~~~~~~~~~~~~~~~~
vim +928 mm/util.c
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 911
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 912 /*
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 913 * Check that a process has enough memory to allocate a new virtual
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 914 * mapping. 0 means there is enough memory for the allocation to
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 915 * succeed and -ENOMEM implies there is not.
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 916 *
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 917 * We currently support three overcommit policies, which are set via the
ee65728e103bb7 Mike Rapoport 2022-06-27 918 * vm.overcommit_memory sysctl. See Documentation/mm/overcommit-accounting.rst
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 919 *
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 920 * Strict overcommit modes added 2002 Feb 26 by Alan Cox.
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 921 * Additional code 2002 Jul 20 by Robert Love.
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 922 *
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 923 * cap_sys_admin is 1 if the process has admin privileges, 0 otherwise.
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 924 *
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 925 * Note this is a helper function intended to be used by LSMs which
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 926 * wish to use this logic.
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 927 */
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 @928 int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 929 {
8c7829b04c523c Johannes Weiner 2019-05-13 930 long allowed;
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 931
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 932 vm_acct_memory(pages);
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 933
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 934 /*
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 935 * Sometimes we want to use more memory than we have
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 936 */
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 937 if (sysctl_overcommit_memory == OVERCOMMIT_ALWAYS)
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 938 return 0;
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 939
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 940 if (sysctl_overcommit_memory == OVERCOMMIT_GUESS) {
8c7829b04c523c Johannes Weiner 2019-05-13 941 if (pages > totalram_pages() + total_swap_pages)
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 942 goto error;
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 943 return 0;
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 944 }
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 945
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 946 allowed = vm_commit_limit();
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 947 /*
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 948 * Reserve some for root
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 949 */
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 950 if (!cap_sys_admin)
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 951 allowed -= sysctl_admin_reserve_kbytes >> (PAGE_SHIFT - 10);
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 952
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 953 /*
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 954 * Don't let a single process grow so big a user can't recover
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 955 */
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 956 if (mm) {
8c7829b04c523c Johannes Weiner 2019-05-13 957 long reserve = sysctl_user_reserve_kbytes >> (PAGE_SHIFT - 10);
8c7829b04c523c Johannes Weiner 2019-05-13 958
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 959 allowed -= min_t(long, mm->total_vm / 32, reserve);
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 960 }
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 961
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 962 if (percpu_counter_read_positive(&vm_committed_as) < allowed)
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 963 return 0;
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 964 error:
6bdfc60cf0f977 Jakub Wilk 2023-02-10 965 pr_warn_ratelimited("%s: pid: %d, comm: %s, not enough memory for the allocation\n",
44b414c8715c5d Kefeng Wang 2022-07-26 966 __func__, current->pid, current->comm);
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 967 vm_unacct_memory(pages);
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 968
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 969 return -ENOMEM;
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 970 }
39a1aa8e194ab6 Andrey Ryabinin 2016-03-17 971
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
next prev parent reply other threads:[~2023-08-24 13:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-23 6:53 [PATCH] lsm: constify the 'mm' parameter in security_vm_enough_memory_mm() Khadija Kamran
2023-08-23 12:06 ` Matthew Wilcox
2023-09-13 22:01 ` Paul Moore
2023-08-24 13:03 ` kernel test robot [this message]
2023-09-13 22:02 ` Paul Moore
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=202308242024.q4KF0YIN-lkp@intel.com \
--to=lkp@intel.com \
--cc=akpm@linux-foundation.org \
--cc=alison.schofield@intel.com \
--cc=eparis@parisplace.org \
--cc=jmorris@namei.org \
--cc=kamrankhadijadj@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-security-module@vger.kernel.org \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=paul@paul-moore.com \
--cc=selinux@vger.kernel.org \
--cc=serge@hallyn.com \
--cc=stephen.smalley.work@gmail.com \
--cc=ztarkhani@microsoft.com \
/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 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).