DriverDev-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] staging: android: ashmem: Fixed a issue related to file_operations
@ 2020-05-13 11:41 Anmol
  2020-05-13 12:02 ` Greg KH
  2020-05-13 16:44 ` kbuild test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Anmol @ 2020-05-13 11:41 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel, Anmol

From: Anmol <anmol.karan123@gmail.com>

Fixed a issue related to struct file_operations which should normally be const.

Signed-off-by: Anmol <anmol.karan123@gmail.com>
---
 drivers/staging/android/ashmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
 
-- 
2.20.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: android: ashmem: Fixed a issue related to file_operations
  2020-05-13 11:41 [PATCH] staging: android: ashmem: Fixed a issue related to file_operations Anmol
@ 2020-05-13 12:02 ` Greg KH
       [not found]   ` <CAC+yH-boJnUbnhkLdkZ3Vj8_1D0OMBLKsBYbrcJ2sr29_ekeJQ@mail.gmail.com>
  2020-05-13 16:44 ` kbuild test robot
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2020-05-13 12:02 UTC (permalink / raw)
  To: Anmol; +Cc: devel, linux-kernel

On Wed, May 13, 2020 at 05:11:16PM +0530, Anmol wrote:
> From: Anmol <anmol.karan123@gmail.com>
> 
> Fixed a issue related to struct file_operations which should normally be const.
> 
> Signed-off-by: Anmol <anmol.karan123@gmail.com>
> ---
>  drivers/staging/android/ashmem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 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;

Did you properly build this change?

Also, always use your full name for kernel changes, as the Documentation
states to.

thanks,

greg k-h
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: android: ashmem: Fixed a issue related to file_operations
  2020-05-13 11:41 [PATCH] staging: android: ashmem: Fixed a issue related to file_operations Anmol
  2020-05-13 12:02 ` Greg KH
@ 2020-05-13 16:44 ` kbuild test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2020-05-13 16:44 UTC (permalink / raw)
  To: Anmol, gregkh; +Cc: devel, kbuild-all, linux-kernel, Anmol


[-- Attachment #1: Type: text/plain, Size: 8156 bytes --]

Hi Anmol,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v5.7-rc5 next-20200512]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Anmol/staging-android-ashmem-Fixed-a-issue-related-to-file_operations/20200513-194410
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 1ff4388a06eb001efbc272754ef750c0b97817cb
config: um-allmodconfig (attached as .config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=um 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new 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'
vmfile_fops = *vmfile->f_op;
^
>> drivers/staging/android/ashmem.c:419:21: error: assignment of member 'mmap' in read-only object
vmfile_fops.mmap = ashmem_vmfile_mmap;
^
>> drivers/staging/android/ashmem.c:420:34: error: assignment of member 'get_unmapped_area' in read-only object
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  {
823a00202dabb1 Anmol              2020-05-13  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: 22558 bytes --]

[-- Attachment #3: Type: text/plain, Size: 169 bytes --]

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: android: ashmem: Fixed a issue related to file_operations
       [not found]   ` <CAC+yH-boJnUbnhkLdkZ3Vj8_1D0OMBLKsBYbrcJ2sr29_ekeJQ@mail.gmail.com>
@ 2020-05-15  8:04     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2020-05-15  8:04 UTC (permalink / raw)
  To: Anmol karn; +Cc: devel, linux-kernel

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?


http://daringfireball.net/2007/07/on_top

On Fri, May 15, 2020 at 01:16:12PM +0530, Anmol karn wrote:
> Hello sir,
> Thank you for your response,
> 
> Did you properly build this change?
> 
> 
> I have build the *linux_stable* according to the LFD103 course (By Linux
> Foundation) and the kernel they used in their tutorial was *5.2.21  *so, my
> question is can I use this kernel for the patch or do I need to switch to
> the recent mainline kernel release. Because in the recent patch I have used
> *5.2.21.*

Working on a 6 month old kernel is not going to help at all, you need to
work on the latest tree at the least.  linux-next is best.  Otherwise
you end up making changes that can not be applied, or have already been
done by others, which is just a waste of time.

But what I asked is if you actually test built the change you made.  As
the kbuild bot showed you, you obviously did not :(

Please always do that, you can not add new warnings to the kernel, nor
break the build with any change.

Also work on your knowledge of C before doing more kernel work, as the
change is not correct for the obvious reasons that it is not allowed by
the language.  checkpatch is just a perl script, sometimes it give
incorrect information, like this time.

> Also, always use your full name for kernel changes, as the Documentation
> > states to.
> 
> 
>  Sir, my legal full name is 'Anmol' only.

That does not match what your email "From:" says :)

greg k-h
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-13 11:41 [PATCH] staging: android: ashmem: Fixed a issue related to file_operations Anmol
2020-05-13 12:02 ` Greg KH
     [not found]   ` <CAC+yH-boJnUbnhkLdkZ3Vj8_1D0OMBLKsBYbrcJ2sr29_ekeJQ@mail.gmail.com>
2020-05-15  8:04     ` Greg KH
2020-05-13 16:44 ` kbuild test robot

DriverDev-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/driverdev-devel/0 driverdev-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 driverdev-devel driverdev-devel/ https://lore.kernel.org/driverdev-devel \
		driverdev-devel@linuxdriverproject.org devel@driverdev.osuosl.org
	public-inbox-index driverdev-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxdriverproject.driverdev-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git