Re: fs/proc/vmcore.c:161:34: sparse: sparse: incorrect type in argument 1 (different address spaces)

From: Matthew Wilcox
Date: Sat Dec 04 2021 - 11:58:30 EST


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 ...