All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ls: prevent double open
@ 2017-10-16 20:11 Eric Snowberg
  2017-10-17 13:22 ` Daniel Kiper
  2017-10-18 16:32 ` Vladimir 'phcoder' Serbinenko
  0 siblings, 2 replies; 11+ messages in thread
From: Eric Snowberg @ 2017-10-16 20:11 UTC (permalink / raw)
  To: grub-devel; +Cc: phcoder, daniel.kiper, Eric Snowberg

Prevent a double open.  This can cause problems with some ieee1275
devices, causing the system to hang.  The double open can occur
as follows:

grub_ls_list_files (char *dirname, int longlist, int all, int human)
       dev = grub_device_open (device_name);
       dev remains open while:
       grub_normal_print_device_info (device_name);
                dev = grub_device_open (name);

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
 grub-core/commands/ls.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c
index 0eaf836..a7318ab 100644
--- a/grub-core/commands/ls.c
+++ b/grub-core/commands/ls.c
@@ -201,6 +201,8 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
       if (grub_errno == GRUB_ERR_UNKNOWN_FS)
 	grub_errno = GRUB_ERR_NONE;
 
+      grub_device_close (dev);
+      dev = NULL;
       grub_normal_print_device_info (device_name);
     }
   else if (fs)
-- 
1.7.1



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

* Re: [PATCH] ls: prevent double open
  2017-10-16 20:11 [PATCH] ls: prevent double open Eric Snowberg
@ 2017-10-17 13:22 ` Daniel Kiper
  2017-10-18 16:30   ` Eric Snowberg
  2017-10-18 16:32 ` Vladimir 'phcoder' Serbinenko
  1 sibling, 1 reply; 11+ messages in thread
From: Daniel Kiper @ 2017-10-17 13:22 UTC (permalink / raw)
  To: Eric Snowberg; +Cc: grub-devel, phcoder

On Mon, Oct 16, 2017 at 01:11:12PM -0700, Eric Snowberg wrote:
> Prevent a double open.  This can cause problems with some ieee1275
> devices, causing the system to hang.  The double open can occur
> as follows:
>
> grub_ls_list_files (char *dirname, int longlist, int all, int human)
>        dev = grub_device_open (device_name);
>        dev remains open while:
>        grub_normal_print_device_info (device_name);
>                 dev = grub_device_open (name);
>
> Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>

In general LGTM. One nitpick...

> ---
>  grub-core/commands/ls.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c
> index 0eaf836..a7318ab 100644
> --- a/grub-core/commands/ls.c
> +++ b/grub-core/commands/ls.c
> @@ -201,6 +201,8 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
>        if (grub_errno == GRUB_ERR_UNKNOWN_FS)
>  	grub_errno = GRUB_ERR_NONE;
>
> +      grub_device_close (dev);
> +      dev = NULL;

I would put a comment before why it is needed.

Thanks,

Daniel


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

* Re: [PATCH] ls: prevent double open
  2017-10-17 13:22 ` Daniel Kiper
@ 2017-10-18 16:30   ` Eric Snowberg
  2017-11-10 21:35     ` Daniel Kiper
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Snowberg @ 2017-10-18 16:30 UTC (permalink / raw)
  To: The development of GNU GRUB
  Cc: Vladimir 'phcoder' Serbinenko, Daniel Kiper


> On Oct 17, 2017, at 7:22 AM, Daniel Kiper <daniel.kiper@oracle.com> wrote:
> 
> On Mon, Oct 16, 2017 at 01:11:12PM -0700, Eric Snowberg wrote:
>> Prevent a double open.  This can cause problems with some ieee1275
>> devices, causing the system to hang.  The double open can occur
>> as follows:
>> 
>> grub_ls_list_files (char *dirname, int longlist, int all, int human)
>>       dev = grub_device_open (device_name);
>>       dev remains open while:
>>       grub_normal_print_device_info (device_name);
>>                dev = grub_device_open (name);
>> 
>> Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
> 
> In general LGTM. One nitpick...
> 
>> ---
>> grub-core/commands/ls.c |    2 ++
>> 1 files changed, 2 insertions(+), 0 deletions(-)
>> 
>> diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c
>> index 0eaf836..a7318ab 100644
>> --- a/grub-core/commands/ls.c
>> +++ b/grub-core/commands/ls.c
>> @@ -201,6 +201,8 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
>>       if (grub_errno == GRUB_ERR_UNKNOWN_FS)
>> 	grub_errno = GRUB_ERR_NONE;
>> 
>> +      grub_device_close (dev);
>> +      dev = NULL;
> 
> I would put a comment before why it is needed.
> 

Ok, I’ll add a comment and submit a V2.



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

* Re: [PATCH] ls: prevent double open
  2017-10-16 20:11 [PATCH] ls: prevent double open Eric Snowberg
  2017-10-17 13:22 ` Daniel Kiper
@ 2017-10-18 16:32 ` Vladimir 'phcoder' Serbinenko
  2017-10-18 17:02   ` Eric Snowberg
  1 sibling, 1 reply; 11+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-10-18 16:32 UTC (permalink / raw)
  To: Eric Snowberg; +Cc: daniel.kiper, grub-devel

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

On Mon, Oct 16, 2017, 22:11 Eric Snowberg <eric.snowberg@oracle.com> wrote:

> Prevent a double open.  This can cause problems with some ieee1275
> devices, causing the system to hang.  The double open can occur
> as follows:
>
Why does it? Underlying firmware device should not be aware of how many
times grub device is open. If it is and it causes bugs, then it's a bug in
device driver

>
> grub_ls_list_files (char *dirname, int longlist, int all, int human)
>        dev = grub_device_open (device_name);
>        dev remains open while:
>        grub_normal_print_device_info (device_name);
>                 dev = grub_device_open (name);
>
> Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
> ---
>  grub-core/commands/ls.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c
> index 0eaf836..a7318ab 100644
> --- a/grub-core/commands/ls.c
> +++ b/grub-core/commands/ls.c
> @@ -201,6 +201,8 @@ grub_ls_list_files (char *dirname, int longlist, int
> all, int human)
>        if (grub_errno == GRUB_ERR_UNKNOWN_FS)
>         grub_errno = GRUB_ERR_NONE;
>
> +      grub_device_close (dev);
> +      dev = NULL;
>        grub_normal_print_device_info (device_name);
>      }
>    else if (fs)
> --
> 1.7.1
>
>

[-- Attachment #2: Type: text/html, Size: 1897 bytes --]

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

* Re: [PATCH] ls: prevent double open
  2017-10-18 16:32 ` Vladimir 'phcoder' Serbinenko
@ 2017-10-18 17:02   ` Eric Snowberg
  2017-10-18 17:03     ` Vladimir 'phcoder' Serbinenko
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Snowberg @ 2017-10-18 17:02 UTC (permalink / raw)
  To: The development of GNU GRUB
  Cc: Daniel Kiper, Vladimir 'phcoder' Serbinenko


> On Oct 18, 2017, at 10:32 AM, Vladimir 'phcoder' Serbinenko <phcoder@gmail.com> wrote:
> 
> 
> 
> On Mon, Oct 16, 2017, 22:11 Eric Snowberg <eric.snowberg@oracle.com> wrote:
> Prevent a double open.  This can cause problems with some ieee1275
> devices, causing the system to hang.  The double open can occur
> as follows:
> Why does it? Underlying firmware device should not be aware of how many times grub device is open. If it is and it causes bugs, then it's a bug in device driver

Which device driver are you referring to?  The one in GRUB or Open Firmware?




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

* Re: [PATCH] ls: prevent double open
  2017-10-18 17:02   ` Eric Snowberg
@ 2017-10-18 17:03     ` Vladimir 'phcoder' Serbinenko
  2017-10-18 21:01       ` Eric Snowberg
  0 siblings, 1 reply; 11+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-10-18 17:03 UTC (permalink / raw)
  To: Eric Snowberg; +Cc: Daniel Kiper, The development of GNU GRUB

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

On Wed, Oct 18, 2017, 19:02 Eric Snowberg <eric.snowberg@oracle.com> wrote:

>
> > On Oct 18, 2017, at 10:32 AM, Vladimir 'phcoder' Serbinenko <
> phcoder@gmail.com> wrote:
> >
> >
> >
> > On Mon, Oct 16, 2017, 22:11 Eric Snowberg <eric.snowberg@oracle.com>
> wrote:
> > Prevent a double open.  This can cause problems with some ieee1275
> > devices, causing the system to hang.  The double open can occur
> > as follows:
> > Why does it? Underlying firmware device should not be aware of how many
> times grub device is open. If it is and it causes bugs, then it's a bug in
> device driver
>
> Which device driver are you referring to?  The one in GRUB or Open
> Firmware?
>
In GRUB

>
>
>

[-- Attachment #2: Type: text/html, Size: 1279 bytes --]

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

* Re: [PATCH] ls: prevent double open
  2017-10-18 17:03     ` Vladimir 'phcoder' Serbinenko
@ 2017-10-18 21:01       ` Eric Snowberg
  2017-11-07 21:17         ` John Paul Adrian Glaubitz
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Snowberg @ 2017-10-18 21:01 UTC (permalink / raw)
  To: The development of GNU GRUB
  Cc: Daniel Kiper, Vladimir 'phcoder' Serbinenko


> On Oct 18, 2017, at 11:03 AM, Vladimir 'phcoder' Serbinenko <phcoder@gmail.com> wrote:
> 
> 
> 
> On Wed, Oct 18, 2017, 19:02 Eric Snowberg <eric.snowberg@oracle.com> wrote:
> 
> > On Oct 18, 2017, at 10:32 AM, Vladimir 'phcoder' Serbinenko <phcoder@gmail.com> wrote:
> >
> >
> >
> > On Mon, Oct 16, 2017, 22:11 Eric Snowberg <eric.snowberg@oracle.com> wrote:
> > Prevent a double open.  This can cause problems with some ieee1275
> > devices, causing the system to hang.  The double open can occur
> > as follows:
> > Why does it? Underlying firmware device should not be aware of how many times grub device is open. If it is and it causes bugs, then it's a bug in device driver
> 
> Which device driver are you referring to?  The one in GRUB or Open Firmware?
> In GRUB
> 
> 


I would agree with that.  There are many problems with the ofdisk driver in GRUB. One being the memory corruption issues that prevents new code from being added to it, which is what I believe you are recommending. I submitted a fix for the memory corruption problems years ago, but the patch was ignored.

memory corruption example:

devpath created in grub_ofdisk_open
  it then calls ofdisk_hash_add with devpath
    it then calls ofdisk_hash_add_real with devpath
      ofdisk_hash_add_real saves pointer of devpath
    return
  return
free devpath

dangling pointer/memory corruption with what is stored in ofdisk_hash_add_real, any new memory allocation corrupts devpath

As I recall, just trying to add a grub_printf in the wrong place can corrupt the devpath. I never understood why this bug was too risky to fix for 2.02 or why it still exists today. 

I ended up writing a new driver which we use instead.

https://github.com/esnowberg/grub2-sparc/commit/d802909bc614980dcf6dc2f4484bfa8c2448adf1

This driver would take care of this double open problem making this patch unnecessary. It will also solve many other problems that currently exist in ofdisk. If you would consider this driver in upstream, let me know and I’ll start submitting it.




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

* Re: [PATCH] ls: prevent double open
  2017-10-18 21:01       ` Eric Snowberg
@ 2017-11-07 21:17         ` John Paul Adrian Glaubitz
  2017-11-07 21:26           ` Daniel Kiper
  0 siblings, 1 reply; 11+ messages in thread
From: John Paul Adrian Glaubitz @ 2017-11-07 21:17 UTC (permalink / raw)
  To: The development of GNU GRUB, Eric Snowberg
  Cc: Vladimir 'phcoder' Serbinenko, Daniel Kiper

Hi Daniel and Eric!

Is there any progress on these patches?

May I suggest that we continue with the remaining SPARC patches first if
there is still disagreement on the patches that have been posted so far?

I fear that this will fall into oblivion again and we continue to be stuck
with SILO :(.

Please be assured that the Debian sparc64 porters are very happy to help
with any issues that might arise with the patches, be it in the form of
testing or helping to fix potential bugs.

Your work is highly appreciated and much anticipated :).

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


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

* Re: [PATCH] ls: prevent double open
  2017-11-07 21:17         ` John Paul Adrian Glaubitz
@ 2017-11-07 21:26           ` Daniel Kiper
  0 siblings, 0 replies; 11+ messages in thread
From: Daniel Kiper @ 2017-11-07 21:26 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz
  Cc: The development of GNU GRUB, Eric Snowberg,
	Vladimir 'phcoder' Serbinenko

On Tue, Nov 07, 2017 at 10:17:34PM +0100, John Paul Adrian Glaubitz wrote:
> Hi Daniel and Eric!
>
> Is there any progress on these patches?

Vladimir had some concerns. Sadly he was ill last week and I was going to
ping him this one. Vladimir? If he does not voice his opinion I will apply
this patch by the end of this week.

> May I suggest that we continue with the remaining SPARC patches first if
> there is still disagreement on the patches that have been posted so far?

I am OK with that.

> I fear that this will fall into oblivion again and we continue to be stuck
> with SILO :(.

Unfortunately I am swamped by two internal very pesky bugs and traveling
next week. So, if it is possible to post new patches in the second half
of November I will be very grateful.

> Please be assured that the Debian sparc64 porters are very happy to help
> with any issues that might arise with the patches, be it in the form of
> testing or helping to fix potential bugs.

Great!

> Your work is highly appreciated and much anticipated :).

Thanks!

Daniel


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

* Re: [PATCH] ls: prevent double open
  2017-10-18 16:30   ` Eric Snowberg
@ 2017-11-10 21:35     ` Daniel Kiper
  2017-11-13 16:11       ` John Paul Adrian Glaubitz
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel Kiper @ 2017-11-10 21:35 UTC (permalink / raw)
  To: Eric Snowberg
  Cc: The development of GNU GRUB, Vladimir 'phcoder' Serbinenko

On Wed, Oct 18, 2017 at 10:30:37AM -0600, Eric Snowberg wrote:
> > On Oct 17, 2017, at 7:22 AM, Daniel Kiper <daniel.kiper@oracle.com> wrote:
> > On Mon, Oct 16, 2017 at 01:11:12PM -0700, Eric Snowberg wrote:
> >> Prevent a double open.  This can cause problems with some ieee1275
> >> devices, causing the system to hang.  The double open can occur
> >> as follows:
> >>
> >> grub_ls_list_files (char *dirname, int longlist, int all, int human)
> >>       dev = grub_device_open (device_name);
> >>       dev remains open while:
> >>       grub_normal_print_device_info (device_name);
> >>                dev = grub_device_open (name);
> >>
> >> Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
> >
> > In general LGTM. One nitpick...
> >
> >> ---
> >> grub-core/commands/ls.c |    2 ++
> >> 1 files changed, 2 insertions(+), 0 deletions(-)
> >>
> >> diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c
> >> index 0eaf836..a7318ab 100644
> >> --- a/grub-core/commands/ls.c
> >> +++ b/grub-core/commands/ls.c
> >> @@ -201,6 +201,8 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
> >>       if (grub_errno == GRUB_ERR_UNKNOWN_FS)
> >> 	grub_errno = GRUB_ERR_NONE;
> >>
> >> +      grub_device_close (dev);
> >> +      dev = NULL;
> >
> > I would put a comment before why it is needed.
> >
>
> Ok, I’ll add a comment and submit a V2.

I was going to apply this today but have not found v2... :-(((
If you post it I will apply it immediately.

Daniel


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

* Re: [PATCH] ls: prevent double open
  2017-11-10 21:35     ` Daniel Kiper
@ 2017-11-13 16:11       ` John Paul Adrian Glaubitz
  0 siblings, 0 replies; 11+ messages in thread
From: John Paul Adrian Glaubitz @ 2017-11-13 16:11 UTC (permalink / raw)
  To: The development of GNU GRUB, Daniel Kiper, Eric Snowberg
  Cc: Vladimir 'phcoder' Serbinenko

On 11/10/2017 10:35 PM, Daniel Kiper wrote:
>> Ok, I’ll add a comment and submit a V2.
> 
> I was going to apply this today but have not found v2... :-(((
> If you post it I will apply it immediately.

I think Eric didn't send a V2 patch yet. But since the only difference
would be adding an additional explanatory comment, why not apply his
patch and then add the comment in another commit?

Or just apply his patch, add a comment and then commit it?

@Eric: What's your opinion?

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


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

end of thread, other threads:[~2017-11-13 16:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-16 20:11 [PATCH] ls: prevent double open Eric Snowberg
2017-10-17 13:22 ` Daniel Kiper
2017-10-18 16:30   ` Eric Snowberg
2017-11-10 21:35     ` Daniel Kiper
2017-11-13 16:11       ` John Paul Adrian Glaubitz
2017-10-18 16:32 ` Vladimir 'phcoder' Serbinenko
2017-10-18 17:02   ` Eric Snowberg
2017-10-18 17:03     ` Vladimir 'phcoder' Serbinenko
2017-10-18 21:01       ` Eric Snowberg
2017-11-07 21:17         ` John Paul Adrian Glaubitz
2017-11-07 21:26           ` Daniel Kiper

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.