public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] arch/parisc: mm: fix uninitialized variable usage
@ 2013-09-22 18:17 Felipe Pena
  2013-09-22 22:58 ` Johannes Weiner
  0 siblings, 1 reply; 3+ messages in thread
From: Felipe Pena @ 2013-09-22 18:17 UTC (permalink / raw)
  To: James E.J. Bottomley, linux-parisc, Michal Hocko, Johannes Weiner,
	linux-kernel, Kautuk Consul, Andrew Morton, Helge Deller
  Cc: Felipe Pena

The FAULT_FLAG_WRITE flag has been set based on uninitialized variable

Signed-off-by: Felipe Pena <felipensp@gmail.com>
---
 arch/parisc/mm/fault.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
index d10d27a..6b38026 100644
--- a/arch/parisc/mm/fault.c
+++ b/arch/parisc/mm/fault.c
@@ -182,8 +182,6 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
 
 	if (user_mode(regs))
 		flags |= FAULT_FLAG_USER;
-	if (acc_type & VM_WRITE)
-		flags |= FAULT_FLAG_WRITE;
 retry:
 	down_read(&mm->mmap_sem);
 	vma = find_vma_prev(mm, address, &prev_vma);
@@ -201,6 +199,9 @@ good_area:
 	if ((vma->vm_flags & acc_type) != acc_type)
 		goto bad_area;
 
+	if (acc_type & VM_WRITE)
+		flags |= FAULT_FLAG_WRITE;
+
 	/*
 	 * If for any reason at all we couldn't handle the fault, make
 	 * sure we exit gracefully rather than endlessly redo the
-- 
1.7.10.4


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

* Re: [PATCH 1/1] arch/parisc: mm: fix uninitialized variable usage
  2013-09-22 18:17 [PATCH 1/1] arch/parisc: mm: fix uninitialized variable usage Felipe Pena
@ 2013-09-22 22:58 ` Johannes Weiner
  2013-09-23  0:23   ` Felipe Pena
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Weiner @ 2013-09-22 22:58 UTC (permalink / raw)
  To: Felipe Pena
  Cc: James E.J. Bottomley, linux-parisc, Michal Hocko, linux-kernel,
	Kautuk Consul, Andrew Morton, Helge Deller

Hello Felipe,

On Sun, Sep 22, 2013 at 03:17:46PM -0300, Felipe Pena wrote:
> The FAULT_FLAG_WRITE flag has been set based on uninitialized variable

Oops, you are right.

> Signed-off-by: Felipe Pena <felipensp@gmail.com>
> ---
>  arch/parisc/mm/fault.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
> index d10d27a..6b38026 100644
> --- a/arch/parisc/mm/fault.c
> +++ b/arch/parisc/mm/fault.c
> @@ -182,8 +182,6 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
>  
>  	if (user_mode(regs))
>  		flags |= FAULT_FLAG_USER;
> -	if (acc_type & VM_WRITE)
> -		flags |= FAULT_FLAG_WRITE;
>  retry:
>  	down_read(&mm->mmap_sem);
>  	vma = find_vma_prev(mm, address, &prev_vma);
> @@ -201,6 +199,9 @@ good_area:
>  	if ((vma->vm_flags & acc_type) != acc_type)
>  		goto bad_area;
>  
> +	if (acc_type & VM_WRITE)
> +		flags |= FAULT_FLAG_WRITE;

Can acc_type actually change between between the first round and a
retry?  Otherwise, it might make sense to pull this up and place it
next to the flag initialization instead of pulling one flag down.

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

* Re: [PATCH 1/1] arch/parisc: mm: fix uninitialized variable usage
  2013-09-22 22:58 ` Johannes Weiner
@ 2013-09-23  0:23   ` Felipe Pena
  0 siblings, 0 replies; 3+ messages in thread
From: Felipe Pena @ 2013-09-23  0:23 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: James E.J. Bottomley, linux-parisc, Michal Hocko, linux-kernel,
	Kautuk Consul, Andrew Morton, Helge Deller

Hello Johannes,

On Sun, Sep 22, 2013 at 7:58 PM, Johannes Weiner <hannes@cmpxchg.org> wrote:
> Hello Felipe,
>
> On Sun, Sep 22, 2013 at 03:17:46PM -0300, Felipe Pena wrote:
>> The FAULT_FLAG_WRITE flag has been set based on uninitialized variable
>
> Oops, you are right.
>
>> Signed-off-by: Felipe Pena <felipensp@gmail.com>
>> ---
>>  arch/parisc/mm/fault.c |    5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
>> index d10d27a..6b38026 100644
>> --- a/arch/parisc/mm/fault.c
>> +++ b/arch/parisc/mm/fault.c
>> @@ -182,8 +182,6 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
>>
>>       if (user_mode(regs))
>>               flags |= FAULT_FLAG_USER;
>> -     if (acc_type & VM_WRITE)
>> -             flags |= FAULT_FLAG_WRITE;
>>  retry:
>>       down_read(&mm->mmap_sem);
>>       vma = find_vma_prev(mm, address, &prev_vma);
>> @@ -201,6 +199,9 @@ good_area:
>>       if ((vma->vm_flags & acc_type) != acc_type)
>>               goto bad_area;
>>
>> +     if (acc_type & VM_WRITE)
>> +             flags |= FAULT_FLAG_WRITE;
>
> Can acc_type actually change between between the first round and a
> retry?  Otherwise, it might make sense to pull this up and place it
> next to the flag initialization instead of pulling one flag down.

>From what I've analyzed, this make sense. I'll make the suggested
changes and send another patch.

Thanks.

-- 
Regards,
Felipe Pena

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

end of thread, other threads:[~2013-09-23  0:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-22 18:17 [PATCH 1/1] arch/parisc: mm: fix uninitialized variable usage Felipe Pena
2013-09-22 22:58 ` Johannes Weiner
2013-09-23  0:23   ` Felipe Pena

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox