mount: fix segmentation fault in can_mount_now on no mnt_master

Submitted by Pavel Tikhomirov on July 24, 2018, 9:55 a.m.

Details

Message ID 20180724095502.11364-1-ptikhomirov@virtuozzo.com
State Accepted
Series "mount: fix segmentation fault in can_mount_now on no mnt_master"
Headers show

Commit Message

Pavel Tikhomirov July 24, 2018, 9:55 a.m.
In resolve_shared_mounts there are cases when we have m->master_id > 0
but m->mnt_master is not set, it happens for cases where we have no
access to master mount, for instance CT root m->parent==NULL or when
mount is external. In can_mount_now  for such master mounts we don't
need to check mounted state also, so just use "if(mi->mnt_master)"
condition instead of "if(mi->master_id > 0)" to fix segfault.

https://jira.sw.ru/browse/PSBM-86978

Program terminated with signal 11, Segmentation fault.
0x000000000046328b in can_mount_now (mi=0x2155970) at criu/mount.c:2699
2699	list_for_each_entry(c, &mi->mnt_master->children, siblings)

(gdb) p mi->mnt_master
$2 = (struct mount_info	*) 0x0

Fixes commit 3a02362c5be1 ("mount: fix can_mount_now to wait children of
master's share properly")

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
 criu/mount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/mount.c b/criu/mount.c
index 9cc8f6e94..d2292cd8e 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -2355,7 +2355,7 @@  static bool can_mount_now(struct mount_info *mi)
 	 *   - Make sure all children of master's share are
 	 *   mounted as well to eliminate mounts duplications
 	 */
-	if (mi->master_id > 0) {
+	if (mi->mnt_master) {
 		struct mount_info *c, *s;
 
 		if (mi->bind == NULL)

Comments

Andrey Vagin July 24, 2018, 10:20 p.m.
Applied, thanks.

On Tue, Jul 24, 2018 at 12:55:02PM +0300, Pavel Tikhomirov wrote:
> In resolve_shared_mounts there are cases when we have m->master_id > 0
> but m->mnt_master is not set, it happens for cases where we have no
> access to master mount, for instance CT root m->parent==NULL or when
> mount is external. In can_mount_now  for such master mounts we don't
> need to check mounted state also, so just use "if(mi->mnt_master)"
> condition instead of "if(mi->master_id > 0)" to fix segfault.
> 
> https://jira.sw.ru/browse/PSBM-86978
> 
> Program terminated with signal 11, Segmentation fault.
> 0x000000000046328b in can_mount_now (mi=0x2155970) at criu/mount.c:2699
> 2699	list_for_each_entry(c, &mi->mnt_master->children, siblings)
> 
> (gdb) p mi->mnt_master
> $2 = (struct mount_info	*) 0x0
> 
> Fixes commit 3a02362c5be1 ("mount: fix can_mount_now to wait children of
> master's share properly")
> 
> Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
> ---
>  criu/mount.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/criu/mount.c b/criu/mount.c
> index 9cc8f6e94..d2292cd8e 100644
> --- a/criu/mount.c
> +++ b/criu/mount.c
> @@ -2355,7 +2355,7 @@ static bool can_mount_now(struct mount_info *mi)
>  	 *   - Make sure all children of master's share are
>  	 *   mounted as well to eliminate mounts duplications
>  	 */
> -	if (mi->master_id > 0) {
> +	if (mi->mnt_master) {
>  		struct mount_info *c, *s;
>  
>  		if (mi->bind == NULL)
> -- 
> 2.17.1
>