* fs/proc/vmcore.c:161:34: sparse: sparse: incorrect type in argument 1 (different address spaces)
@ 2021-11-24 15:42 kernel test robot
2021-11-24 16:45 ` David Hildenbrand
0 siblings, 1 reply; 4+ messages in thread
From: kernel test robot @ 2021-11-24 15:42 UTC (permalink / raw)
To: David Hildenbrand
Cc: kbuild-all, linux-kernel, Andrew Morton, Linux Memory Management List
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 5d9f4cf36721aba199975a9be7863a3ff5cd4b59
commit: c1e63117711977cc4295b2ce73de29dd17066c82 proc/vmcore: fix clearing user buffer by properly using clear_user()
date: 4 days ago
config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20211124/202111242331.x19Qywph-lkp@intel.com/config)
compiler: ia64-linux-gcc (GCC) 11.2.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.4-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c1e63117711977cc4295b2ce73de29dd17066c82
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout c1e63117711977cc4295b2ce73de29dd17066c82
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=ia64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> fs/proc/vmcore.c:161:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __user *p @@ got char *buf @@
fs/proc/vmcore.c:161:34: sparse: expected void const [noderef] __user *p
fs/proc/vmcore.c:161:34: sparse: got char *buf
>> fs/proc/vmcore.c:161:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __user * @@ got char *buf @@
fs/proc/vmcore.c:161:34: sparse: expected void [noderef] __user *
fs/proc/vmcore.c:161:34: sparse: got char *buf
vim +161 fs/proc/vmcore.c
133
134 /* Reads a page from the oldmem device from given offset. */
135 ssize_t read_from_oldmem(char *buf, size_t count,
136 u64 *ppos, int userbuf,
137 bool encrypted)
138 {
139 unsigned long pfn, offset;
140 size_t nr_bytes;
141 ssize_t read = 0, tmp;
142
143 if (!count)
144 return 0;
145
146 offset = (unsigned long)(*ppos % PAGE_SIZE);
147 pfn = (unsigned long)(*ppos / PAGE_SIZE);
148
149 down_read(&vmcore_cb_rwsem);
150 do {
151 if (count > (PAGE_SIZE - offset))
152 nr_bytes = PAGE_SIZE - offset;
153 else
154 nr_bytes = count;
155
156 /* If pfn is not ram, return zeros for sparse dump files */
157 if (!pfn_is_ram(pfn)) {
158 tmp = 0;
159 if (!userbuf)
160 memset(buf, 0, nr_bytes);
> 161 else if (clear_user(buf, nr_bytes))
162 tmp = -EFAULT;
163 } else {
164 if (encrypted)
165 tmp = copy_oldmem_page_encrypted(pfn, buf,
166 nr_bytes,
167 offset,
168 userbuf);
169 else
170 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
171 offset, userbuf);
172 }
173 if (tmp < 0) {
174 up_read(&vmcore_cb_rwsem);
175 return tmp;
176 }
177
178 *ppos += nr_bytes;
179 count -= nr_bytes;
180 buf += nr_bytes;
181 read += nr_bytes;
182 ++pfn;
183 offset = 0;
184 } while (count);
185
186 up_read(&vmcore_cb_rwsem);
187 return read;
188 }
189
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: fs/proc/vmcore.c:161:34: sparse: sparse: incorrect type in argument 1 (different address spaces)
2021-11-24 15:42 fs/proc/vmcore.c:161:34: sparse: sparse: incorrect type in argument 1 (different address spaces) kernel test robot
@ 2021-11-24 16:45 ` David Hildenbrand
2021-12-04 16:58 ` Matthew Wilcox
0 siblings, 1 reply; 4+ messages in thread
From: David Hildenbrand @ 2021-11-24 16:45 UTC (permalink / raw)
To: kernel test robot
Cc: kbuild-all, linux-kernel, Andrew Morton, Linux Memory Management List
On 24.11.21 16:42, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 5d9f4cf36721aba199975a9be7863a3ff5cd4b59
> commit: c1e63117711977cc4295b2ce73de29dd17066c82 proc/vmcore: fix clearing user buffer by properly using clear_user()
> date: 4 days ago
> config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20211124/202111242331.x19Qywph-lkp@intel.com/config)
> compiler: ia64-linux-gcc (GCC) 11.2.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.4-dirty
> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c1e63117711977cc4295b2ce73de29dd17066c82
> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout c1e63117711977cc4295b2ce73de29dd17066c82
> # save the config file to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=ia64
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
>
> sparse warnings: (new ones prefixed by >>)
>>> fs/proc/vmcore.c:161:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __user *p @@ got char *buf @@
> fs/proc/vmcore.c:161:34: sparse: expected void const [noderef] __user *p
> fs/proc/vmcore.c:161:34: sparse: got char *buf
>>> fs/proc/vmcore.c:161:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __user * @@ got char *buf @@
> fs/proc/vmcore.c:161:34: sparse: expected void [noderef] __user *
> fs/proc/vmcore.c:161:34: sparse: got char *buf
>
> vim +161 fs/proc/vmcore.c
>
> 133
> 134 /* Reads a page from the oldmem device from given offset. */
> 135 ssize_t read_from_oldmem(char *buf, size_t count,
> 136 u64 *ppos, int userbuf,
> 137 bool encrypted)
> 138 {
> 139 unsigned long pfn, offset;
> 140 size_t nr_bytes;
> 141 ssize_t read = 0, tmp;
> 142
> 143 if (!count)
> 144 return 0;
> 145
> 146 offset = (unsigned long)(*ppos % PAGE_SIZE);
> 147 pfn = (unsigned long)(*ppos / PAGE_SIZE);
> 148
> 149 down_read(&vmcore_cb_rwsem);
> 150 do {
> 151 if (count > (PAGE_SIZE - offset))
> 152 nr_bytes = PAGE_SIZE - offset;
> 153 else
> 154 nr_bytes = count;
> 155
> 156 /* If pfn is not ram, return zeros for sparse dump files */
> 157 if (!pfn_is_ram(pfn)) {
> 158 tmp = 0;
> 159 if (!userbuf)
> 160 memset(buf, 0, nr_bytes);
> > 161 else if (clear_user(buf, nr_bytes))
> 162 tmp = -EFAULT;
> 163 } else {
> 164 if (encrypted)
> 165 tmp = copy_oldmem_page_encrypted(pfn, buf,
> 166 nr_bytes,
> 167 offset,
> 168 userbuf);
> 169 else
> 170 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
> 171 offset, userbuf);
> 172 }
> 173 if (tmp < 0) {
> 174 up_read(&vmcore_cb_rwsem);
> 175 return tmp;
> 176 }
> 177
> 178 *ppos += nr_bytes;
> 179 count -= nr_bytes;
> 180 buf += nr_bytes;
> 181 read += nr_bytes;
> 182 ++pfn;
> 183 offset = 0;
> 184 } while (count);
> 185
> 186 up_read(&vmcore_cb_rwsem);
> 187 return read;
> 188 }
> 189
Sparse is wrong as it doesn't see the bigger picture. "int userbuf"
tells us what we're actually dealing with ...
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: fs/proc/vmcore.c:161:34: sparse: sparse: incorrect type in argument 1 (different address spaces)
2021-11-24 16:45 ` David Hildenbrand
@ 2021-12-04 16:58 ` Matthew Wilcox
0 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2021-12-04 16:58 UTC (permalink / raw)
To: David Hildenbrand
Cc: kernel test robot, kbuild-all, linux-kernel, Andrew Morton,
Linux Memory Management List
On Wed, Nov 24, 2021 at 05:45:45PM +0100, David Hildenbrand wrote:
> On 24.11.21 16:42, kernel test robot wrote:
> > sparse warnings: (new ones prefixed by >>)
> >>> fs/proc/vmcore.c:161:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __user *p @@ got char *buf @@
> > fs/proc/vmcore.c:161:34: sparse: expected void const [noderef] __user *p
> > 159 if (!userbuf)
> > 160 memset(buf, 0, nr_bytes);
> > > 161 else if (clear_user(buf, nr_bytes))
> > 162 tmp = -EFAULT;
> > 163 } else {
>
> Sparse is wrong as it doesn't see the bigger picture. "int userbuf"
> tells us what we're actually dealing with ...
Sparse is pointing to a deeper problem here. We should be using an
iov_iter throughout vmcore.c, but that's kind of a big project ...
^ permalink raw reply [flat|nested] 4+ messages in thread
* fs/proc/vmcore.c:161:34: sparse: sparse: incorrect type in argument 1 (different address spaces)
@ 2021-12-04 13:45 kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-12-04 13:45 UTC (permalink / raw)
To: David Hildenbrand
Cc: kbuild-all, linux-kernel, Andrew Morton, Linux Memory Management List
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 12119cfa1052d512a92524e90ebee85029a918f8
commit: c1e63117711977cc4295b2ce73de29dd17066c82 proc/vmcore: fix clearing user buffer by properly using clear_user()
date: 2 weeks ago
config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20211204/202112042119.Lqv1OiGv-lkp@intel.com/config)
compiler: ia64-linux-gcc (GCC) 11.2.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.4-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c1e63117711977cc4295b2ce73de29dd17066c82
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout c1e63117711977cc4295b2ce73de29dd17066c82
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=ia64 SHELL=/bin/bash fs/proc/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> fs/proc/vmcore.c:161:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __user *p @@ got char *buf @@
fs/proc/vmcore.c:161:34: sparse: expected void const [noderef] __user *p
fs/proc/vmcore.c:161:34: sparse: got char *buf
>> fs/proc/vmcore.c:161:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __user * @@ got char *buf @@
fs/proc/vmcore.c:161:34: sparse: expected void [noderef] __user *
fs/proc/vmcore.c:161:34: sparse: got char *buf
vim +161 fs/proc/vmcore.c
133
134 /* Reads a page from the oldmem device from given offset. */
135 ssize_t read_from_oldmem(char *buf, size_t count,
136 u64 *ppos, int userbuf,
137 bool encrypted)
138 {
139 unsigned long pfn, offset;
140 size_t nr_bytes;
141 ssize_t read = 0, tmp;
142
143 if (!count)
144 return 0;
145
146 offset = (unsigned long)(*ppos % PAGE_SIZE);
147 pfn = (unsigned long)(*ppos / PAGE_SIZE);
148
149 down_read(&vmcore_cb_rwsem);
150 do {
151 if (count > (PAGE_SIZE - offset))
152 nr_bytes = PAGE_SIZE - offset;
153 else
154 nr_bytes = count;
155
156 /* If pfn is not ram, return zeros for sparse dump files */
157 if (!pfn_is_ram(pfn)) {
158 tmp = 0;
159 if (!userbuf)
160 memset(buf, 0, nr_bytes);
> 161 else if (clear_user(buf, nr_bytes))
162 tmp = -EFAULT;
163 } else {
164 if (encrypted)
165 tmp = copy_oldmem_page_encrypted(pfn, buf,
166 nr_bytes,
167 offset,
168 userbuf);
169 else
170 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
171 offset, userbuf);
172 }
173 if (tmp < 0) {
174 up_read(&vmcore_cb_rwsem);
175 return tmp;
176 }
177
178 *ppos += nr_bytes;
179 count -= nr_bytes;
180 buf += nr_bytes;
181 read += nr_bytes;
182 ++pfn;
183 offset = 0;
184 } while (count);
185
186 up_read(&vmcore_cb_rwsem);
187 return read;
188 }
189
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-04 16:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 15:42 fs/proc/vmcore.c:161:34: sparse: sparse: incorrect type in argument 1 (different address spaces) kernel test robot
2021-11-24 16:45 ` David Hildenbrand
2021-12-04 16:58 ` Matthew Wilcox
2021-12-04 13:45 kernel test robot
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).