* [akpm-mm:mm-unstable 34/207] fs/binfmt_elf.c:1140:17: warning: implicit conversion from 'unsigned long long' to 'unsigned long' changes value from 4294967296 to 0
@ 2026-03-07 12:21 kernel test robot
2026-03-08 21:19 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2026-03-07 12:21 UTC (permalink / raw)
To: Jianhui Zhou
Cc: llvm, oe-kbuild-all, David Hildenbrand, Andrew Morton,
Linux Memory Management List
tree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable
head: 49cb736d092aaa856283e33b78ec3afb3964d82f
commit: cd9119a9480d9d93fdf06792f8f9917cc4f9999c [34/207] mm/userfaultfd: fix hugetlb fault mutex hash calculation
config: powerpc-currituck_defconfig (https://download.01.org/0day-ci/archive/20260307/202603072018.Dl1xONhs-lkp@intel.com/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project c32caeec8158d634bb71ab8911a6031248b9fc47)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260307/202603072018.Dl1xONhs-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/202603072018.Dl1xONhs-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from fs/binfmt_elf.c:31:
include/linux/hugetlb.h:1214:9: error: call to undeclared function 'linear_page_index'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
1214 | return linear_page_index(vma, address);
| ^
In file included from fs/binfmt_elf.c:32:
include/linux/pagemap.h:1079:23: error: conflicting types for 'linear_page_index'
1079 | static inline pgoff_t linear_page_index(const struct vm_area_struct *vma,
| ^
include/linux/hugetlb.h:1214:9: note: previous implicit declaration is here
1214 | return linear_page_index(vma, address);
| ^
>> fs/binfmt_elf.c:1140:17: warning: implicit conversion from 'unsigned long long' to 'unsigned long' changes value from 4294967296 to 0 [-Wconstant-conversion]
1140 | load_bias = ELF_ET_DYN_BASE;
| ~ ^~~~~~~~~~~~~~~
arch/powerpc/include/asm/elf.h:28:10: note: expanded from macro 'ELF_ET_DYN_BASE'
28 | 0x100000000UL)
| ^~~~~~~~~~~~~
fs/binfmt_elf.c:1326:13: warning: implicit conversion from 'unsigned long long' to 'unsigned long' changes value from 4294967296 to 0 [-Wconstant-conversion]
1326 | elf_brk = ELF_ET_DYN_BASE;
| ~ ^~~~~~~~~~~~~~~
arch/powerpc/include/asm/elf.h:28:10: note: expanded from macro 'ELF_ET_DYN_BASE'
28 | 0x100000000UL)
| ^~~~~~~~~~~~~
2 warnings and 2 errors generated.
vim +1140 fs/binfmt_elf.c
00e19ceec80b03a Dave Martin 2020-03-16 831
71613c3b871c5a9 Al Viro 2012-10-20 832 static int load_elf_binary(struct linux_binprm *bprm)
^1da177e4c3f415 Linus Torvalds 2005-04-16 833 {
^1da177e4c3f415 Linus Torvalds 2005-04-16 834 struct file *interpreter = NULL; /* to shut gcc up */
2b4bfbe0967697c Akira Kawata 2022-01-27 835 unsigned long load_bias = 0, phdr_addr = 0;
2b4bfbe0967697c Akira Kawata 2022-01-27 836 int first_pt_load = 1;
^1da177e4c3f415 Linus Torvalds 2005-04-16 837 unsigned long error;
a9d9ef133f443ae Paul Burton 2014-09-11 838 struct elf_phdr *elf_ppnt, *elf_phdata, *interp_elf_phdata = NULL;
00e19ceec80b03a Dave Martin 2020-03-16 839 struct elf_phdr *elf_property_phdata = NULL;
8ed2ef21ff564cf Kees Cook 2023-09-28 840 unsigned long elf_brk;
11854fe263eb1b9 Kees Cook 2025-04-25 841 bool brk_moved = false;
^1da177e4c3f415 Linus Torvalds 2005-04-16 842 int retval, i;
cc503c1b43e002e Jiri Kosina 2008-01-30 843 unsigned long elf_entry;
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 844 unsigned long e_entry;
cc503c1b43e002e Jiri Kosina 2008-01-30 845 unsigned long interp_load_addr = 0;
^1da177e4c3f415 Linus Torvalds 2005-04-16 846 unsigned long start_code, end_code, start_data, end_data;
1a530a6f23f7dca David Daney 2011-03-22 847 unsigned long reloc_func_desc __maybe_unused = 0;
8de61e69c2feb10 David Rientjes 2006-12-06 848 int executable_stack = EXSTACK_DEFAULT;
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 849 struct elfhdr *elf_ex = (struct elfhdr *)bprm->buf;
0693ffebcfe5ac7 Alexey Dobriyan 2020-04-06 850 struct elfhdr *interp_elf_ex = NULL;
774c105ed8d791b Paul Burton 2014-09-11 851 struct arch_elf_state arch_state = INIT_ARCH_ELF_STATE;
03c6d723eeac2d7 Alexey Dobriyan 2020-01-30 852 struct mm_struct *mm;
249b08e4e504d4c Alexey Dobriyan 2019-05-14 853 struct pt_regs *regs;
^1da177e4c3f415 Linus Torvalds 2005-04-16 854
^1da177e4c3f415 Linus Torvalds 2005-04-16 855 retval = -ENOEXEC;
^1da177e4c3f415 Linus Torvalds 2005-04-16 856 /* First of all, some simple consistency checks */
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 857 if (memcmp(elf_ex->e_ident, ELFMAG, SELFMAG) != 0)
^1da177e4c3f415 Linus Torvalds 2005-04-16 858 goto out;
^1da177e4c3f415 Linus Torvalds 2005-04-16 859
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 860 if (elf_ex->e_type != ET_EXEC && elf_ex->e_type != ET_DYN)
^1da177e4c3f415 Linus Torvalds 2005-04-16 861 goto out;
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 862 if (!elf_check_arch(elf_ex))
^1da177e4c3f415 Linus Torvalds 2005-04-16 863 goto out;
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 864 if (elf_check_fdpic(elf_ex))
4755200b6b116db Nicolas Pitre 2017-08-16 865 goto out;
b013ed403197f3f Lorenzo Stoakes 2025-06-16 866 if (!can_mmap_file(bprm->file))
^1da177e4c3f415 Linus Torvalds 2005-04-16 867 goto out;
^1da177e4c3f415 Linus Torvalds 2005-04-16 868
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 869 elf_phdata = load_elf_phdrs(elf_ex, bprm->file);
^1da177e4c3f415 Linus Torvalds 2005-04-16 870 if (!elf_phdata)
^1da177e4c3f415 Linus Torvalds 2005-04-16 871 goto out;
^1da177e4c3f415 Linus Torvalds 2005-04-16 872
^1da177e4c3f415 Linus Torvalds 2005-04-16 873 elf_ppnt = elf_phdata;
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 874 for (i = 0; i < elf_ex->e_phnum; i++, elf_ppnt++) {
cc338010a233c08 Alexey Dobriyan 2019-05-14 875 char *elf_interpreter;
5cf4a36382588e6 Alexey Dobriyan 2019-05-14 876
00e19ceec80b03a Dave Martin 2020-03-16 877 if (elf_ppnt->p_type == PT_GNU_PROPERTY) {
00e19ceec80b03a Dave Martin 2020-03-16 878 elf_property_phdata = elf_ppnt;
00e19ceec80b03a Dave Martin 2020-03-16 879 continue;
00e19ceec80b03a Dave Martin 2020-03-16 880 }
00e19ceec80b03a Dave Martin 2020-03-16 881
be0deb585e4c51d Alexey Dobriyan 2019-05-14 882 if (elf_ppnt->p_type != PT_INTERP)
be0deb585e4c51d Alexey Dobriyan 2019-05-14 883 continue;
be0deb585e4c51d Alexey Dobriyan 2019-05-14 884
be0deb585e4c51d Alexey Dobriyan 2019-05-14 885 /*
be0deb585e4c51d Alexey Dobriyan 2019-05-14 886 * This is the program interpreter used for shared libraries -
be0deb585e4c51d Alexey Dobriyan 2019-05-14 887 * for now assume that this is an a.out format binary.
^1da177e4c3f415 Linus Torvalds 2005-04-16 888 */
^1da177e4c3f415 Linus Torvalds 2005-04-16 889 retval = -ENOEXEC;
be0deb585e4c51d Alexey Dobriyan 2019-05-14 890 if (elf_ppnt->p_filesz > PATH_MAX || elf_ppnt->p_filesz < 2)
e7b9b550f53e81e Al Viro 2009-03-29 891 goto out_free_ph;
^1da177e4c3f415 Linus Torvalds 2005-04-16 892
^1da177e4c3f415 Linus Torvalds 2005-04-16 893 retval = -ENOMEM;
be0deb585e4c51d Alexey Dobriyan 2019-05-14 894 elf_interpreter = kmalloc(elf_ppnt->p_filesz, GFP_KERNEL);
^1da177e4c3f415 Linus Torvalds 2005-04-16 895 if (!elf_interpreter)
e7b9b550f53e81e Al Viro 2009-03-29 896 goto out_free_ph;
^1da177e4c3f415 Linus Torvalds 2005-04-16 897
658c03356511854 Alexey Dobriyan 2019-12-04 898 retval = elf_read(bprm->file, elf_interpreter, elf_ppnt->p_filesz,
658c03356511854 Alexey Dobriyan 2019-12-04 899 elf_ppnt->p_offset);
658c03356511854 Alexey Dobriyan 2019-12-04 900 if (retval < 0)
^1da177e4c3f415 Linus Torvalds 2005-04-16 901 goto out_free_interp;
^1da177e4c3f415 Linus Torvalds 2005-04-16 902 /* make sure path is NULL terminated */
^1da177e4c3f415 Linus Torvalds 2005-04-16 903 retval = -ENOEXEC;
^1da177e4c3f415 Linus Torvalds 2005-04-16 904 if (elf_interpreter[elf_ppnt->p_filesz - 1] != '\0')
^1da177e4c3f415 Linus Torvalds 2005-04-16 905 goto out_free_interp;
^1da177e4c3f415 Linus Torvalds 2005-04-16 906
^1da177e4c3f415 Linus Torvalds 2005-04-16 907 interpreter = open_exec(elf_interpreter);
cc338010a233c08 Alexey Dobriyan 2019-05-14 908 kfree(elf_interpreter);
^1da177e4c3f415 Linus Torvalds 2005-04-16 909 retval = PTR_ERR(interpreter);
^1da177e4c3f415 Linus Torvalds 2005-04-16 910 if (IS_ERR(interpreter))
cc338010a233c08 Alexey Dobriyan 2019-05-14 911 goto out_free_ph;
1fb844961818ce9 Alexey Dobriyan 2007-01-26 912
1fb844961818ce9 Alexey Dobriyan 2007-01-26 913 /*
be0deb585e4c51d Alexey Dobriyan 2019-05-14 914 * If the binary is not readable then enforce mm->dumpable = 0
be0deb585e4c51d Alexey Dobriyan 2019-05-14 915 * regardless of the interpreter's permissions.
1fb844961818ce9 Alexey Dobriyan 2007-01-26 916 */
1b5d783c94c328d Al Viro 2011-06-19 917 would_dump(bprm, interpreter);
1fb844961818ce9 Alexey Dobriyan 2007-01-26 918
bf4afc53b77aeaa Linus Torvalds 2026-02-21 919 interp_elf_ex = kmalloc_obj(*interp_elf_ex);
0693ffebcfe5ac7 Alexey Dobriyan 2020-04-06 920 if (!interp_elf_ex) {
0693ffebcfe5ac7 Alexey Dobriyan 2020-04-06 921 retval = -ENOMEM;
594d2a14f2168c0 Li Zetao 2022-10-24 922 goto out_free_file;
0693ffebcfe5ac7 Alexey Dobriyan 2020-04-06 923 }
0693ffebcfe5ac7 Alexey Dobriyan 2020-04-06 924
b582ef5c53040c5 Maciej W. Rozycki 2015-10-26 925 /* Get the exec headers */
c69bcc932ef3568 Alexey Dobriyan 2020-04-06 926 retval = elf_read(interpreter, interp_elf_ex,
c69bcc932ef3568 Alexey Dobriyan 2020-04-06 927 sizeof(*interp_elf_ex), 0);
658c03356511854 Alexey Dobriyan 2019-12-04 928 if (retval < 0)
^1da177e4c3f415 Linus Torvalds 2005-04-16 929 goto out_free_dentry;
^1da177e4c3f415 Linus Torvalds 2005-04-16 930
^1da177e4c3f415 Linus Torvalds 2005-04-16 931 break;
cc338010a233c08 Alexey Dobriyan 2019-05-14 932
cc338010a233c08 Alexey Dobriyan 2019-05-14 933 out_free_interp:
cc338010a233c08 Alexey Dobriyan 2019-05-14 934 kfree(elf_interpreter);
cc338010a233c08 Alexey Dobriyan 2019-05-14 935 goto out_free_ph;
^1da177e4c3f415 Linus Torvalds 2005-04-16 936 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 937
^1da177e4c3f415 Linus Torvalds 2005-04-16 938 elf_ppnt = elf_phdata;
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 939 for (i = 0; i < elf_ex->e_phnum; i++, elf_ppnt++)
774c105ed8d791b Paul Burton 2014-09-11 940 switch (elf_ppnt->p_type) {
774c105ed8d791b Paul Burton 2014-09-11 941 case PT_GNU_STACK:
^1da177e4c3f415 Linus Torvalds 2005-04-16 942 if (elf_ppnt->p_flags & PF_X)
^1da177e4c3f415 Linus Torvalds 2005-04-16 943 executable_stack = EXSTACK_ENABLE_X;
^1da177e4c3f415 Linus Torvalds 2005-04-16 944 else
^1da177e4c3f415 Linus Torvalds 2005-04-16 945 executable_stack = EXSTACK_DISABLE_X;
^1da177e4c3f415 Linus Torvalds 2005-04-16 946 break;
774c105ed8d791b Paul Burton 2014-09-11 947
774c105ed8d791b Paul Burton 2014-09-11 948 case PT_LOPROC ... PT_HIPROC:
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 949 retval = arch_elf_pt_proc(elf_ex, elf_ppnt,
774c105ed8d791b Paul Burton 2014-09-11 950 bprm->file, false,
774c105ed8d791b Paul Burton 2014-09-11 951 &arch_state);
774c105ed8d791b Paul Burton 2014-09-11 952 if (retval)
774c105ed8d791b Paul Burton 2014-09-11 953 goto out_free_dentry;
774c105ed8d791b Paul Burton 2014-09-11 954 break;
^1da177e4c3f415 Linus Torvalds 2005-04-16 955 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 956
^1da177e4c3f415 Linus Torvalds 2005-04-16 957 /* Some simple consistency checks for the interpreter */
cc338010a233c08 Alexey Dobriyan 2019-05-14 958 if (interpreter) {
^1da177e4c3f415 Linus Torvalds 2005-04-16 959 retval = -ELIBBAD;
d20894a23708c2a Andi Kleen 2008-02-08 960 /* Not an ELF interpreter */
c69bcc932ef3568 Alexey Dobriyan 2020-04-06 961 if (memcmp(interp_elf_ex->e_ident, ELFMAG, SELFMAG) != 0)
^1da177e4c3f415 Linus Torvalds 2005-04-16 962 goto out_free_dentry;
^1da177e4c3f415 Linus Torvalds 2005-04-16 963 /* Verify the interpreter has a valid arch */
c69bcc932ef3568 Alexey Dobriyan 2020-04-06 964 if (!elf_check_arch(interp_elf_ex) ||
c69bcc932ef3568 Alexey Dobriyan 2020-04-06 965 elf_check_fdpic(interp_elf_ex))
^1da177e4c3f415 Linus Torvalds 2005-04-16 966 goto out_free_dentry;
a9d9ef133f443ae Paul Burton 2014-09-11 967
a9d9ef133f443ae Paul Burton 2014-09-11 968 /* Load the interpreter program headers */
c69bcc932ef3568 Alexey Dobriyan 2020-04-06 969 interp_elf_phdata = load_elf_phdrs(interp_elf_ex,
a9d9ef133f443ae Paul Burton 2014-09-11 970 interpreter);
a9d9ef133f443ae Paul Burton 2014-09-11 971 if (!interp_elf_phdata)
a9d9ef133f443ae Paul Burton 2014-09-11 972 goto out_free_dentry;
774c105ed8d791b Paul Burton 2014-09-11 973
774c105ed8d791b Paul Burton 2014-09-11 974 /* Pass PT_LOPROC..PT_HIPROC headers to arch code */
00e19ceec80b03a Dave Martin 2020-03-16 975 elf_property_phdata = NULL;
774c105ed8d791b Paul Burton 2014-09-11 976 elf_ppnt = interp_elf_phdata;
c69bcc932ef3568 Alexey Dobriyan 2020-04-06 977 for (i = 0; i < interp_elf_ex->e_phnum; i++, elf_ppnt++)
774c105ed8d791b Paul Burton 2014-09-11 978 switch (elf_ppnt->p_type) {
00e19ceec80b03a Dave Martin 2020-03-16 979 case PT_GNU_PROPERTY:
00e19ceec80b03a Dave Martin 2020-03-16 980 elf_property_phdata = elf_ppnt;
00e19ceec80b03a Dave Martin 2020-03-16 981 break;
00e19ceec80b03a Dave Martin 2020-03-16 982
774c105ed8d791b Paul Burton 2014-09-11 983 case PT_LOPROC ... PT_HIPROC:
c69bcc932ef3568 Alexey Dobriyan 2020-04-06 984 retval = arch_elf_pt_proc(interp_elf_ex,
774c105ed8d791b Paul Burton 2014-09-11 985 elf_ppnt, interpreter,
774c105ed8d791b Paul Burton 2014-09-11 986 true, &arch_state);
774c105ed8d791b Paul Burton 2014-09-11 987 if (retval)
774c105ed8d791b Paul Burton 2014-09-11 988 goto out_free_dentry;
774c105ed8d791b Paul Burton 2014-09-11 989 break;
^1da177e4c3f415 Linus Torvalds 2005-04-16 990 }
774c105ed8d791b Paul Burton 2014-09-11 991 }
774c105ed8d791b Paul Burton 2014-09-11 992
00e19ceec80b03a Dave Martin 2020-03-16 993 retval = parse_elf_properties(interpreter ?: bprm->file,
00e19ceec80b03a Dave Martin 2020-03-16 994 elf_property_phdata, &arch_state);
00e19ceec80b03a Dave Martin 2020-03-16 995 if (retval)
00e19ceec80b03a Dave Martin 2020-03-16 996 goto out_free_dentry;
00e19ceec80b03a Dave Martin 2020-03-16 997
774c105ed8d791b Paul Burton 2014-09-11 998 /*
774c105ed8d791b Paul Burton 2014-09-11 999 * Allow arch code to reject the ELF at this point, whilst it's
774c105ed8d791b Paul Burton 2014-09-11 1000 * still possible to return an error to the code that invoked
774c105ed8d791b Paul Burton 2014-09-11 1001 * the exec syscall.
774c105ed8d791b Paul Burton 2014-09-11 1002 */
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 1003 retval = arch_check_elf(elf_ex,
c69bcc932ef3568 Alexey Dobriyan 2020-04-06 1004 !!interpreter, interp_elf_ex,
eb4bc076ff94b82 Maciej W. Rozycki 2015-11-13 1005 &arch_state);
774c105ed8d791b Paul Burton 2014-09-11 1006 if (retval)
774c105ed8d791b Paul Burton 2014-09-11 1007 goto out_free_dentry;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1008
^1da177e4c3f415 Linus Torvalds 2005-04-16 1009 /* Flush all traces of the currently running executable */
2388777a0a5957a Eric W. Biederman 2020-05-03 1010 retval = begin_new_exec(bprm);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1011 if (retval)
^1da177e4c3f415 Linus Torvalds 2005-04-16 1012 goto out_free_dentry;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1013
^1da177e4c3f415 Linus Torvalds 2005-04-16 1014 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
^1da177e4c3f415 Linus Torvalds 2005-04-16 1015 may depend on the personality. */
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 1016 SET_PERSONALITY2(*elf_ex, &arch_state);
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 1017 if (elf_read_implies_exec(*elf_ex, executable_stack))
^1da177e4c3f415 Linus Torvalds 2005-04-16 1018 current->personality |= READ_IMPLIES_EXEC;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1019
2a97388a807b6ab Alexey Dobriyan 2024-06-21 1020 const int snapshot_randomize_va_space = READ_ONCE(randomize_va_space);
2a97388a807b6ab Alexey Dobriyan 2024-06-21 1021 if (!(current->personality & ADDR_NO_RANDOMIZE) && snapshot_randomize_va_space)
^1da177e4c3f415 Linus Torvalds 2005-04-16 1022 current->flags |= PF_RANDOMIZE;
221af7f87b97431 Linus Torvalds 2010-01-28 1023
221af7f87b97431 Linus Torvalds 2010-01-28 1024 setup_new_exec(bprm);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1025
^1da177e4c3f415 Linus Torvalds 2005-04-16 1026 /* Do this so that we can load the interpreter, if need be. We will
^1da177e4c3f415 Linus Torvalds 2005-04-16 1027 change some of these later */
^1da177e4c3f415 Linus Torvalds 2005-04-16 1028 retval = setup_arg_pages(bprm, randomize_stack_top(STACK_TOP),
^1da177e4c3f415 Linus Torvalds 2005-04-16 1029 executable_stack);
19d860a140beac4 Al Viro 2014-05-04 1030 if (retval < 0)
^1da177e4c3f415 Linus Torvalds 2005-04-16 1031 goto out_free_dentry;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1032
852643165aea099 Alexey Dobriyan 2019-05-14 1033 elf_brk = 0;
852643165aea099 Alexey Dobriyan 2019-05-14 1034
852643165aea099 Alexey Dobriyan 2019-05-14 1035 start_code = ~0UL;
852643165aea099 Alexey Dobriyan 2019-05-14 1036 end_code = 0;
852643165aea099 Alexey Dobriyan 2019-05-14 1037 start_data = 0;
852643165aea099 Alexey Dobriyan 2019-05-14 1038 end_data = 0;
852643165aea099 Alexey Dobriyan 2019-05-14 1039
af901ca181d92aa André Goddard Rosa 2009-11-14 1040 /* Now we do a little grungy work by mmapping the ELF image into
cc503c1b43e002e Jiri Kosina 2008-01-30 1041 the correct location in memory. */
f4e5cc2c44bf760 Jesper Juhl 2006-06-23 1042 for(i = 0, elf_ppnt = elf_phdata;
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 1043 i < elf_ex->e_phnum; i++, elf_ppnt++) {
b212921b13bda08 Linus Torvalds 2019-10-06 1044 int elf_prot, elf_flags;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1045 unsigned long k, vaddr;
a87938b2e246b81 Michael Davidson 2015-04-14 1046 unsigned long total_size = 0;
ce81bb256a22425 Chris Kennelly 2020-10-15 1047 unsigned long alignment;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1048
^1da177e4c3f415 Linus Torvalds 2005-04-16 1049 if (elf_ppnt->p_type != PT_LOAD)
^1da177e4c3f415 Linus Torvalds 2005-04-16 1050 continue;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1051
fe0f67660ee9c99 Dave Martin 2020-03-16 1052 elf_prot = make_prot(elf_ppnt->p_flags, &arch_state,
fe0f67660ee9c99 Dave Martin 2020-03-16 1053 !!interpreter, false);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1054
4589ff7ca815163 David Hildenbrand 2021-04-23 1055 elf_flags = MAP_PRIVATE;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1056
^1da177e4c3f415 Linus Torvalds 2005-04-16 1057 vaddr = elf_ppnt->p_vaddr;
eab09532d400906 Kees Cook 2017-07-10 1058 /*
2b4bfbe0967697c Akira Kawata 2022-01-27 1059 * The first time through the loop, first_pt_load is true:
5f501d555653f89 Kees Cook 2021-11-08 1060 * layout will be calculated. Once set, use MAP_FIXED since
5f501d555653f89 Kees Cook 2021-11-08 1061 * we know we've already safely mapped the entire region with
5f501d555653f89 Kees Cook 2021-11-08 1062 * MAP_FIXED_NOREPLACE in the once-per-binary logic following.
eab09532d400906 Kees Cook 2017-07-10 1063 */
2b4bfbe0967697c Akira Kawata 2022-01-27 1064 if (!first_pt_load) {
b212921b13bda08 Linus Torvalds 2019-10-06 1065 elf_flags |= MAP_FIXED;
5f501d555653f89 Kees Cook 2021-11-08 1066 } else if (elf_ex->e_type == ET_EXEC) {
5f501d555653f89 Kees Cook 2021-11-08 1067 /*
5f501d555653f89 Kees Cook 2021-11-08 1068 * This logic is run once for the first LOAD Program
5f501d555653f89 Kees Cook 2021-11-08 1069 * Header for ET_EXEC binaries. No special handling
5f501d555653f89 Kees Cook 2021-11-08 1070 * is needed.
5f501d555653f89 Kees Cook 2021-11-08 1071 */
5f501d555653f89 Kees Cook 2021-11-08 1072 elf_flags |= MAP_FIXED_NOREPLACE;
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 1073 } else if (elf_ex->e_type == ET_DYN) {
eab09532d400906 Kees Cook 2017-07-10 1074 /*
eab09532d400906 Kees Cook 2017-07-10 1075 * This logic is run once for the first LOAD Program
eab09532d400906 Kees Cook 2017-07-10 1076 * Header for ET_DYN binaries to calculate the
eab09532d400906 Kees Cook 2017-07-10 1077 * randomization (load_bias) for all the LOAD
5f501d555653f89 Kees Cook 2021-11-08 1078 * Program Headers.
2d4cf7b190bbfad Kees Cook 2024-05-08 1079 */
2d4cf7b190bbfad Kees Cook 2024-05-08 1080
2d4cf7b190bbfad Kees Cook 2024-05-08 1081 /*
2d4cf7b190bbfad Kees Cook 2024-05-08 1082 * Calculate the entire size of the ELF mapping
2d4cf7b190bbfad Kees Cook 2024-05-08 1083 * (total_size), used for the initial mapping,
2d4cf7b190bbfad Kees Cook 2024-05-08 1084 * due to load_addr_set which is set to true later
2d4cf7b190bbfad Kees Cook 2024-05-08 1085 * once the initial mapping is performed.
eab09532d400906 Kees Cook 2017-07-10 1086 *
2d4cf7b190bbfad Kees Cook 2024-05-08 1087 * Note that this is only sensible when the LOAD
2d4cf7b190bbfad Kees Cook 2024-05-08 1088 * segments are contiguous (or overlapping). If
2d4cf7b190bbfad Kees Cook 2024-05-08 1089 * used for LOADs that are far apart, this would
2d4cf7b190bbfad Kees Cook 2024-05-08 1090 * cause the holes between LOADs to be mapped,
2d4cf7b190bbfad Kees Cook 2024-05-08 1091 * running the risk of having the mapping fail,
2d4cf7b190bbfad Kees Cook 2024-05-08 1092 * as it would be larger than the ELF file itself.
eab09532d400906 Kees Cook 2017-07-10 1093 *
2d4cf7b190bbfad Kees Cook 2024-05-08 1094 * As a result, only ET_DYN does this, since
2d4cf7b190bbfad Kees Cook 2024-05-08 1095 * some ET_EXEC (e.g. ia64) may have large virtual
2d4cf7b190bbfad Kees Cook 2024-05-08 1096 * memory holes between LOADs.
2d4cf7b190bbfad Kees Cook 2024-05-08 1097 *
2d4cf7b190bbfad Kees Cook 2024-05-08 1098 */
2d4cf7b190bbfad Kees Cook 2024-05-08 1099 total_size = total_mapping_size(elf_phdata,
2d4cf7b190bbfad Kees Cook 2024-05-08 1100 elf_ex->e_phnum);
2d4cf7b190bbfad Kees Cook 2024-05-08 1101 if (!total_size) {
2d4cf7b190bbfad Kees Cook 2024-05-08 1102 retval = -EINVAL;
2d4cf7b190bbfad Kees Cook 2024-05-08 1103 goto out_free_dentry;
2d4cf7b190bbfad Kees Cook 2024-05-08 1104 }
2d4cf7b190bbfad Kees Cook 2024-05-08 1105
3545deff0ec7a37 Kees Cook 2024-05-08 1106 /* Calculate any requested alignment. */
3545deff0ec7a37 Kees Cook 2024-05-08 1107 alignment = maximum_alignment(elf_phdata, elf_ex->e_phnum);
3545deff0ec7a37 Kees Cook 2024-05-08 1108
11854fe263eb1b9 Kees Cook 2025-04-25 1109 /**
11854fe263eb1b9 Kees Cook 2025-04-25 1110 * DOC: PIE handling
11854fe263eb1b9 Kees Cook 2025-04-25 1111 *
11854fe263eb1b9 Kees Cook 2025-04-25 1112 * There are effectively two types of ET_DYN ELF
11854fe263eb1b9 Kees Cook 2025-04-25 1113 * binaries: programs (i.e. PIE: ET_DYN with
11854fe263eb1b9 Kees Cook 2025-04-25 1114 * PT_INTERP) and loaders (i.e. static PIE: ET_DYN
11854fe263eb1b9 Kees Cook 2025-04-25 1115 * without PT_INTERP, usually the ELF interpreter
11854fe263eb1b9 Kees Cook 2025-04-25 1116 * itself). Loaders must be loaded away from programs
11854fe263eb1b9 Kees Cook 2025-04-25 1117 * since the program may otherwise collide with the
11854fe263eb1b9 Kees Cook 2025-04-25 1118 * loader (especially for ET_EXEC which does not have
11854fe263eb1b9 Kees Cook 2025-04-25 1119 * a randomized position).
11854fe263eb1b9 Kees Cook 2025-04-25 1120 *
11854fe263eb1b9 Kees Cook 2025-04-25 1121 * For example, to handle invocations of
eab09532d400906 Kees Cook 2017-07-10 1122 * "./ld.so someprog" to test out a new version of
eab09532d400906 Kees Cook 2017-07-10 1123 * the loader, the subsequent program that the
eab09532d400906 Kees Cook 2017-07-10 1124 * loader loads must avoid the loader itself, so
eab09532d400906 Kees Cook 2017-07-10 1125 * they cannot share the same load range. Sufficient
eab09532d400906 Kees Cook 2017-07-10 1126 * room for the brk must be allocated with the
eab09532d400906 Kees Cook 2017-07-10 1127 * loader as well, since brk must be available with
eab09532d400906 Kees Cook 2017-07-10 1128 * the loader.
eab09532d400906 Kees Cook 2017-07-10 1129 *
eab09532d400906 Kees Cook 2017-07-10 1130 * Therefore, programs are loaded offset from
eab09532d400906 Kees Cook 2017-07-10 1131 * ELF_ET_DYN_BASE and loaders are loaded into the
eab09532d400906 Kees Cook 2017-07-10 1132 * independently randomized mmap region (0 load_bias
5f501d555653f89 Kees Cook 2021-11-08 1133 * without MAP_FIXED nor MAP_FIXED_NOREPLACE).
11854fe263eb1b9 Kees Cook 2025-04-25 1134 *
11854fe263eb1b9 Kees Cook 2025-04-25 1135 * See below for "brk" handling details, which is
11854fe263eb1b9 Kees Cook 2025-04-25 1136 * also affected by program vs loader and ASLR.
eab09532d400906 Kees Cook 2017-07-10 1137 */
aeb7923733d100b Andrew Morton 2022-04-14 1138 if (interpreter) {
3545deff0ec7a37 Kees Cook 2024-05-08 1139 /* On ET_DYN with PT_INTERP, we do the ASLR. */
eab09532d400906 Kees Cook 2017-07-10 @1140 load_bias = ELF_ET_DYN_BASE;
a3defbe5c337dbc Jiri Kosina 2011-11-02 1141 if (current->flags & PF_RANDOMIZE)
d1fd836dcf00d20 Kees Cook 2015-04-14 1142 load_bias += arch_mmap_rnd();
3545deff0ec7a37 Kees Cook 2024-05-08 1143 /* Adjust alignment as requested. */
3545deff0ec7a37 Kees Cook 2024-05-08 1144 if (alignment)
3545deff0ec7a37 Kees Cook 2024-05-08 1145 load_bias &= ~(alignment - 1);
3545deff0ec7a37 Kees Cook 2024-05-08 1146 elf_flags |= MAP_FIXED_NOREPLACE;
3545deff0ec7a37 Kees Cook 2024-05-08 1147 } else {
3545deff0ec7a37 Kees Cook 2024-05-08 1148 /*
3545deff0ec7a37 Kees Cook 2024-05-08 1149 * For ET_DYN without PT_INTERP, we rely on
3545deff0ec7a37 Kees Cook 2024-05-08 1150 * the architectures's (potentially ASLR) mmap
3545deff0ec7a37 Kees Cook 2024-05-08 1151 * base address (via a load_bias of 0).
3545deff0ec7a37 Kees Cook 2024-05-08 1152 *
3545deff0ec7a37 Kees Cook 2024-05-08 1153 * When a large alignment is requested, we
3545deff0ec7a37 Kees Cook 2024-05-08 1154 * must do the allocation at address "0" right
3545deff0ec7a37 Kees Cook 2024-05-08 1155 * now to discover where things will load so
3545deff0ec7a37 Kees Cook 2024-05-08 1156 * that we can adjust the resulting alignment.
3545deff0ec7a37 Kees Cook 2024-05-08 1157 * In this case (load_bias != 0), we can use
3545deff0ec7a37 Kees Cook 2024-05-08 1158 * MAP_FIXED_NOREPLACE to make sure the mapping
3545deff0ec7a37 Kees Cook 2024-05-08 1159 * doesn't collide with anything.
3545deff0ec7a37 Kees Cook 2024-05-08 1160 */
3545deff0ec7a37 Kees Cook 2024-05-08 1161 if (alignment > ELF_MIN_ALIGN) {
3545deff0ec7a37 Kees Cook 2024-05-08 1162 load_bias = elf_load(bprm->file, 0, elf_ppnt,
3545deff0ec7a37 Kees Cook 2024-05-08 1163 elf_prot, elf_flags, total_size);
3545deff0ec7a37 Kees Cook 2024-05-08 1164 if (BAD_ADDR(load_bias)) {
3545deff0ec7a37 Kees Cook 2024-05-08 1165 retval = IS_ERR_VALUE(load_bias) ?
3545deff0ec7a37 Kees Cook 2024-05-08 1166 PTR_ERR((void*)load_bias) : -EINVAL;
3545deff0ec7a37 Kees Cook 2024-05-08 1167 goto out_free_dentry;
3545deff0ec7a37 Kees Cook 2024-05-08 1168 }
3545deff0ec7a37 Kees Cook 2024-05-08 1169 vm_munmap(load_bias, total_size);
3545deff0ec7a37 Kees Cook 2024-05-08 1170 /* Adjust alignment as requested. */
ce81bb256a22425 Chris Kennelly 2020-10-15 1171 if (alignment)
ce81bb256a22425 Chris Kennelly 2020-10-15 1172 load_bias &= ~(alignment - 1);
5f501d555653f89 Kees Cook 2021-11-08 1173 elf_flags |= MAP_FIXED_NOREPLACE;
eab09532d400906 Kees Cook 2017-07-10 1174 } else
eab09532d400906 Kees Cook 2017-07-10 1175 load_bias = 0;
3545deff0ec7a37 Kees Cook 2024-05-08 1176 }
eab09532d400906 Kees Cook 2017-07-10 1177
eab09532d400906 Kees Cook 2017-07-10 1178 /*
eab09532d400906 Kees Cook 2017-07-10 1179 * Since load_bias is used for all subsequent loading
eab09532d400906 Kees Cook 2017-07-10 1180 * calculations, we must lower it by the first vaddr
eab09532d400906 Kees Cook 2017-07-10 1181 * so that the remaining calculations based on the
eab09532d400906 Kees Cook 2017-07-10 1182 * ELF vaddrs will be correctly offset. The result
eab09532d400906 Kees Cook 2017-07-10 1183 * is then page aligned.
eab09532d400906 Kees Cook 2017-07-10 1184 */
eab09532d400906 Kees Cook 2017-07-10 1185 load_bias = ELF_PAGESTART(load_bias - vaddr);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1186 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1187
585a018627b4d7e Eric W. Biederman 2023-09-28 1188 error = elf_load(bprm->file, load_bias + vaddr, elf_ppnt,
a87938b2e246b81 Michael Davidson 2015-04-14 1189 elf_prot, elf_flags, total_size);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1190 if (BAD_ADDR(error)) {
dc64cc12bcd1421 Bo Liu 2022-11-14 1191 retval = IS_ERR_VALUE(error) ?
b140f25108a8b11 Alexey Kuznetsov 2007-05-08 1192 PTR_ERR((void*)error) : -EINVAL;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1193 goto out_free_dentry;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1194 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1195
2b4bfbe0967697c Akira Kawata 2022-01-27 1196 if (first_pt_load) {
2b4bfbe0967697c Akira Kawata 2022-01-27 1197 first_pt_load = 0;
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 1198 if (elf_ex->e_type == ET_DYN) {
^1da177e4c3f415 Linus Torvalds 2005-04-16 1199 load_bias += error -
^1da177e4c3f415 Linus Torvalds 2005-04-16 1200 ELF_PAGESTART(load_bias + vaddr);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1201 reloc_func_desc = load_bias;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1202 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1203 }
0da1d5002745cdc Akira Kawata 2022-01-27 1204
0da1d5002745cdc Akira Kawata 2022-01-27 1205 /*
0da1d5002745cdc Akira Kawata 2022-01-27 1206 * Figure out which segment in the file contains the Program
0da1d5002745cdc Akira Kawata 2022-01-27 1207 * Header table, and map to the associated memory address.
0da1d5002745cdc Akira Kawata 2022-01-27 1208 */
0da1d5002745cdc Akira Kawata 2022-01-27 1209 if (elf_ppnt->p_offset <= elf_ex->e_phoff &&
0da1d5002745cdc Akira Kawata 2022-01-27 1210 elf_ex->e_phoff < elf_ppnt->p_offset + elf_ppnt->p_filesz) {
0da1d5002745cdc Akira Kawata 2022-01-27 1211 phdr_addr = elf_ex->e_phoff - elf_ppnt->p_offset +
0da1d5002745cdc Akira Kawata 2022-01-27 1212 elf_ppnt->p_vaddr;
0da1d5002745cdc Akira Kawata 2022-01-27 1213 }
0da1d5002745cdc Akira Kawata 2022-01-27 1214
^1da177e4c3f415 Linus Torvalds 2005-04-16 1215 k = elf_ppnt->p_vaddr;
f67ef446291a091 Alexey Dobriyan 2020-01-30 1216 if ((elf_ppnt->p_flags & PF_X) && k < start_code)
f4e5cc2c44bf760 Jesper Juhl 2006-06-23 1217 start_code = k;
f4e5cc2c44bf760 Jesper Juhl 2006-06-23 1218 if (start_data < k)
f4e5cc2c44bf760 Jesper Juhl 2006-06-23 1219 start_data = k;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1220
^1da177e4c3f415 Linus Torvalds 2005-04-16 1221 /*
^1da177e4c3f415 Linus Torvalds 2005-04-16 1222 * Check to see if the section's size will overflow the
^1da177e4c3f415 Linus Torvalds 2005-04-16 1223 * allowed task size. Note that p_filesz must always be
^1da177e4c3f415 Linus Torvalds 2005-04-16 1224 * <= p_memsz so it is only necessary to check p_memsz.
^1da177e4c3f415 Linus Torvalds 2005-04-16 1225 */
ce51059be56f637 Chuck Ebbert 2006-07-03 1226 if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
^1da177e4c3f415 Linus Torvalds 2005-04-16 1227 elf_ppnt->p_memsz > TASK_SIZE ||
^1da177e4c3f415 Linus Torvalds 2005-04-16 1228 TASK_SIZE - elf_ppnt->p_memsz < k) {
^1da177e4c3f415 Linus Torvalds 2005-04-16 1229 /* set_brk can never work. Avoid overflows. */
b140f25108a8b11 Alexey Kuznetsov 2007-05-08 1230 retval = -EINVAL;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1231 goto out_free_dentry;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1232 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1233
^1da177e4c3f415 Linus Torvalds 2005-04-16 1234 k = elf_ppnt->p_vaddr + elf_ppnt->p_filesz;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1235
^1da177e4c3f415 Linus Torvalds 2005-04-16 1236 if ((elf_ppnt->p_flags & PF_X) && end_code < k)
^1da177e4c3f415 Linus Torvalds 2005-04-16 1237 end_code = k;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1238 if (end_data < k)
^1da177e4c3f415 Linus Torvalds 2005-04-16 1239 end_data = k;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1240 k = elf_ppnt->p_vaddr + elf_ppnt->p_memsz;
585a018627b4d7e Eric W. Biederman 2023-09-28 1241 if (k > elf_brk)
^1da177e4c3f415 Linus Torvalds 2005-04-16 1242 elf_brk = k;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1243 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1244
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 1245 e_entry = elf_ex->e_entry + load_bias;
0da1d5002745cdc Akira Kawata 2022-01-27 1246 phdr_addr += load_bias;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1247 elf_brk += load_bias;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1248 start_code += load_bias;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1249 end_code += load_bias;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1250 start_data += load_bias;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1251 end_data += load_bias;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1252
cc338010a233c08 Alexey Dobriyan 2019-05-14 1253 if (interpreter) {
c69bcc932ef3568 Alexey Dobriyan 2020-04-06 1254 elf_entry = load_elf_interp(interp_elf_ex,
^1da177e4c3f415 Linus Torvalds 2005-04-16 1255 interpreter,
fe0f67660ee9c99 Dave Martin 2020-03-16 1256 load_bias, interp_elf_phdata,
fe0f67660ee9c99 Dave Martin 2020-03-16 1257 &arch_state);
dc64cc12bcd1421 Bo Liu 2022-11-14 1258 if (!IS_ERR_VALUE(elf_entry)) {
cc503c1b43e002e Jiri Kosina 2008-01-30 1259 /*
cc503c1b43e002e Jiri Kosina 2008-01-30 1260 * load_elf_interp() returns relocation
cc503c1b43e002e Jiri Kosina 2008-01-30 1261 * adjustment
cc503c1b43e002e Jiri Kosina 2008-01-30 1262 */
cc503c1b43e002e Jiri Kosina 2008-01-30 1263 interp_load_addr = elf_entry;
c69bcc932ef3568 Alexey Dobriyan 2020-04-06 1264 elf_entry += interp_elf_ex->e_entry;
cc503c1b43e002e Jiri Kosina 2008-01-30 1265 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1266 if (BAD_ADDR(elf_entry)) {
dc64cc12bcd1421 Bo Liu 2022-11-14 1267 retval = IS_ERR_VALUE(elf_entry) ?
ce51059be56f637 Chuck Ebbert 2006-07-03 1268 (int)elf_entry : -EINVAL;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1269 goto out_free_dentry;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1270 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1271 reloc_func_desc = interp_load_addr;
^1da177e4c3f415 Linus Torvalds 2005-04-16 1272
0357ef03c94ef83 Amir Goldstein 2024-11-28 1273 exe_file_allow_write_access(interpreter);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1274 fput(interpreter);
0693ffebcfe5ac7 Alexey Dobriyan 2020-04-06 1275
0693ffebcfe5ac7 Alexey Dobriyan 2020-04-06 1276 kfree(interp_elf_ex);
aa0d1564b10f916 Alexey Dobriyan 2020-04-06 1277 kfree(interp_elf_phdata);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1278 } else {
a62c5b1b6647ea0 Alexey Dobriyan 2020-01-30 1279 elf_entry = e_entry;
5342fba5412cead Suresh Siddha 2006-02-26 1280 if (BAD_ADDR(elf_entry)) {
ce51059be56f637 Chuck Ebbert 2006-07-03 1281 retval = -EINVAL;
5342fba5412cead Suresh Siddha 2006-02-26 1282 goto out_free_dentry;
5342fba5412cead Suresh Siddha 2006-02-26 1283 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1284 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 1285
^1da177e4c3f415 Linus Torvalds 2005-04-16 1286 kfree(elf_phdata);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1287
^1da177e4c3f415 Linus Torvalds 2005-04-16 1288 set_binfmt(&elf_format);
^1da177e4c3f415 Linus Torvalds 2005-04-16 1289
:::::: The code at line 1140 was first introduced by commit
:::::: eab09532d40090698b05a07c1c87f39fdbc5fab5 binfmt_elf: use ELF_ET_DYN_BASE only for PIE
:::::: TO: Kees Cook <keescook@chromium.org>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [akpm-mm:mm-unstable 34/207] fs/binfmt_elf.c:1140:17: warning: implicit conversion from 'unsigned long long' to 'unsigned long' changes value from 4294967296 to 0
2026-03-07 12:21 [akpm-mm:mm-unstable 34/207] fs/binfmt_elf.c:1140:17: warning: implicit conversion from 'unsigned long long' to 'unsigned long' changes value from 4294967296 to 0 kernel test robot
@ 2026-03-08 21:19 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2026-03-08 21:19 UTC (permalink / raw)
To: kernel test robot
Cc: Jianhui Zhou, llvm, oe-kbuild-all, David Hildenbrand,
Linux Memory Management List
On Sat, 07 Mar 2026 20:21:02 +0800 kernel test robot <lkp@intel.com> wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable
> head: 49cb736d092aaa856283e33b78ec3afb3964d82f
> commit: cd9119a9480d9d93fdf06792f8f9917cc4f9999c [34/207] mm/userfaultfd: fix hugetlb fault mutex hash calculation
> config: powerpc-currituck_defconfig (https://download.01.org/0day-ci/archive/20260307/202603072018.Dl1xONhs-lkp@intel.com/config)
> compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project c32caeec8158d634bb71ab8911a6031248b9fc47)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260307/202603072018.Dl1xONhs-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/202603072018.Dl1xONhs-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
> In file included from fs/binfmt_elf.c:31:
> include/linux/hugetlb.h:1214:9: error: call to undeclared function 'linear_page_index'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
> 1214 | return linear_page_index(vma, address);
> | ^
> In file included from fs/binfmt_elf.c:32:
Thanks, I expect v2 will fix this.
--- a/include/linux/hugetlb.h~mm-userfaultfd-fix-hugetlb-fault-mutex-hash-calculation-v2
+++ a/include/linux/hugetlb.h
@@ -1208,12 +1208,6 @@ static inline unsigned int huge_page_shi
return PAGE_SHIFT;
}
-static inline pgoff_t vma_hugecache_offset(struct hstate *h,
- struct vm_area_struct *vma, unsigned long address)
-{
- return linear_page_index(vma, address);
-}
-
static inline bool hstate_is_gigantic(struct hstate *h)
{
return false;
_
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-08 21:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-07 12:21 [akpm-mm:mm-unstable 34/207] fs/binfmt_elf.c:1140:17: warning: implicit conversion from 'unsigned long long' to 'unsigned long' changes value from 4294967296 to 0 kernel test robot
2026-03-08 21:19 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox