Skip to contentSkip to conversation

asm-generic: instrument usercopy in cacheflush.h

PATCH Alexander Potapenko 1 participant 1 message Jun 2, 2022 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 2 lines · kernel test robot

Hi Alexander,

Hi,

Quoted 24 lines

I love your patch! Perhaps something to improve:

[auto build test WARNING on tip/x86/core]
[also build test WARNING on tip/x86/mm linus/master v5.18-rc4 next-20220427] [cannot apply to hnaz-mm/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Alexander-Potapenko/Add-KernelMemorySanitizer-infrastructure/20220427-004851
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 203d8919a9eda5d1bc68ac3cd7637588334c9dc1
config: i386-randconfig-s002-20220425 (https://download.01.org/0day-ci/archive/20220428/202204281316.B64baqtO-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.2.0-20) 11.2.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://github.com/intel-lab-lkp/linux/commit/7ab236390b96b8606acf877ddea4e3a14f58bfd2
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Alexander-Potapenko/Add-KernelMemorySanitizer-infrastructure/20220427-004851
        git checkout 7ab236390b96b8606acf877ddea4e3a14f58bfd2
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash
Quoted 2 lines

If you fix the issue, kindly add following tag as appropriate

The mentioned reports are irrelevant to this patch and are reproducible without it.
Also, my patch does not touch memory.c

Quoted 97 lines

sparse warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

mm/memory.c:5221:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __user *to @@ got void * @@

mm/memory.c:5221:33: sparse: expected void [noderef] __user *to
mm/memory.c:5221:33: sparse: got void *

Quoted 1 line
Quoted 1 line

mm/memory.c:5225:33: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const [noderef] __user *from @@ got void * @@

mm/memory.c:5225:33: sparse: expected void const [noderef] __user *from
mm/memory.c:5225:33: sparse: got void *

Quoted 1 line
Quoted 1 line

mm/memory.c:5225:33: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const [noderef] __user *from @@ got void * @@

mm/memory.c:5225:33: sparse: expected void const [noderef] __user *from
mm/memory.c:5225:33: sparse: got void *
mm/memory.c:1024:17: sparse: sparse: context imbalance in 'copy_pte_range' - different lock contexts for basic block mm/memory.c:1752:16: sparse: sparse: context imbalance in '__get_locked_pte' - different lock contexts for basic block mm/memory.c:1800:9: sparse: sparse: context imbalance in 'insert_page' - different lock contexts for basic block mm/memory.c:2302:17: sparse: sparse: context imbalance in 'remap_pte_range' - different lock contexts for basic block mm/memory.c:2558:17: sparse: sparse: context imbalance in 'apply_to_pte_range' - unexpected unlock mm/memory.c:2847:9: sparse: sparse: context imbalance in 'wp_page_copy' - different lock contexts for basic block mm/memory.c:3185:17: sparse: sparse: context imbalance in 'wp_pfn_shared' - unexpected unlock mm/memory.c:3248:19: sparse: sparse: context imbalance in 'do_wp_page' - different lock contexts for basic block mm/memory.c:4952:5: sparse: sparse: context imbalance in 'follow_invalidate_pte' - wrong count at exit mm/memory.c:5073:23: sparse: sparse: context imbalance in 'follow_pfn' - unexpected unlock mm/memory.c:5103:9: sparse: sparse: context imbalance in 'follow_phys' - unexpected unlock mm/memory.c:5137:9: sparse: sparse: context imbalance in 'generic_access_phys' - unexpected unlock

vim +5221 mm/memory.c

28b2ee20c7cba81 Rik van Riel          2008-07-23  5173
0ec76a110f432e9 David Howells         2006-09-27  5174  /*
d3f5ffcacd15287 John Hubbard          2020-12-14  5175   * Access another process' address space as given in mm.
0ec76a110f432e9 David Howells         2006-09-27  5176   */
d3f5ffcacd15287 John Hubbard          2020-12-14  5177  int __access_remote_vm(struct mm_struct *mm, unsigned long addr, void *buf,
d3f5ffcacd15287 John Hubbard          2020-12-14  5178                         int len, unsigned int gup_flags)
0ec76a110f432e9 David Howells         2006-09-27  5179  {
0ec76a110f432e9 David Howells         2006-09-27  5180          struct vm_area_struct *vma;
0ec76a110f432e9 David Howells         2006-09-27  5181          void *old_buf = buf;
442486ec1096781 Lorenzo Stoakes       2016-10-13  5182          int write = gup_flags & FOLL_WRITE;
0ec76a110f432e9 David Howells         2006-09-27  5183
d8ed45c5dcd455f Michel Lespinasse     2020-06-08  5184          if (mmap_read_lock_killable(mm))
1e426fe28261b03 Konstantin Khlebnikov 2019-07-11  5185                  return 0;
1e426fe28261b03 Konstantin Khlebnikov 2019-07-11  5186
183ff22bb6bd818 Simon Arlott          2007-10-20  5187          /* ignore errors, just check how much was successfully transferred */
0ec76a110f432e9 David Howells         2006-09-27  5188          while (len) {
0ec76a110f432e9 David Howells         2006-09-27  5189                  int bytes, ret, offset;
0ec76a110f432e9 David Howells         2006-09-27  5190                  void *maddr;
28b2ee20c7cba81 Rik van Riel          2008-07-23  5191                  struct page *page = NULL;
0ec76a110f432e9 David Howells         2006-09-27  5192
64019a2e467a288 Peter Xu              2020-08-11  5193                  ret = get_user_pages_remote(mm, addr, 1,
5b56d49fc31dbb0 Lorenzo Stoakes       2016-12-14  5194                                  gup_flags, &page, &vma, NULL);
28b2ee20c7cba81 Rik van Riel          2008-07-23  5195                  if (ret <= 0) {
dbffcd03d77a3fb Rik van Riel          2014-08-06  5196  #ifndef CONFIG_HAVE_IOREMAP_PROT
dbffcd03d77a3fb Rik van Riel          2014-08-06  5197                          break;
dbffcd03d77a3fb Rik van Riel          2014-08-06  5198  #else
28b2ee20c7cba81 Rik van Riel          2008-07-23  5199                          /*
28b2ee20c7cba81 Rik van Riel          2008-07-23  5200                           * Check if this is a VM_IO | VM_PFNMAP VMA, which
28b2ee20c7cba81 Rik van Riel          2008-07-23  5201                           * we can access using slightly different code.
28b2ee20c7cba81 Rik van Riel          2008-07-23  5202                           */
3e418f9888463a8 Liam Howlett          2021-06-28  5203                          vma = vma_lookup(mm, addr);
3e418f9888463a8 Liam Howlett          2021-06-28  5204                          if (!vma)
28b2ee20c7cba81 Rik van Riel          2008-07-23  5205                                  break;
28b2ee20c7cba81 Rik van Riel          2008-07-23  5206                          if (vma->vm_ops && vma->vm_ops->access)
28b2ee20c7cba81 Rik van Riel          2008-07-23  5207                                  ret = vma->vm_ops->access(vma, addr, buf,
28b2ee20c7cba81 Rik van Riel          2008-07-23  5208                                                            len, write);
0ec76a110f432e9 David Howells         2006-09-27  5209                          if (ret <= 0)
0ec76a110f432e9 David Howells         2006-09-27  5210                                  break;
28b2ee20c7cba81 Rik van Riel          2008-07-23  5211                          bytes = ret;
dbffcd03d77a3fb Rik van Riel          2014-08-06  5212  #endif
28b2ee20c7cba81 Rik van Riel          2008-07-23  5213                  } else {
0ec76a110f432e9 David Howells         2006-09-27  5214                          bytes = len;
0ec76a110f432e9 David Howells         2006-09-27  5215                          offset = addr & (PAGE_SIZE-1);
0ec76a110f432e9 David Howells         2006-09-27  5216                          if (bytes > PAGE_SIZE-offset)
0ec76a110f432e9 David Howells         2006-09-27  5217                                  bytes = PAGE_SIZE-offset;
0ec76a110f432e9 David Howells         2006-09-27  5218
0ec76a110f432e9 David Howells         2006-09-27  5219                          maddr = kmap(page);
0ec76a110f432e9 David Howells         2006-09-27  5220                          if (write) {
0ec76a110f432e9 David Howells         2006-09-27 @5221                                  copy_to_user_page(vma, page, addr,
0ec76a110f432e9 David Howells         2006-09-27  5222                                                    maddr + offset, buf, bytes);
0ec76a110f432e9 David Howells         2006-09-27  5223                                  set_page_dirty_lock(page);
0ec76a110f432e9 David Howells         2006-09-27  5224                          } else {
0ec76a110f432e9 David Howells         2006-09-27 @5225                                  copy_from_user_page(vma, page, addr,
0ec76a110f432e9 David Howells         2006-09-27  5226                                                      buf, maddr + offset, bytes);
0ec76a110f432e9 David Howells         2006-09-27  5227                          }
0ec76a110f432e9 David Howells         2006-09-27  5228                          kunmap(page);
09cbfeaf1a5a67b Kirill A. Shutemov    2016-04-01  5229                          put_page(page);
28b2ee20c7cba81 Rik van Riel          2008-07-23  5230                  }
0ec76a110f432e9 David Howells         2006-09-27  5231                  len -= bytes;
0ec76a110f432e9 David Howells         2006-09-27  5232                  buf += bytes;
0ec76a110f432e9 David Howells         2006-09-27  5233                  addr += bytes;
0ec76a110f432e9 David Howells         2006-09-27  5234          }
d8ed45c5dcd455f Michel Lespinasse     2020-06-08  5235          mmap_read_unlock(mm);
0ec76a110f432e9 David Howells         2006-09-27  5236
0ec76a110f432e9 David Howells         2006-09-27  5237          return buf - old_buf;
0ec76a110f432e9 David Howells         2006-09-27  5238  }
03252919b798910 Andi Kleen            2008-01-30  5239

--
0-DAY CI Kernel Test Service
https://01.org/lkp

Signature · 21 lines
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Liana Sebastian
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

Diese E-Mail ist vertraulich. Falls Sie diese fälschlicherweise
erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes
weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich
bitte wissen, dass die E-Mail an die falsche Person gesendet wurde.


This e-mail is confidential. If you received this communication by
mistake, please don't forward it to anyone else, please erase all
copies and attachments, and please let me know that it has gone to the
wrong person.