kexec.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()
@ 2016-09-29  7:59 Madhavan Srinivasan
  2016-09-29  8:20 ` Simon Horman
  2016-09-29  8:24 ` Pratyush Anand
  0 siblings, 2 replies; 4+ messages in thread
From: Madhavan Srinivasan @ 2016-09-29  7:59 UTC (permalink / raw)
  To: horms; +Cc: panand, Madhavan Srinivasan, kexec

In dt_copy_old_root_param(), FILE * returned
from fopen is not checked for NULL pointer
before passinig to fclose(). This could trigger
a segfault. Patch to fix the same.

Reviewed-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
---
Changelog v1:
 - Moved the check right after fopen

 kexec/fs2dt.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
index 6ed2399759cf..5ba3ec0fa65c 100644
--- a/kexec/fs2dt.c
+++ b/kexec/fs2dt.c
@@ -524,6 +524,9 @@ static void dt_copy_old_root_param(void)
 	strcpy(filename, pathname);
 	strcat(filename, "bootargs");
 	fp = fopen(filename, "r");
+	if (!fp)
+		return;
+
 	if (fp) {
 		if (getline(&last_cmdline, &len, fp) == -1)
 			die("unable to read %s\n", filename);
-- 
2.7.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* Re: [PATCH v2] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()
  2016-09-29  7:59 [PATCH v2] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param() Madhavan Srinivasan
@ 2016-09-29  8:20 ` Simon Horman
  2016-09-29  8:29   ` Dave Young
  2016-09-29  8:24 ` Pratyush Anand
  1 sibling, 1 reply; 4+ messages in thread
From: Simon Horman @ 2016-09-29  8:20 UTC (permalink / raw)
  To: Madhavan Srinivasan; +Cc: panand, Dave Young, kexec

[CC Dave Young]

On Thu, Sep 29, 2016 at 01:29:13PM +0530, Madhavan Srinivasan wrote:
> In dt_copy_old_root_param(), FILE * returned
> from fopen is not checked for NULL pointer
> before passinig to fclose(). This could trigger
> a segfault. Patch to fix the same.
> 
> Reviewed-by: Dave Young <dyoung@redhat.com>

Probably Dave's tag should be dropped as that was for a somewhat
different (though equally trivial) approach.

> Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
> ---
> Changelog v1:
>  - Moved the check right after fopen
> 
>  kexec/fs2dt.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
> index 6ed2399759cf..5ba3ec0fa65c 100644
> --- a/kexec/fs2dt.c
> +++ b/kexec/fs2dt.c
> @@ -524,6 +524,9 @@ static void dt_copy_old_root_param(void)
>  	strcpy(filename, pathname);
>  	strcat(filename, "bootargs");
>  	fp = fopen(filename, "r");
> +	if (!fp)
> +		return;
> +

With the (!fp) conditional above the (fp) conditional below can be removed.

>  	if (fp) {
>  		if (getline(&last_cmdline, &len, fp) == -1)
>  			die("unable to read %s\n", filename);
> -- 
> 2.7.4
> 

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* Re: [PATCH v2] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()
  2016-09-29  7:59 [PATCH v2] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param() Madhavan Srinivasan
  2016-09-29  8:20 ` Simon Horman
@ 2016-09-29  8:24 ` Pratyush Anand
  1 sibling, 0 replies; 4+ messages in thread
From: Pratyush Anand @ 2016-09-29  8:24 UTC (permalink / raw)
  To: Madhavan Srinivasan, horms; +Cc: kexec



On Thursday 29 September 2016 01:29 PM, Madhavan Srinivasan wrote:
> In dt_copy_old_root_param(), FILE * returned
> from fopen is not checked for NULL pointer
> before passinig to fclose(). This could trigger
> a segfault. Patch to fix the same.
>
> Reviewed-by: Dave Young <dyoung@redhat.com>
> Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>

Reviewed-by: Pratyush Anand <panand@redhat.com>

> ---
> Changelog v1:
>  - Moved the check right after fopen
>
>  kexec/fs2dt.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
> index 6ed2399759cf..5ba3ec0fa65c 100644
> --- a/kexec/fs2dt.c
> +++ b/kexec/fs2dt.c
> @@ -524,6 +524,9 @@ static void dt_copy_old_root_param(void)
>  	strcpy(filename, pathname);
>  	strcat(filename, "bootargs");
>  	fp = fopen(filename, "r");
> +	if (!fp)
> +		return;
> +
>  	if (fp) {
>  		if (getline(&last_cmdline, &len, fp) == -1)
>  			die("unable to read %s\n", filename);
>

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* Re: [PATCH v2] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()
  2016-09-29  8:20 ` Simon Horman
@ 2016-09-29  8:29   ` Dave Young
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Young @ 2016-09-29  8:29 UTC (permalink / raw)
  To: Simon Horman; +Cc: panand, Madhavan Srinivasan, kexec

On 09/29/16 at 10:20am, Simon Horman wrote:
> [CC Dave Young]
> 
> On Thu, Sep 29, 2016 at 01:29:13PM +0530, Madhavan Srinivasan wrote:
> > In dt_copy_old_root_param(), FILE * returned
> > from fopen is not checked for NULL pointer
> > before passinig to fclose(). This could trigger
> > a segfault. Patch to fix the same.
> > 
> > Reviewed-by: Dave Young <dyoung@redhat.com>
> 
> Probably Dave's tag should be dropped as that was for a somewhat
> different (though equally trivial) approach.

Simion, I think I'm fine with any of them. 

> 
> > Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
> > ---
> > Changelog v1:
> >  - Moved the check right after fopen
> > 
> >  kexec/fs2dt.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
> > index 6ed2399759cf..5ba3ec0fa65c 100644
> > --- a/kexec/fs2dt.c
> > +++ b/kexec/fs2dt.c
> > @@ -524,6 +524,9 @@ static void dt_copy_old_root_param(void)
> >  	strcpy(filename, pathname);
> >  	strcat(filename, "bootargs");
> >  	fp = fopen(filename, "r");
> > +	if (!fp)
> > +		return;
> > +
> 
> With the (!fp) conditional above the (fp) conditional below can be removed.
> 
> >  	if (fp) {
> >  		if (getline(&last_cmdline, &len, fp) == -1)
> >  			die("unable to read %s\n", filename);
> > -- 
> > 2.7.4
> > 

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

end of thread, other threads:[~2016-09-29  8:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-29  7:59 [PATCH v2] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param() Madhavan Srinivasan
2016-09-29  8:20 ` Simon Horman
2016-09-29  8:29   ` Dave Young
2016-09-29  8:24 ` Pratyush Anand

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).