tree:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
linux-4.9.y
head: d3e70b39d31a36dd7611410e535bd0762f3824f9
commit: 2f7ed3b41f24ea9a083e73b715e1e0277d8d14bb [1042/1178] vt: keyboard, simplify
vt_kdgkbsent
config: m68k-randconfig-s032-20201118 (attached as .config)
compiler: m68k-linux-gcc (GCC) 7.5.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-123-g626c4742-dirty
#
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gi...
git remote add linux-stable-rc
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git fetch --no-tags linux-stable-rc linux-4.9.y
git checkout 2f7ed3b41f24ea9a083e73b715e1e0277d8d14bb
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-7.5.0 make.cross C=1
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=m68k
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
"sparse warnings: (new ones prefixed by >>)"
drivers/tty/vt/keyboard.c:1653:21: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1653:21: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1653:21: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1653:21: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void * @@ got unsigned int [noderef]
<asn:1> * @@
drivers/tty/vt/keyboard.c:1653:21: sparse: expected void *
drivers/tty/vt/keyboard.c:1653:21: sparse: got unsigned int [noderef] <asn:1>
*
drivers/tty/vt/keyboard.c:1655:27: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void * @@ got struct kbdiacr [noderef]
<asn:1> * @@
drivers/tty/vt/keyboard.c:1655:27: sparse: expected void *
drivers/tty/vt/keyboard.c:1655:27: sparse: got struct kbdiacr [noderef]
<asn:1> *
drivers/tty/vt/keyboard.c:1680:21: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1680:21: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1680:21: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1680:21: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void * @@ got unsigned int [noderef]
<asn:1> * @@
drivers/tty/vt/keyboard.c:1680:21: sparse: expected void *
drivers/tty/vt/keyboard.c:1680:21: sparse: got unsigned int [noderef] <asn:1>
*
drivers/tty/vt/keyboard.c:1682:26: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void * @@ got struct kbdiacruc [noderef]
<asn:1> * @@
drivers/tty/vt/keyboard.c:1682:26: sparse: expected void *
drivers/tty/vt/keyboard.c:1682:26: sparse: got struct kbdiacruc [noderef]
<asn:1> *
drivers/tty/vt/keyboard.c:1698:21: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1698:21: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1698:21: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1698:21: sparse: sparse: incorrect type in argument 2
(different address spaces) @@ expected void const * @@ got unsigned int [noderef]
<asn:1> * @@
drivers/tty/vt/keyboard.c:1698:21: sparse: expected void const *
drivers/tty/vt/keyboard.c:1698:21: sparse: got unsigned int [noderef] <asn:1>
*
drivers/tty/vt/keyboard.c:1736:21: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1736:21: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1736:21: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1736:21: sparse: sparse: incorrect type in argument 2
(different address spaces) @@ expected void const * @@ got unsigned int [noderef]
<asn:1> * @@
drivers/tty/vt/keyboard.c:1736:21: sparse: expected void const *
drivers/tty/vt/keyboard.c:1736:21: sparse: got unsigned int [noderef] <asn:1>
*
drivers/tty/vt/keyboard.c:1836:13: sparse: sparse: incorrect type in argument 2
(different address spaces) @@ expected void const * @@ got struct kbkeycode
[noderef] <asn:1> *user_kbkc @@
drivers/tty/vt/keyboard.c:1836:13: sparse: expected void const *
drivers/tty/vt/keyboard.c:1836:13: sparse: got struct kbkeycode [noderef]
<asn:1> *user_kbkc
drivers/tty/vt/keyboard.c:1842:30: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1842:30: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1842:30: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1842:30: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void * @@ got unsigned int [noderef]
<asn:1> * @@
drivers/tty/vt/keyboard.c:1842:30: sparse: expected void *
drivers/tty/vt/keyboard.c:1842:30: sparse: got unsigned int [noderef] <asn:1>
*
drivers/tty/vt/keyboard.c:1865:13: sparse: sparse: incorrect type in argument 2
(different address spaces) @@ expected void const * @@ got struct kbentry
[noderef] <asn:1> *user_kbe @@
drivers/tty/vt/keyboard.c:1865:13: sparse: expected void const *
drivers/tty/vt/keyboard.c:1865:13: sparse: got struct kbentry [noderef]
<asn:1> *user_kbe
drivers/tty/vt/keyboard.c:1883:24: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1883:24: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1883:24: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:1883:24: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void * @@ got unsigned short [noderef]
<asn:1> * @@
drivers/tty/vt/keyboard.c:1883:24: sparse: expected void *
drivers/tty/vt/keyboard.c:1883:24: sparse: got unsigned short [noderef]
<asn:1> *
drivers/tty/vt/keyboard.c:1984:13: sparse: sparse: incorrect type in argument 2
(different address spaces) @@ expected void const * @@ got struct kbsentry
[noderef] <asn:1> *user_kdgkb @@
drivers/tty/vt/keyboard.c:1984:13: sparse: expected void const *
drivers/tty/vt/keyboard.c:1984:13: sparse: got struct kbsentry [noderef]
<asn:1> *user_kdgkb
> drivers/tty/vt/keyboard.c:1996:23: sparse: sparse: incorrect type
in argument 1 (different address spaces) @@ expected void * @@ got unsigned char
[noderef] <asn:1> * @@
drivers/tty/vt/keyboard.c:1996:23: sparse:
expected void *
drivers/tty/vt/keyboard.c:1996:23: sparse: got unsigned char [noderef]
<asn:1> *
drivers/tty/vt/keyboard.c:2098:24: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:2098:24: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:2098:24: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:2098:24: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void * @@ got char [noderef] <asn:1>
* @@
drivers/tty/vt/keyboard.c:2098:24: sparse: expected void *
drivers/tty/vt/keyboard.c:2098:24: sparse: got char [noderef] <asn:1> *
drivers/tty/vt/keyboard.c:2116:24: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:2116:24: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:2116:24: sparse: sparse: cast removes address space
'<asn:1>' of expression
drivers/tty/vt/keyboard.c:2116:24: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void * @@ got char [noderef] <asn:1>
* @@
drivers/tty/vt/keyboard.c:2116:24: sparse: expected void *
drivers/tty/vt/keyboard.c:2116:24: sparse: got char [noderef] <asn:1> *
drivers/tty/vt/keyboard.c: In function 'k_fn':
drivers/tty/vt/keyboard.c:714:22: warning: comparison is always true due to limited
range of data type [-Wtype-limits]
if ((unsigned)value < ARRAY_SIZE(func_table)) {
^
vim +1996 drivers/tty/vt/keyboard.c
1961
1962 /* FIXME: This one needs untangling and locking */
1963 int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
1964 {
1965 struct kbsentry *kbs;
1966 u_char *q;
1967 int sz, fnw_sz;
1968 int delta;
1969 char *first_free, *fj, *fnw;
1970 int i, j, k;
1971 int ret;
1972 unsigned long flags;
1973
1974 if (!capable(CAP_SYS_TTY_CONFIG))
1975 perm = 0;
1976
1977 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
1978 if (!kbs) {
1979 ret = -ENOMEM;
1980 goto reterr;
1981 }
1982
1983 /* we mostly copy too much here (512bytes), but who cares ;) */
1984 if (copy_from_user(kbs, user_kdgkb, sizeof(struct kbsentry))) {
1985 ret = -EFAULT;
1986 goto reterr;
1987 }
1988 kbs->kb_string[sizeof(kbs->kb_string)-1] = '\0';
1989 i = kbs->kb_func;
1990
1991 switch (cmd) {
1992 case KDGKBSENT: {
1993 /* size should have been a struct member */
1994 unsigned char *from = func_table[i] ? : "";
1995
1996 ret = copy_to_user(user_kdgkb->kb_string, from,
1997 strlen(from) + 1) ? -EFAULT : 0;
1998
1999 goto reterr;
2000 }
2001 case KDSKBSENT:
2002 if (!perm) {
2003 ret = -EPERM;
2004 goto reterr;
2005 }
2006
2007 fnw = NULL;
2008 fnw_sz = 0;
2009 /* race aginst other writers */
2010 again:
2011 spin_lock_irqsave(&func_buf_lock, flags);
2012 q = func_table[i];
2013
2014 /* fj pointer to next entry after 'q' */
2015 first_free = funcbufptr + (funcbufsize - funcbufleft);
2016 for (j = i+1; j < MAX_NR_FUNC && !func_table[j]; j++)
2017 ;
2018 if (j < MAX_NR_FUNC)
2019 fj = func_table[j];
2020 else
2021 fj = first_free;
2022 /* buffer usage increase by new entry */
2023 delta = (q ? -strlen(q) : 1) + strlen(kbs->kb_string);
2024
2025 if (delta <= funcbufleft) { /* it fits in current buf */
2026 if (j < MAX_NR_FUNC) {
2027 /* make enough space for new entry at 'fj' */
2028 memmove(fj + delta, fj, first_free - fj);
2029 for (k = j; k < MAX_NR_FUNC; k++)
2030 if (func_table[k])
2031 func_table[k] += delta;
2032 }
2033 if (!q)
2034 func_table[i] = fj;
2035 funcbufleft -= delta;
2036 } else { /* allocate a larger buffer */
2037 sz = 256;
2038 while (sz < funcbufsize - funcbufleft + delta)
2039 sz <<= 1;
2040 if (fnw_sz != sz) {
2041 spin_unlock_irqrestore(&func_buf_lock, flags);
2042 kfree(fnw);
2043 fnw = kmalloc(sz, GFP_KERNEL);
2044 fnw_sz = sz;
2045 if (!fnw) {
2046 ret = -ENOMEM;
2047 goto reterr;
2048 }
2049 goto again;
2050 }
2051
2052 if (!q)
2053 func_table[i] = fj;
2054 /* copy data before insertion point to new location */
2055 if (fj > funcbufptr)
2056 memmove(fnw, funcbufptr, fj - funcbufptr);
2057 for (k = 0; k < j; k++)
2058 if (func_table[k])
2059 func_table[k] = fnw + (func_table[k] - funcbufptr);
2060
2061 /* copy data after insertion point to new location */
2062 if (first_free > fj) {
2063 memmove(fnw + (fj - funcbufptr) + delta, fj, first_free - fj);
2064 for (k = j; k < MAX_NR_FUNC; k++)
2065 if (func_table[k])
2066 func_table[k] = fnw + (func_table[k] - funcbufptr) + delta;
2067 }
2068 if (funcbufptr != func_buf)
2069 kfree(funcbufptr);
2070 funcbufptr = fnw;
2071 funcbufleft = funcbufleft - delta + sz - funcbufsize;
2072 funcbufsize = sz;
2073 }
2074 /* finally insert item itself */
2075 strcpy(func_table[i], kbs->kb_string);
2076 spin_unlock_irqrestore(&func_buf_lock, flags);
2077 break;
2078 }
2079 ret = 0;
2080 reterr:
2081 kfree(kbs);
2082 return ret;
2083 }
2084
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org