diff mbox

[Vivid,SRU] init: fix regression by supporting devices with major:minor:offset format

Message ID 8082FF9BCB2B054996454E47167FF4EC0290DC5C@SHSMSX104.ccr.corp.intel.com
State New
Headers show

Commit Message

Xiong Zhang May 11, 2015, 7:11 a.m. UTC
The system will reboot after resuming from S4 on 15.04.
The following commit fixes this broken.

commit cb31ef485dd4c6a205d1064b42027f82076d00c8
Author: Chen Yu <yu.c.chen@intel.com>
Date:   Sun May 3 22:35:05 2015 +0800

    init: fix regression by supporting devices with major:minor:offset format

    Commit 283e7ad02 ("init: stricter checking of major:minor root=
    values") was so strict that it exposed the fact that a previously
    unknown device format was being used.

    Distributions like Ubuntu uses klibc (rather than uswsusp) to resume
    system from hibernation.  klibc expressed the swap partition/file in
    the form of major:minor:offset.  For example, 8:3:0 represents a swap
    partition in klibc, and klibc's resume process in initrd will finally
    echo 8:3:0 to /sys/power/resume for manually resuming.  However, due
    to commit 283e7ad02's stricter checking, 8:3:0 will be treated as an
    invalid device format, and manual resuming from hibernation will fail.

    Fix this by adding support for devices with major:minor:offset format
    when resuming from hibernation.

    Reported-by: Prigent, Christophe <christophe.prigent@intel.com>
    Signed-off-by: Chen Yu <yu.c.chen@intel.com>
    Acked-by: Rafael J. Wysocki <rjw@rjwysocki.net>
    Signed-off-by: Mike Snitzer <snitzer@redhat.com>

(END)

Comments

Stefan Bader May 11, 2015, 4:10 p.m. UTC | #1
On 11.05.2015 09:11, Zhang, Xiong Y wrote:
> The system will reboot after resuming from S4 on 15.04.
> The following commit fixes this broken.

Is there a LP bug for this?

>  
> commit cb31ef485dd4c6a205d1064b42027f82076d00c8
> Author: Chen Yu <yu.c.chen@intel.com>
> Date:   Sun May 3 22:35:05 2015 +0800
>  
>     init: fix regression by supporting devices with major:minor:offset format
>  
>     Commit 283e7ad02 ("init: stricter checking of major:minor root=
>     values") was so strict that it exposed the fact that a previously
>     unknown device format was being used.
>  
>     Distributions like Ubuntu uses klibc (rather than uswsusp) to resume
>     system from hibernation.  klibc expressed the swap partition/file in
>     the form of major:minor:offset.  For example, 8:3:0 represents a swap
>     partition in klibc, and klibc's resume process in initrd will finally
>     echo 8:3:0 to /sys/power/resume for manually resuming.  However, due
>     to commit 283e7ad02's stricter checking, 8:3:0 will be treated as an
>     invalid device format, and manual resuming from hibernation will fail.
>  
>     Fix this by adding support for devices with major:minor:offset format
>     when resuming from hibernation.
>  
>     Reported-by: Prigent, Christophe <christophe.prigent@intel.com>
>     Signed-off-by: Chen Yu <yu.c.chen@intel.com>
>     Acked-by: Rafael J. Wysocki <rjw@rjwysocki.net>
>     Signed-off-by: Mike Snitzer <snitzer@redhat.com>
>  
> diff --git a/init/do_mounts.c b/init/do_mounts.c
> index 8369ffa..a95bbdb 100644
> --- a/init/do_mounts.c
> +++ b/init/do_mounts.c
> @@ -225,10 +225,11 @@ dev_t name_to_dev_t(const char *name)
> #endif
>  
>         if (strncmp(name, "/dev/", 5) != 0) {
> -               unsigned maj, min;
> +               unsigned maj, min, offset;
>                 char dummy;
>  
> -               if (sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) {
> +               if ((sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) ||
> +                   (sscanf(name, "%u:%u:%u:%c", &maj, &min, &offset, &dummy) ==
> 3)) {
>                         res = MKDEV(maj, min);
>                         if (maj != MAJOR(res) || min != MINOR(res))
>                                 goto fail;
> (END)
>  
> 
>
Stefan Bader May 11, 2015, 4:21 p.m. UTC | #2
On 11.05.2015 09:11, Zhang, Xiong Y wrote:
> The system will reboot after resuming from S4 on 15.04.
> The following commit fixes this broken.

Asking about a LP bug was probably stupid. Probably rather something that might
be stable. Just confused as the commit that was claimed to introduce the
regression seems to be 4.1. Why would that be required for Vivid?

-Stefan

>  
> commit cb31ef485dd4c6a205d1064b42027f82076d00c8
> Author: Chen Yu <yu.c.chen@intel.com>
> Date:   Sun May 3 22:35:05 2015 +0800
>  
>     init: fix regression by supporting devices with major:minor:offset format
>  
>     Commit 283e7ad02 ("init: stricter checking of major:minor root=
>     values") was so strict that it exposed the fact that a previously
>     unknown device format was being used.
>  
>     Distributions like Ubuntu uses klibc (rather than uswsusp) to resume
>     system from hibernation.  klibc expressed the swap partition/file in
>     the form of major:minor:offset.  For example, 8:3:0 represents a swap
>     partition in klibc, and klibc's resume process in initrd will finally
>     echo 8:3:0 to /sys/power/resume for manually resuming.  However, due
>     to commit 283e7ad02's stricter checking, 8:3:0 will be treated as an
>     invalid device format, and manual resuming from hibernation will fail.
>  
>     Fix this by adding support for devices with major:minor:offset format
>     when resuming from hibernation.
>  
>     Reported-by: Prigent, Christophe <christophe.prigent@intel.com>
>     Signed-off-by: Chen Yu <yu.c.chen@intel.com>
>     Acked-by: Rafael J. Wysocki <rjw@rjwysocki.net>
>     Signed-off-by: Mike Snitzer <snitzer@redhat.com>
>  
> diff --git a/init/do_mounts.c b/init/do_mounts.c
> index 8369ffa..a95bbdb 100644
> --- a/init/do_mounts.c
> +++ b/init/do_mounts.c
> @@ -225,10 +225,11 @@ dev_t name_to_dev_t(const char *name)
> #endif
>  
>         if (strncmp(name, "/dev/", 5) != 0) {
> -               unsigned maj, min;
> +               unsigned maj, min, offset;
>                 char dummy;
>  
> -               if (sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) {
> +               if ((sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) ||
> +                   (sscanf(name, "%u:%u:%u:%c", &maj, &min, &offset, &dummy) ==
> 3)) {
>                         res = MKDEV(maj, min);
>                         if (maj != MAJOR(res) || min != MINOR(res))
>                                 goto fail;
> (END)
>  
> 
>
Andy Whitcroft May 11, 2015, 6:54 p.m. UTC | #3
On Mon, May 11, 2015 at 07:11:24AM +0000, Zhang, Xiong Y wrote:
> The system will reboot after resuming from S4 on 15.04.
> The following commit fixes this broken.
> 
> commit cb31ef485dd4c6a205d1064b42027f82076d00c8
> Author: Chen Yu <yu.c.chen@intel.com>
> Date:   Sun May 3 22:35:05 2015 +0800
> 
>     init: fix regression by supporting devices with major:minor:offset format
> 
>     Commit 283e7ad02 ("init: stricter checking of major:minor root=
>     values") was so strict that it exposed the fact that a previously
>     unknown device format was being used.
> 
>     Distributions like Ubuntu uses klibc (rather than uswsusp) to resume
>     system from hibernation.  klibc expressed the swap partition/file in
>     the form of major:minor:offset.  For example, 8:3:0 represents a swap
>     partition in klibc, and klibc's resume process in initrd will finally
>     echo 8:3:0 to /sys/power/resume for manually resuming.  However, due
>     to commit 283e7ad02's stricter checking, 8:3:0 will be treated as an
>     invalid device format, and manual resuming from hibernation will fail.
> 
>     Fix this by adding support for devices with major:minor:offset format
>     when resuming from hibernation.
> 
>     Reported-by: Prigent, Christophe <christophe.prigent@intel.com>
>     Signed-off-by: Chen Yu <yu.c.chen@intel.com>
>     Acked-by: Rafael J. Wysocki <rjw@rjwysocki.net>
>     Signed-off-by: Mike Snitzer <snitzer@redhat.com>
> 
> diff --git a/init/do_mounts.c b/init/do_mounts.c
> index 8369ffa..a95bbdb 100644
> --- a/init/do_mounts.c
> +++ b/init/do_mounts.c
> @@ -225,10 +225,11 @@ dev_t name_to_dev_t(const char *name)
>  #endif
> 
>         if (strncmp(name, "/dev/", 5) != 0) {
> -               unsigned maj, min;
> +               unsigned maj, min, offset;
>                 char dummy;
> 
> -               if (sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) {
> +               if ((sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) ||
> +                   (sscanf(name, "%u:%u:%u:%c", &maj, &min, &offset, &dummy) == 3)) {
>                         res = MKDEV(maj, min);
>                         if (maj != MAJOR(res) || min != MINOR(res))
>                                 goto fail;

Does this _actually_ do what is claimed?  it actually appears to add
support for 8:3:0: as a format?

-apw
diff mbox

Patch

diff --git a/init/do_mounts.c b/init/do_mounts.c
index 8369ffa..a95bbdb 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -225,10 +225,11 @@  dev_t name_to_dev_t(const char *name)
 #endif

        if (strncmp(name, "/dev/", 5) != 0) {
-               unsigned maj, min;
+               unsigned maj, min, offset;
                char dummy;

-               if (sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) {
+               if ((sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) ||
+                   (sscanf(name, "%u:%u:%u:%c", &maj, &min, &offset, &dummy) == 3)) {
                        res = MKDEV(maj, min);
                        if (maj != MAJOR(res) || min != MINOR(res))
                                goto fail;