mount: cgroup -- Fix nil dereference

Submitted by Cyrill Gorcunov on Sept. 13, 2016, 12:26 p.m.

Details

Message ID 1473769569-25195-1-git-send-email-gorcunov@openvz.org
State Rejected
Series "mount: cgroup -- Fix nil dereference"
Headers show

Commit Message

Cyrill Gorcunov Sept. 13, 2016, 12:26 p.m.
In case if there is no CLONE_NEWCGROUP on root
namespace mask the @private member remains nil
and comparision in mounts_sb_equal leads to nil
dereference.

CC: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 criu/mount.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/mount.c b/criu/mount.c
index fe120a17ca69..ca757562da96 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -296,7 +296,9 @@  static bool mounts_sb_equal(struct mount_info *a, struct mount_info *b)
 			return false;
 	}
 
-	if (a->fstype->code == FSTYPE__CGROUP && strcmp(a->private, b->private))
+	if (a->fstype->code == FSTYPE__CGROUP &&
+	    a->private && b->private &&
+	    strcmp(a->private, b->private))
 		return false;
 
 	return a->s_dev == b->s_dev && !strcmp(a->source, b->source);

Comments

Tycho Andersen Sept. 13, 2016, 2:58 p.m.
On Tue, Sep 13, 2016 at 03:26:09PM +0300, Cyrill Gorcunov wrote:
> In case if there is no CLONE_NEWCGROUP on root
> namespace mask the @private member remains nil
> and comparision in mounts_sb_equal leads to nil
> dereference.
> 
> CC: Tycho Andersen <tycho.andersen@canonical.com>

Acked-by: Tycho Andersen <tycho.andersen@canonical.com>

Whoops, thanks :)

> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> ---
>  criu/mount.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/criu/mount.c b/criu/mount.c
> index fe120a17ca69..ca757562da96 100644
> --- a/criu/mount.c
> +++ b/criu/mount.c
> @@ -296,7 +296,9 @@ static bool mounts_sb_equal(struct mount_info *a, struct mount_info *b)
>  			return false;
>  	}
>  
> -	if (a->fstype->code == FSTYPE__CGROUP && strcmp(a->private, b->private))
> +	if (a->fstype->code == FSTYPE__CGROUP &&
> +	    a->private && b->private &&
> +	    strcmp(a->private, b->private))
>  		return false;
>  
>  	return a->s_dev == b->s_dev && !strcmp(a->source, b->source);
> -- 
> 2.7.4
>
Pavel Emelianov Sept. 16, 2016, 5:12 p.m.
Applied, thanks