lkml.org 
[lkml]   [2018]   [Apr]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] prctl: fix compat handling for prctl
Hi Li,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.17-rc1 next-20180418]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Li-Bin/prctl-fix-compat-handling-for-prctl/20180419-004502
config: x86_64-randconfig-x002-201815 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

All errors (new ones prefixed by >>):

kernel/sys.c: In function 'prctl_set_mm_map':
>> kernel/sys.c:2009:6: error: implicit declaration of function 'is_compat_task'; did you mean 'is_idle_task'? [-Werror=implicit-function-declaration]
if (is_compat_task()) {
^~~~~~~~~~~~~~
is_idle_task
cc1: some warnings being treated as errors

vim +2009 kernel/sys.c

1989
1990 #ifdef CONFIG_CHECKPOINT_RESTORE
1991 static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data_size)
1992 {
1993 struct prctl_mm_map prctl_map = { .exe_fd = (u32)-1, };
1994 unsigned long user_auxv[AT_VECTOR_SIZE];
1995 struct mm_struct *mm = current->mm;
1996 int error;
1997
1998 BUILD_BUG_ON(sizeof(user_auxv) != sizeof(mm->saved_auxv));
1999 BUILD_BUG_ON(sizeof(struct prctl_mm_map) > 256);
2000
2001 if (opt == PR_SET_MM_MAP_SIZE)
2002 return put_user((unsigned int)sizeof(prctl_map),
2003 (unsigned int __user *)addr);
2004
2005 if (data_size != sizeof(prctl_map))
2006 return -EINVAL;
2007
2008 #ifdef CONFIG_COMPAT
> 2009 if (is_compat_task()) {
2010 struct compat_prctl_mm_map prctl_map32;
2011 if (copy_from_user(&prctl_map32, addr, sizeof(prctl_map32)))
2012 return -EFAULT;
2013
2014 prctl_map.start_code = prctl_map32.start_code;
2015 prctl_map.end_code = prctl_map32.end_code;
2016 prctl_map.start_data = prctl_map32.start_data;
2017 prctl_map.end_data = prctl_map32.end_data;
2018 prctl_map.start_brk = prctl_map32.start_brk;
2019 prctl_map.brk = prctl_map32.brk;
2020 prctl_map.start_stack = prctl_map32.start_stack;
2021 prctl_map.arg_start = prctl_map32.arg_start;
2022 prctl_map.arg_end = prctl_map32.arg_end;
2023 prctl_map.env_start = prctl_map32.env_start;
2024 prctl_map.env_end = prctl_map32.env_end;
2025 prctl_map.auxv = compat_ptr(prctl_map32.auxv);
2026 prctl_map.auxv_size = prctl_map32.auxv_size;
2027 prctl_map.exe_fd = prctl_map32.exe_fd;
2028 } else
2029 #endif
2030 if (copy_from_user(&prctl_map, addr, sizeof(prctl_map)))
2031 return -EFAULT;
2032
2033 error = validate_prctl_map(&prctl_map);
2034 if (error)
2035 return error;
2036
2037 if (prctl_map.auxv_size) {
2038 memset(user_auxv, 0, sizeof(user_auxv));
2039 if (copy_from_user(user_auxv,
2040 (const void __user *)prctl_map.auxv,
2041 prctl_map.auxv_size))
2042 return -EFAULT;
2043
2044 /* Last entry must be AT_NULL as specification requires */
2045 user_auxv[AT_VECTOR_SIZE - 2] = AT_NULL;
2046 user_auxv[AT_VECTOR_SIZE - 1] = AT_NULL;
2047 }
2048
2049 if (prctl_map.exe_fd != (u32)-1) {
2050 error = prctl_set_mm_exe_file(mm, prctl_map.exe_fd);
2051 if (error)
2052 return error;
2053 }
2054
2055 down_write(&mm->mmap_sem);
2056
2057 /*
2058 * We don't validate if these members are pointing to
2059 * real present VMAs because application may have correspond
2060 * VMAs already unmapped and kernel uses these members for statistics
2061 * output in procfs mostly, except
2062 *
2063 * - @start_brk/@brk which are used in do_brk but kernel lookups
2064 * for VMAs when updating these memvers so anything wrong written
2065 * here cause kernel to swear at userspace program but won't lead
2066 * to any problem in kernel itself
2067 */
2068
2069 mm->start_code = prctl_map.start_code;
2070 mm->end_code = prctl_map.end_code;
2071 mm->start_data = prctl_map.start_data;
2072 mm->end_data = prctl_map.end_data;
2073 mm->start_brk = prctl_map.start_brk;
2074 mm->brk = prctl_map.brk;
2075 mm->start_stack = prctl_map.start_stack;
2076 mm->arg_start = prctl_map.arg_start;
2077 mm->arg_end = prctl_map.arg_end;
2078 mm->env_start = prctl_map.env_start;
2079 mm->env_end = prctl_map.env_end;
2080
2081 /*
2082 * Note this update of @saved_auxv is lockless thus
2083 * if someone reads this member in procfs while we're
2084 * updating -- it may get partly updated results. It's
2085 * known and acceptable trade off: we leave it as is to
2086 * not introduce additional locks here making the kernel
2087 * more complex.
2088 */
2089 if (prctl_map.auxv_size)
2090 memcpy(mm->saved_auxv, user_auxv, sizeof(user_auxv));
2091
2092 up_write(&mm->mmap_sem);
2093 return 0;
2094 }
2095 #endif /* CONFIG_CHECKPOINT_RESTORE */
2096

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[unhandled content-type:application/gzip]
\
 
 \ /
  Last update: 2018-04-18 19:37    [W:0.081 / U:0.404 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site