* [PATCH] staging: android: ashmem.c: Cleanup
@ 2020-06-13 17:37 Dio Putra
2020-06-13 19:53 ` kernel test robot
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Dio Putra @ 2020-06-13 17:37 UTC (permalink / raw)
To: gregkh; +Cc: arve, tkjos, maco, joel, christian, devel, linux-kernel
Minor cleanup to make file_operations const once again.
Signed-off-by: Dio Putra <dioput12@gmail.com>
---
drivers/staging/android/ashmem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
base-commit: aa5af974127d317071d6225a0f3678c5f520e7ce
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 8044510d8ec6..fbb6ac9ba1ab 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -367,7 +367,7 @@ ashmem_vmfile_get_unmapped_area(struct file *file, unsigned long addr,
static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
{
- static struct file_operations vmfile_fops;
+ static const struct file_operations vmfile_fops;
struct ashmem_area *asma = file->private_data;
int ret = 0;
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] staging: android: ashmem.c: Cleanup 2020-06-13 17:37 [PATCH] staging: android: ashmem.c: Cleanup Dio Putra @ 2020-06-13 19:53 ` kernel test robot 2020-06-13 20:22 ` kernel test robot ` (2 subsequent siblings) 3 siblings, 0 replies; 10+ messages in thread From: kernel test robot @ 2020-06-13 19:53 UTC (permalink / raw) To: kbuild-all [-- Attachment #1: Type: text/plain, Size: 8072 bytes --] Hi Dio, Thank you for the patch! Yet something to improve: [auto build test ERROR on staging/staging-testing] [cannot apply to aa5af974127d317071d6225a0f3678c5f520e7ce] url: https://github.com/0day-ci/linux/commits/Dio-Putra/staging-android-ashmem-c-Cleanup/20200614-013821 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git af7b4801030c07637840191c69eb666917e4135d config: x86_64-randconfig-m001-20200614 (attached as .config) compiler: gcc-9 (Debian 9.3.0-13) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>, old ones prefixed by <<): drivers/staging/android/ashmem.c: In function 'ashmem_mmap': >> drivers/staging/android/ashmem.c:418:16: error: assignment of read-only variable 'vmfile_fops' 418 | vmfile_fops = *vmfile->f_op; | ^ >> drivers/staging/android/ashmem.c:419:21: error: assignment of member 'mmap' in read-only object 419 | vmfile_fops.mmap = ashmem_vmfile_mmap; | ^ >> drivers/staging/android/ashmem.c:420:34: error: assignment of member 'get_unmapped_area' in read-only object 420 | vmfile_fops.get_unmapped_area = | ^ vim +/vmfile_fops +418 drivers/staging/android/ashmem.c 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 367 11980c2ac4ccfa Robert Love 2011-12-20 368 static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) 11980c2ac4ccfa Robert Love 2011-12-20 369 { 7fe32ab69ec805 Dio Putra 2020-06-14 370 static const struct file_operations vmfile_fops; 11980c2ac4ccfa Robert Love 2011-12-20 371 struct ashmem_area *asma = file->private_data; 11980c2ac4ccfa Robert Love 2011-12-20 372 int ret = 0; 11980c2ac4ccfa Robert Love 2011-12-20 373 11980c2ac4ccfa Robert Love 2011-12-20 374 mutex_lock(&ashmem_mutex); 11980c2ac4ccfa Robert Love 2011-12-20 375 11980c2ac4ccfa Robert Love 2011-12-20 376 /* user needs to SET_SIZE before mapping */ 59848d6aded59a Alistair Strachan 2018-06-19 377 if (!asma->size) { 11980c2ac4ccfa Robert Love 2011-12-20 378 ret = -EINVAL; 11980c2ac4ccfa Robert Love 2011-12-20 379 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 380 } 11980c2ac4ccfa Robert Love 2011-12-20 381 8632c614565d0c Alistair Strachan 2018-06-19 382 /* requested mapping size larger than object size */ 8632c614565d0c Alistair Strachan 2018-06-19 383 if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) { 11980c2ac4ccfa Robert Love 2011-12-20 384 ret = -EINVAL; 11980c2ac4ccfa Robert Love 2011-12-20 385 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 386 } 11980c2ac4ccfa Robert Love 2011-12-20 387 11980c2ac4ccfa Robert Love 2011-12-20 388 /* requested protection bits must match our allowed protection mask */ 59848d6aded59a Alistair Strachan 2018-06-19 389 if ((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) & 59848d6aded59a Alistair Strachan 2018-06-19 390 calc_vm_prot_bits(PROT_MASK, 0)) { 11980c2ac4ccfa Robert Love 2011-12-20 391 ret = -EPERM; 11980c2ac4ccfa Robert Love 2011-12-20 392 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 393 } 56f76fc68492af Arve Hjønnevåg 2011-12-20 394 vma->vm_flags &= ~calc_vm_may_flags(~asma->prot_mask); 11980c2ac4ccfa Robert Love 2011-12-20 395 11980c2ac4ccfa Robert Love 2011-12-20 396 if (!asma->file) { 11980c2ac4ccfa Robert Love 2011-12-20 397 char *name = ASHMEM_NAME_DEF; 11980c2ac4ccfa Robert Love 2011-12-20 398 struct file *vmfile; 11980c2ac4ccfa Robert Love 2011-12-20 399 11980c2ac4ccfa Robert Love 2011-12-20 400 if (asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0') 11980c2ac4ccfa Robert Love 2011-12-20 401 name = asma->name; 11980c2ac4ccfa Robert Love 2011-12-20 402 11980c2ac4ccfa Robert Love 2011-12-20 403 /* ... and allocate the backing shmem file */ 11980c2ac4ccfa Robert Love 2011-12-20 404 vmfile = shmem_file_setup(name, asma->size, vma->vm_flags); 7f44cb0ba88b40 Viresh Kumar 2015-07-31 405 if (IS_ERR(vmfile)) { 11980c2ac4ccfa Robert Love 2011-12-20 406 ret = PTR_ERR(vmfile); 11980c2ac4ccfa Robert Love 2011-12-20 407 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 408 } 97fbfef6bd5978 Shuxiao Zhang 2017-04-06 409 vmfile->f_mode |= FMODE_LSEEK; 11980c2ac4ccfa Robert Love 2011-12-20 410 asma->file = vmfile; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 411 /* 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 412 * override mmap operation of the vmfile so that it can't be 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 413 * remapped which would lead to creation of a new vma with no 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 414 * asma permission checks. Have to override get_unmapped_area 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 415 * as well to prevent VM_BUG_ON check for f_ops modification. 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 416 */ 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 417 if (!vmfile_fops.mmap) { 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 @418 vmfile_fops = *vmfile->f_op; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 @419 vmfile_fops.mmap = ashmem_vmfile_mmap; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 @420 vmfile_fops.get_unmapped_area = 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 421 ashmem_vmfile_get_unmapped_area; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 422 } 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 423 vmfile->f_op = &vmfile_fops; 11980c2ac4ccfa Robert Love 2011-12-20 424 } 11980c2ac4ccfa Robert Love 2011-12-20 425 get_file(asma->file); 11980c2ac4ccfa Robert Love 2011-12-20 426 11980c2ac4ccfa Robert Love 2011-12-20 427 /* 11980c2ac4ccfa Robert Love 2011-12-20 428 * XXX - Reworked to use shmem_zero_setup() instead of 11980c2ac4ccfa Robert Love 2011-12-20 429 * shmem_set_file while we're in staging. -jstultz 11980c2ac4ccfa Robert Love 2011-12-20 430 */ 11980c2ac4ccfa Robert Love 2011-12-20 431 if (vma->vm_flags & VM_SHARED) { 11980c2ac4ccfa Robert Love 2011-12-20 432 ret = shmem_zero_setup(vma); 11980c2ac4ccfa Robert Love 2011-12-20 433 if (ret) { 11980c2ac4ccfa Robert Love 2011-12-20 434 fput(asma->file); 11980c2ac4ccfa Robert Love 2011-12-20 435 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 436 } 44960f2a7b63e2 John Stultz 2018-07-31 437 } else { 44960f2a7b63e2 John Stultz 2018-07-31 438 vma_set_anonymous(vma); 11980c2ac4ccfa Robert Love 2011-12-20 439 } 11980c2ac4ccfa Robert Love 2011-12-20 440 11980c2ac4ccfa Robert Love 2011-12-20 441 if (vma->vm_file) 11980c2ac4ccfa Robert Love 2011-12-20 442 fput(vma->vm_file); 11980c2ac4ccfa Robert Love 2011-12-20 443 vma->vm_file = asma->file; 11980c2ac4ccfa Robert Love 2011-12-20 444 11980c2ac4ccfa Robert Love 2011-12-20 445 out: 11980c2ac4ccfa Robert Love 2011-12-20 446 mutex_unlock(&ashmem_mutex); 11980c2ac4ccfa Robert Love 2011-12-20 447 return ret; 11980c2ac4ccfa Robert Love 2011-12-20 448 } 11980c2ac4ccfa Robert Love 2011-12-20 449 :::::: The code at line 418 was first introduced by commit :::::: 6d67b0290b4b84c477e6a2fc6e005e174d3c7786 staging: android: ashmem: Disallow ashmem memory from being remapped :::::: TO: Suren Baghdasaryan <surenb@google.com> :::::: CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org [-- Attachment #2: config.gz --] [-- Type: application/gzip, Size: 31334 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] staging: android: ashmem.c: Cleanup @ 2020-06-13 19:53 ` kernel test robot 0 siblings, 0 replies; 10+ messages in thread From: kernel test robot @ 2020-06-13 19:53 UTC (permalink / raw) To: Dio Putra, gregkh Cc: kbuild-all, arve, tkjos, maco, joel, christian, devel, linux-kernel [-- Attachment #1: Type: text/plain, Size: 7945 bytes --] Hi Dio, Thank you for the patch! Yet something to improve: [auto build test ERROR on staging/staging-testing] [cannot apply to aa5af974127d317071d6225a0f3678c5f520e7ce] url: https://github.com/0day-ci/linux/commits/Dio-Putra/staging-android-ashmem-c-Cleanup/20200614-013821 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git af7b4801030c07637840191c69eb666917e4135d config: x86_64-randconfig-m001-20200614 (attached as .config) compiler: gcc-9 (Debian 9.3.0-13) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>, old ones prefixed by <<): drivers/staging/android/ashmem.c: In function 'ashmem_mmap': >> drivers/staging/android/ashmem.c:418:16: error: assignment of read-only variable 'vmfile_fops' 418 | vmfile_fops = *vmfile->f_op; | ^ >> drivers/staging/android/ashmem.c:419:21: error: assignment of member 'mmap' in read-only object 419 | vmfile_fops.mmap = ashmem_vmfile_mmap; | ^ >> drivers/staging/android/ashmem.c:420:34: error: assignment of member 'get_unmapped_area' in read-only object 420 | vmfile_fops.get_unmapped_area = | ^ vim +/vmfile_fops +418 drivers/staging/android/ashmem.c 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 367 11980c2ac4ccfa Robert Love 2011-12-20 368 static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) 11980c2ac4ccfa Robert Love 2011-12-20 369 { 7fe32ab69ec805 Dio Putra 2020-06-14 370 static const struct file_operations vmfile_fops; 11980c2ac4ccfa Robert Love 2011-12-20 371 struct ashmem_area *asma = file->private_data; 11980c2ac4ccfa Robert Love 2011-12-20 372 int ret = 0; 11980c2ac4ccfa Robert Love 2011-12-20 373 11980c2ac4ccfa Robert Love 2011-12-20 374 mutex_lock(&ashmem_mutex); 11980c2ac4ccfa Robert Love 2011-12-20 375 11980c2ac4ccfa Robert Love 2011-12-20 376 /* user needs to SET_SIZE before mapping */ 59848d6aded59a Alistair Strachan 2018-06-19 377 if (!asma->size) { 11980c2ac4ccfa Robert Love 2011-12-20 378 ret = -EINVAL; 11980c2ac4ccfa Robert Love 2011-12-20 379 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 380 } 11980c2ac4ccfa Robert Love 2011-12-20 381 8632c614565d0c Alistair Strachan 2018-06-19 382 /* requested mapping size larger than object size */ 8632c614565d0c Alistair Strachan 2018-06-19 383 if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) { 11980c2ac4ccfa Robert Love 2011-12-20 384 ret = -EINVAL; 11980c2ac4ccfa Robert Love 2011-12-20 385 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 386 } 11980c2ac4ccfa Robert Love 2011-12-20 387 11980c2ac4ccfa Robert Love 2011-12-20 388 /* requested protection bits must match our allowed protection mask */ 59848d6aded59a Alistair Strachan 2018-06-19 389 if ((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) & 59848d6aded59a Alistair Strachan 2018-06-19 390 calc_vm_prot_bits(PROT_MASK, 0)) { 11980c2ac4ccfa Robert Love 2011-12-20 391 ret = -EPERM; 11980c2ac4ccfa Robert Love 2011-12-20 392 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 393 } 56f76fc68492af Arve Hjønnevåg 2011-12-20 394 vma->vm_flags &= ~calc_vm_may_flags(~asma->prot_mask); 11980c2ac4ccfa Robert Love 2011-12-20 395 11980c2ac4ccfa Robert Love 2011-12-20 396 if (!asma->file) { 11980c2ac4ccfa Robert Love 2011-12-20 397 char *name = ASHMEM_NAME_DEF; 11980c2ac4ccfa Robert Love 2011-12-20 398 struct file *vmfile; 11980c2ac4ccfa Robert Love 2011-12-20 399 11980c2ac4ccfa Robert Love 2011-12-20 400 if (asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0') 11980c2ac4ccfa Robert Love 2011-12-20 401 name = asma->name; 11980c2ac4ccfa Robert Love 2011-12-20 402 11980c2ac4ccfa Robert Love 2011-12-20 403 /* ... and allocate the backing shmem file */ 11980c2ac4ccfa Robert Love 2011-12-20 404 vmfile = shmem_file_setup(name, asma->size, vma->vm_flags); 7f44cb0ba88b40 Viresh Kumar 2015-07-31 405 if (IS_ERR(vmfile)) { 11980c2ac4ccfa Robert Love 2011-12-20 406 ret = PTR_ERR(vmfile); 11980c2ac4ccfa Robert Love 2011-12-20 407 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 408 } 97fbfef6bd5978 Shuxiao Zhang 2017-04-06 409 vmfile->f_mode |= FMODE_LSEEK; 11980c2ac4ccfa Robert Love 2011-12-20 410 asma->file = vmfile; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 411 /* 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 412 * override mmap operation of the vmfile so that it can't be 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 413 * remapped which would lead to creation of a new vma with no 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 414 * asma permission checks. Have to override get_unmapped_area 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 415 * as well to prevent VM_BUG_ON check for f_ops modification. 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 416 */ 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 417 if (!vmfile_fops.mmap) { 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 @418 vmfile_fops = *vmfile->f_op; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 @419 vmfile_fops.mmap = ashmem_vmfile_mmap; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 @420 vmfile_fops.get_unmapped_area = 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 421 ashmem_vmfile_get_unmapped_area; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 422 } 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 423 vmfile->f_op = &vmfile_fops; 11980c2ac4ccfa Robert Love 2011-12-20 424 } 11980c2ac4ccfa Robert Love 2011-12-20 425 get_file(asma->file); 11980c2ac4ccfa Robert Love 2011-12-20 426 11980c2ac4ccfa Robert Love 2011-12-20 427 /* 11980c2ac4ccfa Robert Love 2011-12-20 428 * XXX - Reworked to use shmem_zero_setup() instead of 11980c2ac4ccfa Robert Love 2011-12-20 429 * shmem_set_file while we're in staging. -jstultz 11980c2ac4ccfa Robert Love 2011-12-20 430 */ 11980c2ac4ccfa Robert Love 2011-12-20 431 if (vma->vm_flags & VM_SHARED) { 11980c2ac4ccfa Robert Love 2011-12-20 432 ret = shmem_zero_setup(vma); 11980c2ac4ccfa Robert Love 2011-12-20 433 if (ret) { 11980c2ac4ccfa Robert Love 2011-12-20 434 fput(asma->file); 11980c2ac4ccfa Robert Love 2011-12-20 435 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 436 } 44960f2a7b63e2 John Stultz 2018-07-31 437 } else { 44960f2a7b63e2 John Stultz 2018-07-31 438 vma_set_anonymous(vma); 11980c2ac4ccfa Robert Love 2011-12-20 439 } 11980c2ac4ccfa Robert Love 2011-12-20 440 11980c2ac4ccfa Robert Love 2011-12-20 441 if (vma->vm_file) 11980c2ac4ccfa Robert Love 2011-12-20 442 fput(vma->vm_file); 11980c2ac4ccfa Robert Love 2011-12-20 443 vma->vm_file = asma->file; 11980c2ac4ccfa Robert Love 2011-12-20 444 11980c2ac4ccfa Robert Love 2011-12-20 445 out: 11980c2ac4ccfa Robert Love 2011-12-20 446 mutex_unlock(&ashmem_mutex); 11980c2ac4ccfa Robert Love 2011-12-20 447 return ret; 11980c2ac4ccfa Robert Love 2011-12-20 448 } 11980c2ac4ccfa Robert Love 2011-12-20 449 :::::: The code at line 418 was first introduced by commit :::::: 6d67b0290b4b84c477e6a2fc6e005e174d3c7786 staging: android: ashmem: Disallow ashmem memory from being remapped :::::: TO: Suren Baghdasaryan <surenb@google.com> :::::: CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 31334 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] staging: android: ashmem.c: Cleanup 2020-06-13 17:37 [PATCH] staging: android: ashmem.c: Cleanup Dio Putra @ 2020-06-13 20:22 ` kernel test robot 2020-06-13 20:22 ` kernel test robot ` (2 subsequent siblings) 3 siblings, 0 replies; 10+ messages in thread From: kernel test robot @ 2020-06-13 20:22 UTC (permalink / raw) To: kbuild-all [-- Attachment #1: Type: text/plain, Size: 14728 bytes --] Hi Dio, Thank you for the patch! Yet something to improve: [auto build test ERROR on staging/staging-testing] [cannot apply to aa5af974127d317071d6225a0f3678c5f520e7ce] url: https://github.com/0day-ci/linux/commits/Dio-Putra/staging-android-ashmem-c-Cleanup/20200614-013821 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git af7b4801030c07637840191c69eb666917e4135d config: powerpc-randconfig-r016-20200614 (attached as .config) compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project c669a1ed6386d57a75a602b53266466dae1e1d84) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install powerpc cross compiling tool for clang build # apt-get install binutils-powerpc-linux-gnu # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>, old ones prefixed by <<): ^ arch/powerpc/include/asm/io.h:543:56: note: expanded from macro '__do_insw' #define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from drivers/staging/android/ashmem.c:26: In file included from include/linux/shmem_fs.h:6: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:26: In file included from include/linux/kernel_stat.h:9: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:10: In file included from arch/powerpc/include/asm/hardirq.h:6: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/powerpc/include/asm/io.h:605: arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:602:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; ^~~~~~~~~~~~~~ <scratch space>:118:1: note: expanded from here __do_insl ^ arch/powerpc/include/asm/io.h:544:56: note: expanded from macro '__do_insl' #define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from drivers/staging/android/ashmem.c:26: In file included from include/linux/shmem_fs.h:6: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:26: In file included from include/linux/kernel_stat.h:9: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:10: In file included from arch/powerpc/include/asm/hardirq.h:6: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/powerpc/include/asm/io.h:605: arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:602:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; ^~~~~~~~~~~~~~ <scratch space>:120:1: note: expanded from here __do_outsb ^ arch/powerpc/include/asm/io.h:545:58: note: expanded from macro '__do_outsb' #define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from drivers/staging/android/ashmem.c:26: In file included from include/linux/shmem_fs.h:6: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:26: In file included from include/linux/kernel_stat.h:9: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:10: In file included from arch/powerpc/include/asm/hardirq.h:6: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/powerpc/include/asm/io.h:605: arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:602:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; ^~~~~~~~~~~~~~ <scratch space>:122:1: note: expanded from here __do_outsw ^ arch/powerpc/include/asm/io.h:546:58: note: expanded from macro '__do_outsw' #define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from drivers/staging/android/ashmem.c:26: In file included from include/linux/shmem_fs.h:6: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:26: In file included from include/linux/kernel_stat.h:9: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:10: In file included from arch/powerpc/include/asm/hardirq.h:6: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/powerpc/include/asm/io.h:605: arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:602:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; ^~~~~~~~~~~~~~ <scratch space>:124:1: note: expanded from here __do_outsl ^ arch/powerpc/include/asm/io.h:547:58: note: expanded from macro '__do_outsl' #define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) ~~~~~~~~~~~~~~~~~~~~~^ >> drivers/staging/android/ashmem.c:418:16: error: cannot assign to variable 'vmfile_fops' with const-qualified type 'const struct file_operations' vmfile_fops = *vmfile->f_op; ~~~~~~~~~~~ ^ drivers/staging/android/ashmem.c:370:38: note: variable 'vmfile_fops' declared const here static const struct file_operations vmfile_fops; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ drivers/staging/android/ashmem.c:419:21: error: cannot assign to variable 'vmfile_fops' with const-qualified type 'const struct file_operations' vmfile_fops.mmap = ashmem_vmfile_mmap; ~~~~~~~~~~~~~~~~ ^ drivers/staging/android/ashmem.c:370:38: note: variable 'vmfile_fops' declared const here static const struct file_operations vmfile_fops; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ drivers/staging/android/ashmem.c:420:34: error: cannot assign to variable 'vmfile_fops' with const-qualified type 'const struct file_operations' vmfile_fops.get_unmapped_area = ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ drivers/staging/android/ashmem.c:370:38: note: variable 'vmfile_fops' declared const here static const struct file_operations vmfile_fops; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ 6 warnings and 3 errors generated. vim +418 drivers/staging/android/ashmem.c 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 367 11980c2ac4ccfa Robert Love 2011-12-20 368 static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) 11980c2ac4ccfa Robert Love 2011-12-20 369 { 7fe32ab69ec805 Dio Putra 2020-06-14 370 static const struct file_operations vmfile_fops; 11980c2ac4ccfa Robert Love 2011-12-20 371 struct ashmem_area *asma = file->private_data; 11980c2ac4ccfa Robert Love 2011-12-20 372 int ret = 0; 11980c2ac4ccfa Robert Love 2011-12-20 373 11980c2ac4ccfa Robert Love 2011-12-20 374 mutex_lock(&ashmem_mutex); 11980c2ac4ccfa Robert Love 2011-12-20 375 11980c2ac4ccfa Robert Love 2011-12-20 376 /* user needs to SET_SIZE before mapping */ 59848d6aded59a Alistair Strachan 2018-06-19 377 if (!asma->size) { 11980c2ac4ccfa Robert Love 2011-12-20 378 ret = -EINVAL; 11980c2ac4ccfa Robert Love 2011-12-20 379 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 380 } 11980c2ac4ccfa Robert Love 2011-12-20 381 8632c614565d0c Alistair Strachan 2018-06-19 382 /* requested mapping size larger than object size */ 8632c614565d0c Alistair Strachan 2018-06-19 383 if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) { 11980c2ac4ccfa Robert Love 2011-12-20 384 ret = -EINVAL; 11980c2ac4ccfa Robert Love 2011-12-20 385 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 386 } 11980c2ac4ccfa Robert Love 2011-12-20 387 11980c2ac4ccfa Robert Love 2011-12-20 388 /* requested protection bits must match our allowed protection mask */ 59848d6aded59a Alistair Strachan 2018-06-19 389 if ((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) & 59848d6aded59a Alistair Strachan 2018-06-19 390 calc_vm_prot_bits(PROT_MASK, 0)) { 11980c2ac4ccfa Robert Love 2011-12-20 391 ret = -EPERM; 11980c2ac4ccfa Robert Love 2011-12-20 392 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 393 } 56f76fc68492af Arve Hjønnevåg 2011-12-20 394 vma->vm_flags &= ~calc_vm_may_flags(~asma->prot_mask); 11980c2ac4ccfa Robert Love 2011-12-20 395 11980c2ac4ccfa Robert Love 2011-12-20 396 if (!asma->file) { 11980c2ac4ccfa Robert Love 2011-12-20 397 char *name = ASHMEM_NAME_DEF; 11980c2ac4ccfa Robert Love 2011-12-20 398 struct file *vmfile; 11980c2ac4ccfa Robert Love 2011-12-20 399 11980c2ac4ccfa Robert Love 2011-12-20 400 if (asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0') 11980c2ac4ccfa Robert Love 2011-12-20 401 name = asma->name; 11980c2ac4ccfa Robert Love 2011-12-20 402 11980c2ac4ccfa Robert Love 2011-12-20 403 /* ... and allocate the backing shmem file */ 11980c2ac4ccfa Robert Love 2011-12-20 404 vmfile = shmem_file_setup(name, asma->size, vma->vm_flags); 7f44cb0ba88b40 Viresh Kumar 2015-07-31 405 if (IS_ERR(vmfile)) { 11980c2ac4ccfa Robert Love 2011-12-20 406 ret = PTR_ERR(vmfile); 11980c2ac4ccfa Robert Love 2011-12-20 407 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 408 } 97fbfef6bd5978 Shuxiao Zhang 2017-04-06 409 vmfile->f_mode |= FMODE_LSEEK; 11980c2ac4ccfa Robert Love 2011-12-20 410 asma->file = vmfile; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 411 /* 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 412 * override mmap operation of the vmfile so that it can't be 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 413 * remapped which would lead to creation of a new vma with no 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 414 * asma permission checks. Have to override get_unmapped_area 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 415 * as well to prevent VM_BUG_ON check for f_ops modification. 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 416 */ 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 417 if (!vmfile_fops.mmap) { 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 @418 vmfile_fops = *vmfile->f_op; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 419 vmfile_fops.mmap = ashmem_vmfile_mmap; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 420 vmfile_fops.get_unmapped_area = 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 421 ashmem_vmfile_get_unmapped_area; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 422 } 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 423 vmfile->f_op = &vmfile_fops; 11980c2ac4ccfa Robert Love 2011-12-20 424 } 11980c2ac4ccfa Robert Love 2011-12-20 425 get_file(asma->file); 11980c2ac4ccfa Robert Love 2011-12-20 426 11980c2ac4ccfa Robert Love 2011-12-20 427 /* 11980c2ac4ccfa Robert Love 2011-12-20 428 * XXX - Reworked to use shmem_zero_setup() instead of 11980c2ac4ccfa Robert Love 2011-12-20 429 * shmem_set_file while we're in staging. -jstultz 11980c2ac4ccfa Robert Love 2011-12-20 430 */ 11980c2ac4ccfa Robert Love 2011-12-20 431 if (vma->vm_flags & VM_SHARED) { 11980c2ac4ccfa Robert Love 2011-12-20 432 ret = shmem_zero_setup(vma); 11980c2ac4ccfa Robert Love 2011-12-20 433 if (ret) { 11980c2ac4ccfa Robert Love 2011-12-20 434 fput(asma->file); 11980c2ac4ccfa Robert Love 2011-12-20 435 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 436 } 44960f2a7b63e2 John Stultz 2018-07-31 437 } else { 44960f2a7b63e2 John Stultz 2018-07-31 438 vma_set_anonymous(vma); 11980c2ac4ccfa Robert Love 2011-12-20 439 } 11980c2ac4ccfa Robert Love 2011-12-20 440 11980c2ac4ccfa Robert Love 2011-12-20 441 if (vma->vm_file) 11980c2ac4ccfa Robert Love 2011-12-20 442 fput(vma->vm_file); 11980c2ac4ccfa Robert Love 2011-12-20 443 vma->vm_file = asma->file; 11980c2ac4ccfa Robert Love 2011-12-20 444 11980c2ac4ccfa Robert Love 2011-12-20 445 out: 11980c2ac4ccfa Robert Love 2011-12-20 446 mutex_unlock(&ashmem_mutex); 11980c2ac4ccfa Robert Love 2011-12-20 447 return ret; 11980c2ac4ccfa Robert Love 2011-12-20 448 } 11980c2ac4ccfa Robert Love 2011-12-20 449 :::::: The code at line 418 was first introduced by commit :::::: 6d67b0290b4b84c477e6a2fc6e005e174d3c7786 staging: android: ashmem: Disallow ashmem memory from being remapped :::::: TO: Suren Baghdasaryan <surenb@google.com> :::::: CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org [-- Attachment #2: config.gz --] [-- Type: application/gzip, Size: 31099 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] staging: android: ashmem.c: Cleanup @ 2020-06-13 20:22 ` kernel test robot 0 siblings, 0 replies; 10+ messages in thread From: kernel test robot @ 2020-06-13 20:22 UTC (permalink / raw) To: Dio Putra, gregkh Cc: kbuild-all, arve, tkjos, maco, joel, christian, devel, linux-kernel [-- Attachment #1: Type: text/plain, Size: 14489 bytes --] Hi Dio, Thank you for the patch! Yet something to improve: [auto build test ERROR on staging/staging-testing] [cannot apply to aa5af974127d317071d6225a0f3678c5f520e7ce] url: https://github.com/0day-ci/linux/commits/Dio-Putra/staging-android-ashmem-c-Cleanup/20200614-013821 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git af7b4801030c07637840191c69eb666917e4135d config: powerpc-randconfig-r016-20200614 (attached as .config) compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project c669a1ed6386d57a75a602b53266466dae1e1d84) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install powerpc cross compiling tool for clang build # apt-get install binutils-powerpc-linux-gnu # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>, old ones prefixed by <<): ^ arch/powerpc/include/asm/io.h:543:56: note: expanded from macro '__do_insw' #define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from drivers/staging/android/ashmem.c:26: In file included from include/linux/shmem_fs.h:6: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:26: In file included from include/linux/kernel_stat.h:9: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:10: In file included from arch/powerpc/include/asm/hardirq.h:6: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/powerpc/include/asm/io.h:605: arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:602:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; ^~~~~~~~~~~~~~ <scratch space>:118:1: note: expanded from here __do_insl ^ arch/powerpc/include/asm/io.h:544:56: note: expanded from macro '__do_insl' #define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from drivers/staging/android/ashmem.c:26: In file included from include/linux/shmem_fs.h:6: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:26: In file included from include/linux/kernel_stat.h:9: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:10: In file included from arch/powerpc/include/asm/hardirq.h:6: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/powerpc/include/asm/io.h:605: arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:602:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; ^~~~~~~~~~~~~~ <scratch space>:120:1: note: expanded from here __do_outsb ^ arch/powerpc/include/asm/io.h:545:58: note: expanded from macro '__do_outsb' #define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from drivers/staging/android/ashmem.c:26: In file included from include/linux/shmem_fs.h:6: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:26: In file included from include/linux/kernel_stat.h:9: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:10: In file included from arch/powerpc/include/asm/hardirq.h:6: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/powerpc/include/asm/io.h:605: arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:602:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; ^~~~~~~~~~~~~~ <scratch space>:122:1: note: expanded from here __do_outsw ^ arch/powerpc/include/asm/io.h:546:58: note: expanded from macro '__do_outsw' #define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from drivers/staging/android/ashmem.c:26: In file included from include/linux/shmem_fs.h:6: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:26: In file included from include/linux/kernel_stat.h:9: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:10: In file included from arch/powerpc/include/asm/hardirq.h:6: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/powerpc/include/asm/io.h:605: arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:602:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; ^~~~~~~~~~~~~~ <scratch space>:124:1: note: expanded from here __do_outsl ^ arch/powerpc/include/asm/io.h:547:58: note: expanded from macro '__do_outsl' #define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) ~~~~~~~~~~~~~~~~~~~~~^ >> drivers/staging/android/ashmem.c:418:16: error: cannot assign to variable 'vmfile_fops' with const-qualified type 'const struct file_operations' vmfile_fops = *vmfile->f_op; ~~~~~~~~~~~ ^ drivers/staging/android/ashmem.c:370:38: note: variable 'vmfile_fops' declared const here static const struct file_operations vmfile_fops; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ drivers/staging/android/ashmem.c:419:21: error: cannot assign to variable 'vmfile_fops' with const-qualified type 'const struct file_operations' vmfile_fops.mmap = ashmem_vmfile_mmap; ~~~~~~~~~~~~~~~~ ^ drivers/staging/android/ashmem.c:370:38: note: variable 'vmfile_fops' declared const here static const struct file_operations vmfile_fops; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ drivers/staging/android/ashmem.c:420:34: error: cannot assign to variable 'vmfile_fops' with const-qualified type 'const struct file_operations' vmfile_fops.get_unmapped_area = ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ drivers/staging/android/ashmem.c:370:38: note: variable 'vmfile_fops' declared const here static const struct file_operations vmfile_fops; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ 6 warnings and 3 errors generated. vim +418 drivers/staging/android/ashmem.c 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 367 11980c2ac4ccfa Robert Love 2011-12-20 368 static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) 11980c2ac4ccfa Robert Love 2011-12-20 369 { 7fe32ab69ec805 Dio Putra 2020-06-14 370 static const struct file_operations vmfile_fops; 11980c2ac4ccfa Robert Love 2011-12-20 371 struct ashmem_area *asma = file->private_data; 11980c2ac4ccfa Robert Love 2011-12-20 372 int ret = 0; 11980c2ac4ccfa Robert Love 2011-12-20 373 11980c2ac4ccfa Robert Love 2011-12-20 374 mutex_lock(&ashmem_mutex); 11980c2ac4ccfa Robert Love 2011-12-20 375 11980c2ac4ccfa Robert Love 2011-12-20 376 /* user needs to SET_SIZE before mapping */ 59848d6aded59a Alistair Strachan 2018-06-19 377 if (!asma->size) { 11980c2ac4ccfa Robert Love 2011-12-20 378 ret = -EINVAL; 11980c2ac4ccfa Robert Love 2011-12-20 379 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 380 } 11980c2ac4ccfa Robert Love 2011-12-20 381 8632c614565d0c Alistair Strachan 2018-06-19 382 /* requested mapping size larger than object size */ 8632c614565d0c Alistair Strachan 2018-06-19 383 if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) { 11980c2ac4ccfa Robert Love 2011-12-20 384 ret = -EINVAL; 11980c2ac4ccfa Robert Love 2011-12-20 385 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 386 } 11980c2ac4ccfa Robert Love 2011-12-20 387 11980c2ac4ccfa Robert Love 2011-12-20 388 /* requested protection bits must match our allowed protection mask */ 59848d6aded59a Alistair Strachan 2018-06-19 389 if ((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) & 59848d6aded59a Alistair Strachan 2018-06-19 390 calc_vm_prot_bits(PROT_MASK, 0)) { 11980c2ac4ccfa Robert Love 2011-12-20 391 ret = -EPERM; 11980c2ac4ccfa Robert Love 2011-12-20 392 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 393 } 56f76fc68492af Arve Hjønnevåg 2011-12-20 394 vma->vm_flags &= ~calc_vm_may_flags(~asma->prot_mask); 11980c2ac4ccfa Robert Love 2011-12-20 395 11980c2ac4ccfa Robert Love 2011-12-20 396 if (!asma->file) { 11980c2ac4ccfa Robert Love 2011-12-20 397 char *name = ASHMEM_NAME_DEF; 11980c2ac4ccfa Robert Love 2011-12-20 398 struct file *vmfile; 11980c2ac4ccfa Robert Love 2011-12-20 399 11980c2ac4ccfa Robert Love 2011-12-20 400 if (asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0') 11980c2ac4ccfa Robert Love 2011-12-20 401 name = asma->name; 11980c2ac4ccfa Robert Love 2011-12-20 402 11980c2ac4ccfa Robert Love 2011-12-20 403 /* ... and allocate the backing shmem file */ 11980c2ac4ccfa Robert Love 2011-12-20 404 vmfile = shmem_file_setup(name, asma->size, vma->vm_flags); 7f44cb0ba88b40 Viresh Kumar 2015-07-31 405 if (IS_ERR(vmfile)) { 11980c2ac4ccfa Robert Love 2011-12-20 406 ret = PTR_ERR(vmfile); 11980c2ac4ccfa Robert Love 2011-12-20 407 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 408 } 97fbfef6bd5978 Shuxiao Zhang 2017-04-06 409 vmfile->f_mode |= FMODE_LSEEK; 11980c2ac4ccfa Robert Love 2011-12-20 410 asma->file = vmfile; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 411 /* 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 412 * override mmap operation of the vmfile so that it can't be 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 413 * remapped which would lead to creation of a new vma with no 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 414 * asma permission checks. Have to override get_unmapped_area 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 415 * as well to prevent VM_BUG_ON check for f_ops modification. 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 416 */ 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 417 if (!vmfile_fops.mmap) { 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 @418 vmfile_fops = *vmfile->f_op; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 419 vmfile_fops.mmap = ashmem_vmfile_mmap; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 420 vmfile_fops.get_unmapped_area = 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 421 ashmem_vmfile_get_unmapped_area; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 422 } 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 423 vmfile->f_op = &vmfile_fops; 11980c2ac4ccfa Robert Love 2011-12-20 424 } 11980c2ac4ccfa Robert Love 2011-12-20 425 get_file(asma->file); 11980c2ac4ccfa Robert Love 2011-12-20 426 11980c2ac4ccfa Robert Love 2011-12-20 427 /* 11980c2ac4ccfa Robert Love 2011-12-20 428 * XXX - Reworked to use shmem_zero_setup() instead of 11980c2ac4ccfa Robert Love 2011-12-20 429 * shmem_set_file while we're in staging. -jstultz 11980c2ac4ccfa Robert Love 2011-12-20 430 */ 11980c2ac4ccfa Robert Love 2011-12-20 431 if (vma->vm_flags & VM_SHARED) { 11980c2ac4ccfa Robert Love 2011-12-20 432 ret = shmem_zero_setup(vma); 11980c2ac4ccfa Robert Love 2011-12-20 433 if (ret) { 11980c2ac4ccfa Robert Love 2011-12-20 434 fput(asma->file); 11980c2ac4ccfa Robert Love 2011-12-20 435 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 436 } 44960f2a7b63e2 John Stultz 2018-07-31 437 } else { 44960f2a7b63e2 John Stultz 2018-07-31 438 vma_set_anonymous(vma); 11980c2ac4ccfa Robert Love 2011-12-20 439 } 11980c2ac4ccfa Robert Love 2011-12-20 440 11980c2ac4ccfa Robert Love 2011-12-20 441 if (vma->vm_file) 11980c2ac4ccfa Robert Love 2011-12-20 442 fput(vma->vm_file); 11980c2ac4ccfa Robert Love 2011-12-20 443 vma->vm_file = asma->file; 11980c2ac4ccfa Robert Love 2011-12-20 444 11980c2ac4ccfa Robert Love 2011-12-20 445 out: 11980c2ac4ccfa Robert Love 2011-12-20 446 mutex_unlock(&ashmem_mutex); 11980c2ac4ccfa Robert Love 2011-12-20 447 return ret; 11980c2ac4ccfa Robert Love 2011-12-20 448 } 11980c2ac4ccfa Robert Love 2011-12-20 449 :::::: The code at line 418 was first introduced by commit :::::: 6d67b0290b4b84c477e6a2fc6e005e174d3c7786 staging: android: ashmem: Disallow ashmem memory from being remapped :::::: TO: Suren Baghdasaryan <surenb@google.com> :::::: CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 31099 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] staging: android: ashmem.c: Cleanup 2020-06-13 17:37 [PATCH] staging: android: ashmem.c: Cleanup Dio Putra 2020-06-13 19:53 ` kernel test robot 2020-06-13 20:22 ` kernel test robot @ 2020-06-14 4:40 ` Dio Putra 2020-06-14 6:25 ` Greg KH 2020-06-16 5:30 ` kernel test robot 3 siblings, 1 reply; 10+ messages in thread From: Dio Putra @ 2020-06-14 4:40 UTC (permalink / raw) To: gregkh; +Cc: arve, tkjos, maco, joel, christian, devel, linux-kernel Okay, my fault here. Changing the function a little bit didn't help unfortunately. $ cd ~/git/linux/ $ make CC=clang W=1 M=drivers/staging/android CC drivers/staging/android/ashmem.o drivers/staging/android/ashmem.c:418:16: error: cannot assign to variable 'vmfile_fops' with const-qualified type 'const struct file_operations' vmfile_fops = *vmfile->f_op; ~~~~~~~~~~~ ^ drivers/staging/android/ashmem.c:370:31: note: variable 'vmfile_fops' declared const here const struct file_operations vmfile_fops; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ drivers/staging/android/ashmem.c:419:21: error: cannot assign to variable 'vmfile_fops' with const-qualified type 'const struct file_operations' vmfile_fops.mmap = ashmem_vmfile_mmap; ~~~~~~~~~~~~~~~~ ^ drivers/staging/android/ashmem.c:370:31: note: variable 'vmfile_fops' declared const here const struct file_operations vmfile_fops; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ drivers/staging/android/ashmem.c:420:34: error: cannot assign to variable 'vmfile_fops' with const-qualified type 'const struct file_operations' vmfile_fops.get_unmapped_area = ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ drivers/staging/android/ashmem.c:370:31: note: variable 'vmfile_fops' declared const here const struct file_operations vmfile_fops; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ 3 errors generated. make[1]: *** [scripts/Makefile.build:267: drivers/staging/android/ashmem.o] Error 1 make: *** [Makefile:1735: drivers/staging/android] Error 2 $ On 6/14/20 12:37 AM, Dio Putra wrote: > Minor cleanup to make file_operations const once again. > > Signed-off-by: Dio Putra <dioput12@gmail.com> > --- > drivers/staging/android/ashmem.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > base-commit: aa5af974127d317071d6225a0f3678c5f520e7ce > diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c > index 8044510d8ec6..fbb6ac9ba1ab 100644 > --- a/drivers/staging/android/ashmem.c > +++ b/drivers/staging/android/ashmem.c > @@ -367,7 +367,7 @@ ashmem_vmfile_get_unmapped_area(struct file *file, unsigned long addr, > > static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) > { > - static struct file_operations vmfile_fops; > + static const struct file_operations vmfile_fops; > struct ashmem_area *asma = file->private_data; > int ret = 0; > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] staging: android: ashmem.c: Cleanup 2020-06-14 4:40 ` Dio Putra @ 2020-06-14 6:25 ` Greg KH 0 siblings, 0 replies; 10+ messages in thread From: Greg KH @ 2020-06-14 6:25 UTC (permalink / raw) To: Dio Putra; +Cc: devel, tkjos, linux-kernel, arve, joel, maco, christian On Sun, Jun 14, 2020 at 11:40:42AM +0700, Dio Putra wrote: > Okay, my fault here. Changing the function a little bit didn't help unfortunately. > > $ cd ~/git/linux/ > $ make CC=clang W=1 M=drivers/staging/android > CC drivers/staging/android/ashmem.o > drivers/staging/android/ashmem.c:418:16: error: cannot assign to variable 'vmfile_fops' with const-qualified type 'const struct file_operations' > vmfile_fops = *vmfile->f_op; > ~~~~~~~~~~~ ^ > drivers/staging/android/ashmem.c:370:31: note: variable 'vmfile_fops' declared const here > const struct file_operations vmfile_fops; > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ > drivers/staging/android/ashmem.c:419:21: error: cannot assign to variable 'vmfile_fops' with const-qualified type 'const struct file_operations' > vmfile_fops.mmap = ashmem_vmfile_mmap; > ~~~~~~~~~~~~~~~~ ^ > drivers/staging/android/ashmem.c:370:31: note: variable 'vmfile_fops' declared const here > const struct file_operations vmfile_fops; > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ > drivers/staging/android/ashmem.c:420:34: error: cannot assign to variable 'vmfile_fops' with const-qualified type 'const struct file_operations' > vmfile_fops.get_unmapped_area = > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ > drivers/staging/android/ashmem.c:370:31: note: variable 'vmfile_fops' declared const here > const struct file_operations vmfile_fops; > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ > 3 errors generated. > make[1]: *** [scripts/Makefile.build:267: drivers/staging/android/ashmem.o] Error 1 > make: *** [Makefile:1735: drivers/staging/android] Error 2 > $ > > On 6/14/20 12:37 AM, Dio Putra wrote: > > Minor cleanup to make file_operations const once again. > > > > Signed-off-by: Dio Putra <dioput12@gmail.com> > > --- > > drivers/staging/android/ashmem.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > base-commit: aa5af974127d317071d6225a0f3678c5f520e7ce > > diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c > > index 8044510d8ec6..fbb6ac9ba1ab 100644 > > --- a/drivers/staging/android/ashmem.c > > +++ b/drivers/staging/android/ashmem.c > > @@ -367,7 +367,7 @@ ashmem_vmfile_get_unmapped_area(struct file *file, unsigned long addr, > > > > static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) > > { > > - static struct file_operations vmfile_fops; > > + static const struct file_operations vmfile_fops; > > struct ashmem_area *asma = file->private_data; > > int ret = 0; > > Always test-build your patches before you send them out please... thanks, greg k-h ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] staging: android: ashmem.c: Cleanup 2020-06-13 17:37 [PATCH] staging: android: ashmem.c: Cleanup Dio Putra @ 2020-06-16 5:30 ` kernel test robot 2020-06-13 20:22 ` kernel test robot ` (2 subsequent siblings) 3 siblings, 0 replies; 10+ messages in thread From: kernel test robot @ 2020-06-16 5:30 UTC (permalink / raw) To: kbuild-all [-- Attachment #1: Type: text/plain, Size: 8265 bytes --] Hi Dio, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on staging/staging-testing] [cannot apply to aa5af974127d317071d6225a0f3678c5f520e7ce] url: https://github.com/0day-ci/linux/commits/Dio-Putra/staging-android-ashmem-c-Cleanup/20200614-013821 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git af7b4801030c07637840191c69eb666917e4135d :::::: branch date: 3 hours ago :::::: commit date: 3 hours ago config: i386-randconfig-s002-20200614 (attached as .config) compiler: gcc-9 (Debian 9.3.0-13) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.1-250-g42323db3-dirty # save the attached .config to linux build tree make W=1 C=1 ARCH=i386 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' 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 >>) >> drivers/staging/android/ashmem.c:418:25: sparse: sparse: assignment to const expression drivers/staging/android/ashmem.c:419:36: sparse: sparse: assignment to const expression drivers/staging/android/ashmem.c:420:36: sparse: sparse: assignment to const expression # https://github.com/0day-ci/linux/commit/7fe32ab69ec805d9e6b68fc7871f9de384429a48 git remote add linux-review https://github.com/0day-ci/linux git remote update linux-review git checkout 7fe32ab69ec805d9e6b68fc7871f9de384429a48 vim +418 drivers/staging/android/ashmem.c 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 367 11980c2ac4ccfa Robert Love 2011-12-20 368 static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) 11980c2ac4ccfa Robert Love 2011-12-20 369 { 7fe32ab69ec805 Dio Putra 2020-06-14 370 static const struct file_operations vmfile_fops; 11980c2ac4ccfa Robert Love 2011-12-20 371 struct ashmem_area *asma = file->private_data; 11980c2ac4ccfa Robert Love 2011-12-20 372 int ret = 0; 11980c2ac4ccfa Robert Love 2011-12-20 373 11980c2ac4ccfa Robert Love 2011-12-20 374 mutex_lock(&ashmem_mutex); 11980c2ac4ccfa Robert Love 2011-12-20 375 11980c2ac4ccfa Robert Love 2011-12-20 376 /* user needs to SET_SIZE before mapping */ 59848d6aded59a Alistair Strachan 2018-06-19 377 if (!asma->size) { 11980c2ac4ccfa Robert Love 2011-12-20 378 ret = -EINVAL; 11980c2ac4ccfa Robert Love 2011-12-20 379 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 380 } 11980c2ac4ccfa Robert Love 2011-12-20 381 8632c614565d0c Alistair Strachan 2018-06-19 382 /* requested mapping size larger than object size */ 8632c614565d0c Alistair Strachan 2018-06-19 383 if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) { 11980c2ac4ccfa Robert Love 2011-12-20 384 ret = -EINVAL; 11980c2ac4ccfa Robert Love 2011-12-20 385 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 386 } 11980c2ac4ccfa Robert Love 2011-12-20 387 11980c2ac4ccfa Robert Love 2011-12-20 388 /* requested protection bits must match our allowed protection mask */ 59848d6aded59a Alistair Strachan 2018-06-19 389 if ((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) & 59848d6aded59a Alistair Strachan 2018-06-19 390 calc_vm_prot_bits(PROT_MASK, 0)) { 11980c2ac4ccfa Robert Love 2011-12-20 391 ret = -EPERM; 11980c2ac4ccfa Robert Love 2011-12-20 392 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 393 } 56f76fc68492af Arve Hjønnevåg 2011-12-20 394 vma->vm_flags &= ~calc_vm_may_flags(~asma->prot_mask); 11980c2ac4ccfa Robert Love 2011-12-20 395 11980c2ac4ccfa Robert Love 2011-12-20 396 if (!asma->file) { 11980c2ac4ccfa Robert Love 2011-12-20 397 char *name = ASHMEM_NAME_DEF; 11980c2ac4ccfa Robert Love 2011-12-20 398 struct file *vmfile; 11980c2ac4ccfa Robert Love 2011-12-20 399 11980c2ac4ccfa Robert Love 2011-12-20 400 if (asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0') 11980c2ac4ccfa Robert Love 2011-12-20 401 name = asma->name; 11980c2ac4ccfa Robert Love 2011-12-20 402 11980c2ac4ccfa Robert Love 2011-12-20 403 /* ... and allocate the backing shmem file */ 11980c2ac4ccfa Robert Love 2011-12-20 404 vmfile = shmem_file_setup(name, asma->size, vma->vm_flags); 7f44cb0ba88b40 Viresh Kumar 2015-07-31 405 if (IS_ERR(vmfile)) { 11980c2ac4ccfa Robert Love 2011-12-20 406 ret = PTR_ERR(vmfile); 11980c2ac4ccfa Robert Love 2011-12-20 407 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 408 } 97fbfef6bd5978 Shuxiao Zhang 2017-04-06 409 vmfile->f_mode |= FMODE_LSEEK; 11980c2ac4ccfa Robert Love 2011-12-20 410 asma->file = vmfile; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 411 /* 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 412 * override mmap operation of the vmfile so that it can't be 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 413 * remapped which would lead to creation of a new vma with no 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 414 * asma permission checks. Have to override get_unmapped_area 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 415 * as well to prevent VM_BUG_ON check for f_ops modification. 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 416 */ 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 417 if (!vmfile_fops.mmap) { 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 @418 vmfile_fops = *vmfile->f_op; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 419 vmfile_fops.mmap = ashmem_vmfile_mmap; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 420 vmfile_fops.get_unmapped_area = 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 421 ashmem_vmfile_get_unmapped_area; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 422 } 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 423 vmfile->f_op = &vmfile_fops; 11980c2ac4ccfa Robert Love 2011-12-20 424 } 11980c2ac4ccfa Robert Love 2011-12-20 425 get_file(asma->file); 11980c2ac4ccfa Robert Love 2011-12-20 426 11980c2ac4ccfa Robert Love 2011-12-20 427 /* 11980c2ac4ccfa Robert Love 2011-12-20 428 * XXX - Reworked to use shmem_zero_setup() instead of 11980c2ac4ccfa Robert Love 2011-12-20 429 * shmem_set_file while we're in staging. -jstultz 11980c2ac4ccfa Robert Love 2011-12-20 430 */ 11980c2ac4ccfa Robert Love 2011-12-20 431 if (vma->vm_flags & VM_SHARED) { 11980c2ac4ccfa Robert Love 2011-12-20 432 ret = shmem_zero_setup(vma); 11980c2ac4ccfa Robert Love 2011-12-20 433 if (ret) { 11980c2ac4ccfa Robert Love 2011-12-20 434 fput(asma->file); 11980c2ac4ccfa Robert Love 2011-12-20 435 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 436 } 44960f2a7b63e2 John Stultz 2018-07-31 437 } else { 44960f2a7b63e2 John Stultz 2018-07-31 438 vma_set_anonymous(vma); 11980c2ac4ccfa Robert Love 2011-12-20 439 } 11980c2ac4ccfa Robert Love 2011-12-20 440 11980c2ac4ccfa Robert Love 2011-12-20 441 if (vma->vm_file) 11980c2ac4ccfa Robert Love 2011-12-20 442 fput(vma->vm_file); 11980c2ac4ccfa Robert Love 2011-12-20 443 vma->vm_file = asma->file; 11980c2ac4ccfa Robert Love 2011-12-20 444 11980c2ac4ccfa Robert Love 2011-12-20 445 out: 11980c2ac4ccfa Robert Love 2011-12-20 446 mutex_unlock(&ashmem_mutex); 11980c2ac4ccfa Robert Love 2011-12-20 447 return ret; 11980c2ac4ccfa Robert Love 2011-12-20 448 } 11980c2ac4ccfa Robert Love 2011-12-20 449 :::::: The code at line 418 was first introduced by commit :::::: 6d67b0290b4b84c477e6a2fc6e005e174d3c7786 staging: android: ashmem: Disallow ashmem memory from being remapped :::::: TO: Suren Baghdasaryan <surenb@google.com> :::::: CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org [-- Attachment #2: config.gz --] [-- Type: application/gzip, Size: 33907 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] staging: android: ashmem.c: Cleanup @ 2020-06-16 5:30 ` kernel test robot 0 siblings, 0 replies; 10+ messages in thread From: kernel test robot @ 2020-06-16 5:30 UTC (permalink / raw) To: Dio Putra, gregkh Cc: kbuild-all, arve, tkjos, maco, joel, christian, devel, linux-kernel [-- Attachment #1: Type: text/plain, Size: 8133 bytes --] Hi Dio, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on staging/staging-testing] [cannot apply to aa5af974127d317071d6225a0f3678c5f520e7ce] url: https://github.com/0day-ci/linux/commits/Dio-Putra/staging-android-ashmem-c-Cleanup/20200614-013821 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git af7b4801030c07637840191c69eb666917e4135d :::::: branch date: 3 hours ago :::::: commit date: 3 hours ago config: i386-randconfig-s002-20200614 (attached as .config) compiler: gcc-9 (Debian 9.3.0-13) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.1-250-g42323db3-dirty # save the attached .config to linux build tree make W=1 C=1 ARCH=i386 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' 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 >>) >> drivers/staging/android/ashmem.c:418:25: sparse: sparse: assignment to const expression drivers/staging/android/ashmem.c:419:36: sparse: sparse: assignment to const expression drivers/staging/android/ashmem.c:420:36: sparse: sparse: assignment to const expression # https://github.com/0day-ci/linux/commit/7fe32ab69ec805d9e6b68fc7871f9de384429a48 git remote add linux-review https://github.com/0day-ci/linux git remote update linux-review git checkout 7fe32ab69ec805d9e6b68fc7871f9de384429a48 vim +418 drivers/staging/android/ashmem.c 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 367 11980c2ac4ccfa Robert Love 2011-12-20 368 static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) 11980c2ac4ccfa Robert Love 2011-12-20 369 { 7fe32ab69ec805 Dio Putra 2020-06-14 370 static const struct file_operations vmfile_fops; 11980c2ac4ccfa Robert Love 2011-12-20 371 struct ashmem_area *asma = file->private_data; 11980c2ac4ccfa Robert Love 2011-12-20 372 int ret = 0; 11980c2ac4ccfa Robert Love 2011-12-20 373 11980c2ac4ccfa Robert Love 2011-12-20 374 mutex_lock(&ashmem_mutex); 11980c2ac4ccfa Robert Love 2011-12-20 375 11980c2ac4ccfa Robert Love 2011-12-20 376 /* user needs to SET_SIZE before mapping */ 59848d6aded59a Alistair Strachan 2018-06-19 377 if (!asma->size) { 11980c2ac4ccfa Robert Love 2011-12-20 378 ret = -EINVAL; 11980c2ac4ccfa Robert Love 2011-12-20 379 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 380 } 11980c2ac4ccfa Robert Love 2011-12-20 381 8632c614565d0c Alistair Strachan 2018-06-19 382 /* requested mapping size larger than object size */ 8632c614565d0c Alistair Strachan 2018-06-19 383 if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) { 11980c2ac4ccfa Robert Love 2011-12-20 384 ret = -EINVAL; 11980c2ac4ccfa Robert Love 2011-12-20 385 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 386 } 11980c2ac4ccfa Robert Love 2011-12-20 387 11980c2ac4ccfa Robert Love 2011-12-20 388 /* requested protection bits must match our allowed protection mask */ 59848d6aded59a Alistair Strachan 2018-06-19 389 if ((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) & 59848d6aded59a Alistair Strachan 2018-06-19 390 calc_vm_prot_bits(PROT_MASK, 0)) { 11980c2ac4ccfa Robert Love 2011-12-20 391 ret = -EPERM; 11980c2ac4ccfa Robert Love 2011-12-20 392 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 393 } 56f76fc68492af Arve Hjønnevåg 2011-12-20 394 vma->vm_flags &= ~calc_vm_may_flags(~asma->prot_mask); 11980c2ac4ccfa Robert Love 2011-12-20 395 11980c2ac4ccfa Robert Love 2011-12-20 396 if (!asma->file) { 11980c2ac4ccfa Robert Love 2011-12-20 397 char *name = ASHMEM_NAME_DEF; 11980c2ac4ccfa Robert Love 2011-12-20 398 struct file *vmfile; 11980c2ac4ccfa Robert Love 2011-12-20 399 11980c2ac4ccfa Robert Love 2011-12-20 400 if (asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0') 11980c2ac4ccfa Robert Love 2011-12-20 401 name = asma->name; 11980c2ac4ccfa Robert Love 2011-12-20 402 11980c2ac4ccfa Robert Love 2011-12-20 403 /* ... and allocate the backing shmem file */ 11980c2ac4ccfa Robert Love 2011-12-20 404 vmfile = shmem_file_setup(name, asma->size, vma->vm_flags); 7f44cb0ba88b40 Viresh Kumar 2015-07-31 405 if (IS_ERR(vmfile)) { 11980c2ac4ccfa Robert Love 2011-12-20 406 ret = PTR_ERR(vmfile); 11980c2ac4ccfa Robert Love 2011-12-20 407 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 408 } 97fbfef6bd5978 Shuxiao Zhang 2017-04-06 409 vmfile->f_mode |= FMODE_LSEEK; 11980c2ac4ccfa Robert Love 2011-12-20 410 asma->file = vmfile; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 411 /* 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 412 * override mmap operation of the vmfile so that it can't be 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 413 * remapped which would lead to creation of a new vma with no 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 414 * asma permission checks. Have to override get_unmapped_area 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 415 * as well to prevent VM_BUG_ON check for f_ops modification. 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 416 */ 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 417 if (!vmfile_fops.mmap) { 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 @418 vmfile_fops = *vmfile->f_op; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 419 vmfile_fops.mmap = ashmem_vmfile_mmap; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 420 vmfile_fops.get_unmapped_area = 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 421 ashmem_vmfile_get_unmapped_area; 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 422 } 6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 423 vmfile->f_op = &vmfile_fops; 11980c2ac4ccfa Robert Love 2011-12-20 424 } 11980c2ac4ccfa Robert Love 2011-12-20 425 get_file(asma->file); 11980c2ac4ccfa Robert Love 2011-12-20 426 11980c2ac4ccfa Robert Love 2011-12-20 427 /* 11980c2ac4ccfa Robert Love 2011-12-20 428 * XXX - Reworked to use shmem_zero_setup() instead of 11980c2ac4ccfa Robert Love 2011-12-20 429 * shmem_set_file while we're in staging. -jstultz 11980c2ac4ccfa Robert Love 2011-12-20 430 */ 11980c2ac4ccfa Robert Love 2011-12-20 431 if (vma->vm_flags & VM_SHARED) { 11980c2ac4ccfa Robert Love 2011-12-20 432 ret = shmem_zero_setup(vma); 11980c2ac4ccfa Robert Love 2011-12-20 433 if (ret) { 11980c2ac4ccfa Robert Love 2011-12-20 434 fput(asma->file); 11980c2ac4ccfa Robert Love 2011-12-20 435 goto out; 11980c2ac4ccfa Robert Love 2011-12-20 436 } 44960f2a7b63e2 John Stultz 2018-07-31 437 } else { 44960f2a7b63e2 John Stultz 2018-07-31 438 vma_set_anonymous(vma); 11980c2ac4ccfa Robert Love 2011-12-20 439 } 11980c2ac4ccfa Robert Love 2011-12-20 440 11980c2ac4ccfa Robert Love 2011-12-20 441 if (vma->vm_file) 11980c2ac4ccfa Robert Love 2011-12-20 442 fput(vma->vm_file); 11980c2ac4ccfa Robert Love 2011-12-20 443 vma->vm_file = asma->file; 11980c2ac4ccfa Robert Love 2011-12-20 444 11980c2ac4ccfa Robert Love 2011-12-20 445 out: 11980c2ac4ccfa Robert Love 2011-12-20 446 mutex_unlock(&ashmem_mutex); 11980c2ac4ccfa Robert Love 2011-12-20 447 return ret; 11980c2ac4ccfa Robert Love 2011-12-20 448 } 11980c2ac4ccfa Robert Love 2011-12-20 449 :::::: The code at line 418 was first introduced by commit :::::: 6d67b0290b4b84c477e6a2fc6e005e174d3c7786 staging: android: ashmem: Disallow ashmem memory from being remapped :::::: TO: Suren Baghdasaryan <surenb@google.com> :::::: CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 33907 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] staging: android: ashmem.c: Cleanup
@ 2020-06-13 20:26 kernel test robot
0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2020-06-13 20:26 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 8694 bytes --]
CC: kbuild-all(a)lists.01.org
In-Reply-To: <4ba43a70-c29f-6c41-9c81-66a25b0432af@gmail.com>
References: <4ba43a70-c29f-6c41-9c81-66a25b0432af@gmail.com>
TO: Dio Putra <dioput12@gmail.com>
TO: gregkh(a)linuxfoundation.org
CC: arve(a)android.com
CC: tkjos(a)android.com
CC: maco(a)android.com
CC: joel(a)joelfernandes.org
CC: christian(a)brauner.io
CC: devel(a)driverdev.osuosl.org
CC: linux-kernel(a)vger.kernel.org
Hi Dio,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on staging/staging-testing]
[cannot apply to aa5af974127d317071d6225a0f3678c5f520e7ce]
url: https://github.com/0day-ci/linux/commits/Dio-Putra/staging-android-ashmem-c-Cleanup/20200614-013821
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git af7b4801030c07637840191c69eb666917e4135d
:::::: branch date: 3 hours ago
:::::: commit date: 3 hours ago
config: i386-randconfig-s002-20200614 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-250-g42323db3-dirty
# save the attached .config to linux build tree
make W=1 C=1 ARCH=i386 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
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 >>)
>> drivers/staging/android/ashmem.c:418:25: sparse: sparse: assignment to const expression
drivers/staging/android/ashmem.c:419:36: sparse: sparse: assignment to const expression
drivers/staging/android/ashmem.c:420:36: sparse: sparse: assignment to const expression
# https://github.com/0day-ci/linux/commit/7fe32ab69ec805d9e6b68fc7871f9de384429a48
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 7fe32ab69ec805d9e6b68fc7871f9de384429a48
vim +418 drivers/staging/android/ashmem.c
6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 367
11980c2ac4ccfa Robert Love 2011-12-20 368 static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
11980c2ac4ccfa Robert Love 2011-12-20 369 {
7fe32ab69ec805 Dio Putra 2020-06-14 370 static const struct file_operations vmfile_fops;
11980c2ac4ccfa Robert Love 2011-12-20 371 struct ashmem_area *asma = file->private_data;
11980c2ac4ccfa Robert Love 2011-12-20 372 int ret = 0;
11980c2ac4ccfa Robert Love 2011-12-20 373
11980c2ac4ccfa Robert Love 2011-12-20 374 mutex_lock(&ashmem_mutex);
11980c2ac4ccfa Robert Love 2011-12-20 375
11980c2ac4ccfa Robert Love 2011-12-20 376 /* user needs to SET_SIZE before mapping */
59848d6aded59a Alistair Strachan 2018-06-19 377 if (!asma->size) {
11980c2ac4ccfa Robert Love 2011-12-20 378 ret = -EINVAL;
11980c2ac4ccfa Robert Love 2011-12-20 379 goto out;
11980c2ac4ccfa Robert Love 2011-12-20 380 }
11980c2ac4ccfa Robert Love 2011-12-20 381
8632c614565d0c Alistair Strachan 2018-06-19 382 /* requested mapping size larger than object size */
8632c614565d0c Alistair Strachan 2018-06-19 383 if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) {
11980c2ac4ccfa Robert Love 2011-12-20 384 ret = -EINVAL;
11980c2ac4ccfa Robert Love 2011-12-20 385 goto out;
11980c2ac4ccfa Robert Love 2011-12-20 386 }
11980c2ac4ccfa Robert Love 2011-12-20 387
11980c2ac4ccfa Robert Love 2011-12-20 388 /* requested protection bits must match our allowed protection mask */
59848d6aded59a Alistair Strachan 2018-06-19 389 if ((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) &
59848d6aded59a Alistair Strachan 2018-06-19 390 calc_vm_prot_bits(PROT_MASK, 0)) {
11980c2ac4ccfa Robert Love 2011-12-20 391 ret = -EPERM;
11980c2ac4ccfa Robert Love 2011-12-20 392 goto out;
11980c2ac4ccfa Robert Love 2011-12-20 393 }
56f76fc68492af Arve Hjønnevåg 2011-12-20 394 vma->vm_flags &= ~calc_vm_may_flags(~asma->prot_mask);
11980c2ac4ccfa Robert Love 2011-12-20 395
11980c2ac4ccfa Robert Love 2011-12-20 396 if (!asma->file) {
11980c2ac4ccfa Robert Love 2011-12-20 397 char *name = ASHMEM_NAME_DEF;
11980c2ac4ccfa Robert Love 2011-12-20 398 struct file *vmfile;
11980c2ac4ccfa Robert Love 2011-12-20 399
11980c2ac4ccfa Robert Love 2011-12-20 400 if (asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0')
11980c2ac4ccfa Robert Love 2011-12-20 401 name = asma->name;
11980c2ac4ccfa Robert Love 2011-12-20 402
11980c2ac4ccfa Robert Love 2011-12-20 403 /* ... and allocate the backing shmem file */
11980c2ac4ccfa Robert Love 2011-12-20 404 vmfile = shmem_file_setup(name, asma->size, vma->vm_flags);
7f44cb0ba88b40 Viresh Kumar 2015-07-31 405 if (IS_ERR(vmfile)) {
11980c2ac4ccfa Robert Love 2011-12-20 406 ret = PTR_ERR(vmfile);
11980c2ac4ccfa Robert Love 2011-12-20 407 goto out;
11980c2ac4ccfa Robert Love 2011-12-20 408 }
97fbfef6bd5978 Shuxiao Zhang 2017-04-06 409 vmfile->f_mode |= FMODE_LSEEK;
11980c2ac4ccfa Robert Love 2011-12-20 410 asma->file = vmfile;
6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 411 /*
6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 412 * override mmap operation of the vmfile so that it can't be
6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 413 * remapped which would lead to creation of a new vma with no
6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 414 * asma permission checks. Have to override get_unmapped_area
6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 415 * as well to prevent VM_BUG_ON check for f_ops modification.
6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 416 */
6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 417 if (!vmfile_fops.mmap) {
6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 @418 vmfile_fops = *vmfile->f_op;
6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 419 vmfile_fops.mmap = ashmem_vmfile_mmap;
6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 420 vmfile_fops.get_unmapped_area =
6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 421 ashmem_vmfile_get_unmapped_area;
6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 422 }
6d67b0290b4b84 Suren Baghdasaryan 2020-01-27 423 vmfile->f_op = &vmfile_fops;
11980c2ac4ccfa Robert Love 2011-12-20 424 }
11980c2ac4ccfa Robert Love 2011-12-20 425 get_file(asma->file);
11980c2ac4ccfa Robert Love 2011-12-20 426
11980c2ac4ccfa Robert Love 2011-12-20 427 /*
11980c2ac4ccfa Robert Love 2011-12-20 428 * XXX - Reworked to use shmem_zero_setup() instead of
11980c2ac4ccfa Robert Love 2011-12-20 429 * shmem_set_file while we're in staging. -jstultz
11980c2ac4ccfa Robert Love 2011-12-20 430 */
11980c2ac4ccfa Robert Love 2011-12-20 431 if (vma->vm_flags & VM_SHARED) {
11980c2ac4ccfa Robert Love 2011-12-20 432 ret = shmem_zero_setup(vma);
11980c2ac4ccfa Robert Love 2011-12-20 433 if (ret) {
11980c2ac4ccfa Robert Love 2011-12-20 434 fput(asma->file);
11980c2ac4ccfa Robert Love 2011-12-20 435 goto out;
11980c2ac4ccfa Robert Love 2011-12-20 436 }
44960f2a7b63e2 John Stultz 2018-07-31 437 } else {
44960f2a7b63e2 John Stultz 2018-07-31 438 vma_set_anonymous(vma);
11980c2ac4ccfa Robert Love 2011-12-20 439 }
11980c2ac4ccfa Robert Love 2011-12-20 440
11980c2ac4ccfa Robert Love 2011-12-20 441 if (vma->vm_file)
11980c2ac4ccfa Robert Love 2011-12-20 442 fput(vma->vm_file);
11980c2ac4ccfa Robert Love 2011-12-20 443 vma->vm_file = asma->file;
11980c2ac4ccfa Robert Love 2011-12-20 444
11980c2ac4ccfa Robert Love 2011-12-20 445 out:
11980c2ac4ccfa Robert Love 2011-12-20 446 mutex_unlock(&ashmem_mutex);
11980c2ac4ccfa Robert Love 2011-12-20 447 return ret;
11980c2ac4ccfa Robert Love 2011-12-20 448 }
11980c2ac4ccfa Robert Love 2011-12-20 449
:::::: The code at line 418 was first introduced by commit
:::::: 6d67b0290b4b84c477e6a2fc6e005e174d3c7786 staging: android: ashmem: Disallow ashmem memory from being remapped
:::::: TO: Suren Baghdasaryan <surenb@google.com>
:::::: CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33907 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in threadend of thread, other threads:[~2020-06-16 5:40 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-06-13 17:37 [PATCH] staging: android: ashmem.c: Cleanup Dio Putra 2020-06-13 19:53 ` kernel test robot 2020-06-13 19:53 ` kernel test robot 2020-06-13 20:22 ` kernel test robot 2020-06-13 20:22 ` kernel test robot 2020-06-14 4:40 ` Dio Putra 2020-06-14 6:25 ` Greg KH 2020-06-16 5:30 ` kernel test robot 2020-06-16 5:30 ` kernel test robot -- strict thread matches above, loose matches on Subject: below -- 2020-06-13 20:26 kernel test robot
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.