kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] kcore: fix test for end of list
@ 2010-03-22 12:05 Dan Carpenter
  2010-03-23  0:18 ` KAMEZAWA Hiroyuki
  2010-03-23  3:31 ` Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Dan Carpenter @ 2010-03-22 12:05 UTC (permalink / raw)
  To: Andrew Morton
  Cc: KAMEZAWA Hiroyuki, WANG Cong, Jiri Slaby, Jaswinder Singh Rajput,
	linux-kernel, kernel-janitors

"m" is never NULL here.  We need a different test for the end of list
condition.

Signed-off-by: Dan Carpenter <error27@gmail.com>
---
Found with a static checker and compile tested only.  Please review
carefully.

diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index a44a789..b442dac 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -490,7 +490,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
 		}
 		read_unlock(&kclist_lock);
 
-		if (m = NULL) {
+		if (&m->list = &kclist_head) {
 			if (clear_user(buffer, tsz))
 				return -EFAULT;
 		} else if (is_vmalloc_or_module_addr((void *)start)) {

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

* Re: [patch] kcore: fix test for end of list
  2010-03-22 12:05 [patch] kcore: fix test for end of list Dan Carpenter
@ 2010-03-23  0:18 ` KAMEZAWA Hiroyuki
  2010-03-23  2:47   ` Américo Wang
  2010-03-23  3:31 ` Andrew Morton
  1 sibling, 1 reply; 6+ messages in thread
From: KAMEZAWA Hiroyuki @ 2010-03-23  0:18 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Andrew Morton, WANG Cong, Jiri Slaby, Jaswinder Singh Rajput,
	linux-kernel, kernel-janitors

On Mon, 22 Mar 2010 15:05:09 +0300
Dan Carpenter <error27@gmail.com> wrote:

> "m" is never NULL here.  We need a different test for the end of list
> condition.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

yes, thank you.
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>


> ---
> Found with a static checker and compile tested only.  Please review
> carefully.
> 
> diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
> index a44a789..b442dac 100644
> --- a/fs/proc/kcore.c
> +++ b/fs/proc/kcore.c
> @@ -490,7 +490,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
>  		}
>  		read_unlock(&kclist_lock);
>  
> -		if (m = NULL) {
> +		if (&m->list = &kclist_head) {
>  			if (clear_user(buffer, tsz))
>  				return -EFAULT;
>  		} else if (is_vmalloc_or_module_addr((void *)start)) {
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


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

* Re: [patch] kcore: fix test for end of list
  2010-03-23  0:18 ` KAMEZAWA Hiroyuki
@ 2010-03-23  2:47   ` Américo Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Américo Wang @ 2010-03-23  2:47 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki
  Cc: Dan Carpenter, Andrew Morton, Jiri Slaby, Jaswinder Singh Rajput,
	linux-kernel, kernel-janitors

On Tue, Mar 23, 2010 at 8:18 AM, KAMEZAWA Hiroyuki
<kamezawa.hiroyu@jp.fujitsu.com> wrote:
> On Mon, 22 Mar 2010 15:05:09 +0300
> Dan Carpenter <error27@gmail.com> wrote:
>
>> "m" is never NULL here.  We need a different test for the end of list
>> condition.
>>
>> Signed-off-by: Dan Carpenter <error27@gmail.com>
>
> yes, thank you.
> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

Yeah, this is a good catch for me too!

Acked-by: WANG Cong <xiyou.wangcong@gmail.com>
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [patch] kcore: fix test for end of list
  2010-03-22 12:05 [patch] kcore: fix test for end of list Dan Carpenter
  2010-03-23  0:18 ` KAMEZAWA Hiroyuki
@ 2010-03-23  3:31 ` Andrew Morton
  2010-03-23  6:54   ` KAMEZAWA Hiroyuki
  2010-03-23  7:00   ` Américo Wang
  1 sibling, 2 replies; 6+ messages in thread
From: Andrew Morton @ 2010-03-23  3:31 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: KAMEZAWA Hiroyuki, WANG Cong, Jiri Slaby, Jaswinder Singh Rajput,
	linux-kernel, kernel-janitors

On Mon, 22 Mar 2010 15:05:09 +0300 Dan Carpenter <error27@gmail.com> wrote:

> "m" is never NULL here.  We need a different test for the end of list
> condition.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> Found with a static checker and compile tested only.  Please review
> carefully.
> 
> diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
> index a44a789..b442dac 100644
> --- a/fs/proc/kcore.c
> +++ b/fs/proc/kcore.c
> @@ -490,7 +490,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
>  		}
>  		read_unlock(&kclist_lock);
>  
> -		if (m = NULL) {
> +		if (&m->list = &kclist_head) {
>  			if (clear_user(buffer, tsz))
>  				return -EFAULT;
>  		} else if (is_vmalloc_or_module_addr((void *)start)) {

hm, that code's been there for five years.  I wonder if it's actually necessary.

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

* Re: [patch] kcore: fix test for end of list
  2010-03-23  3:31 ` Andrew Morton
@ 2010-03-23  6:54   ` KAMEZAWA Hiroyuki
  2010-03-23  7:00   ` Américo Wang
  1 sibling, 0 replies; 6+ messages in thread
From: KAMEZAWA Hiroyuki @ 2010-03-23  6:54 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Dan Carpenter, WANG Cong, Jiri Slaby, Jaswinder Singh Rajput,
	linux-kernel, kernel-janitors

On Mon, 22 Mar 2010 23:31:13 -0400
Andrew Morton <akpm@linux-foundation.org> wrote:

> On Mon, 22 Mar 2010 15:05:09 +0300 Dan Carpenter <error27@gmail.com> wrote:
> 
> > "m" is never NULL here.  We need a different test for the end of list
> > condition.
> > 
> > Signed-off-by: Dan Carpenter <error27@gmail.com>
> > ---
> > Found with a static checker and compile tested only.  Please review
> > carefully.
> > 
> > diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
> > index a44a789..b442dac 100644
> > --- a/fs/proc/kcore.c
> > +++ b/fs/proc/kcore.c
> > @@ -490,7 +490,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
> >  		}
> >  		read_unlock(&kclist_lock);
> >  
> > -		if (m = NULL) {
> > +		if (&m->list = &kclist_head) {
> >  			if (clear_user(buffer, tsz))
> >  				return -EFAULT;
> >  		} else if (is_vmalloc_or_module_addr((void *)start)) {
> 
> hm, that code's been there for five years.  I wonder if it's actually necessary.
> 
Hmm..on x86 and others, finally,
	(kern_addr_valid(start))
will catch bad access. But some architectures seems to define kern_addr_valid() as

#define kern_addr_valid(addr)   (1) (from arch/ia64/include/asm/pgtable.h)

Then, we should check "start" is valid address by ourselves (for now). We have
a complete list of registered address in kclist_head.

Regards,
-Kame



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

* Re: [patch] kcore: fix test for end of list
  2010-03-23  3:31 ` Andrew Morton
  2010-03-23  6:54   ` KAMEZAWA Hiroyuki
@ 2010-03-23  7:00   ` Américo Wang
  1 sibling, 0 replies; 6+ messages in thread
From: Américo Wang @ 2010-03-23  7:00 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Dan Carpenter, KAMEZAWA Hiroyuki, Jiri Slaby,
	Jaswinder Singh Rajput, linux-kernel, kernel-janitors

On Tue, Mar 23, 2010 at 11:31 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Mon, 22 Mar 2010 15:05:09 +0300 Dan Carpenter <error27@gmail.com> wrote:
>
>> "m" is never NULL here.  We need a different test for the end of list
>> condition.
>>
>> Signed-off-by: Dan Carpenter <error27@gmail.com>
>> ---
>> Found with a static checker and compile tested only.  Please review
>> carefully.
>>
>> diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
>> index a44a789..b442dac 100644
>> --- a/fs/proc/kcore.c
>> +++ b/fs/proc/kcore.c
>> @@ -490,7 +490,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
>>               }
>>               read_unlock(&kclist_lock);
>>
>> -             if (m = NULL) {
>> +             if (&m->list = &kclist_head) {
>>                       if (clear_user(buffer, tsz))
>>                               return -EFAULT;
>>               } else if (is_vmalloc_or_module_addr((void *)start)) {
>
> hm, that code's been there for five years.  I wonder if it's actually necessary.

Nope, not that long, please see commit 2ef43ec7. :)

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

end of thread, other threads:[~2010-03-23  7:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-22 12:05 [patch] kcore: fix test for end of list Dan Carpenter
2010-03-23  0:18 ` KAMEZAWA Hiroyuki
2010-03-23  2:47   ` Américo Wang
2010-03-23  3:31 ` Andrew Morton
2010-03-23  6:54   ` KAMEZAWA Hiroyuki
2010-03-23  7:00   ` Américo Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).