All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Peilin Ye <yepeilin.cs@gmail.com>
Cc: syzkaller-bugs@googlegroups.com,
	linux-kernel-mentees@lists.linuxfoundation.org,
	linux-kernel@vger.kernel.org, Jan Kara <jack@suse.com>
Subject: Re: [Linux-kernel-mentees] [PATCH] udf: Fix memory leak in udf_process_sequence()
Date: Wed, 23 Sep 2020 12:04:05 +0200	[thread overview]
Message-ID: <20200923100405.GD6719@quack2.suse.cz> (raw)
In-Reply-To: <20200922154531.153922-1-yepeilin.cs@gmail.com>

On Tue 22-09-20 11:45:31, Peilin Ye wrote:
> udf_process_sequence() is leaking memory. Free `data.part_descs_loc`
> before returning.
> 
> Cc: stable@vger.kernel.org
> Fixes: 7b78fd02fb19 ("udf: Fix handling of Partition Descriptors")
> Reported-and-tested-by: syzbot+128f4dd6e796c98b3760@syzkaller.appspotmail.com
> Link: https://syzkaller.appspot.com/bug?id=c5ec4e6f5d818f3c4afd4d59342468eec08a38da
> Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>

Thanks for the patch but I've just yesterday written exactly the same patch
and merged it to my tree...

								Honza

> ---
>  fs/udf/super.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index 1c42f544096d..b0d862ab3024 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -1698,7 +1698,8 @@ static noinline int udf_process_sequence(
>  					"Pointers (max %u supported)\n",
>  					UDF_MAX_TD_NESTING);
>  				brelse(bh);
> -				return -EIO;
> +				ret = -EIO;
> +				goto out;
>  			}
>  
>  			vdp = (struct volDescPtr *)bh->b_data;
> @@ -1718,7 +1719,8 @@ static noinline int udf_process_sequence(
>  			curr = get_volume_descriptor_record(ident, bh, &data);
>  			if (IS_ERR(curr)) {
>  				brelse(bh);
> -				return PTR_ERR(curr);
> +				ret = PTR_ERR(curr);
> +				goto out;
>  			}
>  			/* Descriptor we don't care about? */
>  			if (!curr)
> @@ -1740,28 +1742,32 @@ static noinline int udf_process_sequence(
>  	 */
>  	if (!data.vds[VDS_POS_PRIMARY_VOL_DESC].block) {
>  		udf_err(sb, "Primary Volume Descriptor not found!\n");
> -		return -EAGAIN;
> +		ret = -EAGAIN;
> +		goto out;
>  	}
>  	ret = udf_load_pvoldesc(sb, data.vds[VDS_POS_PRIMARY_VOL_DESC].block);
>  	if (ret < 0)
> -		return ret;
> +		goto out;
>  
>  	if (data.vds[VDS_POS_LOGICAL_VOL_DESC].block) {
>  		ret = udf_load_logicalvol(sb,
>  				data.vds[VDS_POS_LOGICAL_VOL_DESC].block,
>  				fileset);
>  		if (ret < 0)
> -			return ret;
> +			goto out;
>  	}
>  
>  	/* Now handle prevailing Partition Descriptors */
>  	for (i = 0; i < data.num_part_descs; i++) {
>  		ret = udf_load_partdesc(sb, data.part_descs_loc[i].rec.block);
>  		if (ret < 0)
> -			return ret;
> +			goto out;
>  	}
>  
> -	return 0;
> +	ret = 0;
> +out:
> +	kfree(data.part_descs_loc);
> +	return ret;
>  }
>  
>  /*
> -- 
> 2.25.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

WARNING: multiple messages have this Message-ID (diff)
From: Jan Kara <jack@suse.cz>
To: Peilin Ye <yepeilin.cs@gmail.com>
Cc: Jan Kara <jack@suse.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel-mentees@lists.linuxfoundation.org,
	syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org
Subject: Re: [Linux-kernel-mentees] [PATCH] udf: Fix memory leak in udf_process_sequence()
Date: Wed, 23 Sep 2020 12:04:05 +0200	[thread overview]
Message-ID: <20200923100405.GD6719@quack2.suse.cz> (raw)
In-Reply-To: <20200922154531.153922-1-yepeilin.cs@gmail.com>

On Tue 22-09-20 11:45:31, Peilin Ye wrote:
> udf_process_sequence() is leaking memory. Free `data.part_descs_loc`
> before returning.
> 
> Cc: stable@vger.kernel.org
> Fixes: 7b78fd02fb19 ("udf: Fix handling of Partition Descriptors")
> Reported-and-tested-by: syzbot+128f4dd6e796c98b3760@syzkaller.appspotmail.com
> Link: https://syzkaller.appspot.com/bug?id=c5ec4e6f5d818f3c4afd4d59342468eec08a38da
> Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>

Thanks for the patch but I've just yesterday written exactly the same patch
and merged it to my tree...

								Honza

> ---
>  fs/udf/super.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index 1c42f544096d..b0d862ab3024 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -1698,7 +1698,8 @@ static noinline int udf_process_sequence(
>  					"Pointers (max %u supported)\n",
>  					UDF_MAX_TD_NESTING);
>  				brelse(bh);
> -				return -EIO;
> +				ret = -EIO;
> +				goto out;
>  			}
>  
>  			vdp = (struct volDescPtr *)bh->b_data;
> @@ -1718,7 +1719,8 @@ static noinline int udf_process_sequence(
>  			curr = get_volume_descriptor_record(ident, bh, &data);
>  			if (IS_ERR(curr)) {
>  				brelse(bh);
> -				return PTR_ERR(curr);
> +				ret = PTR_ERR(curr);
> +				goto out;
>  			}
>  			/* Descriptor we don't care about? */
>  			if (!curr)
> @@ -1740,28 +1742,32 @@ static noinline int udf_process_sequence(
>  	 */
>  	if (!data.vds[VDS_POS_PRIMARY_VOL_DESC].block) {
>  		udf_err(sb, "Primary Volume Descriptor not found!\n");
> -		return -EAGAIN;
> +		ret = -EAGAIN;
> +		goto out;
>  	}
>  	ret = udf_load_pvoldesc(sb, data.vds[VDS_POS_PRIMARY_VOL_DESC].block);
>  	if (ret < 0)
> -		return ret;
> +		goto out;
>  
>  	if (data.vds[VDS_POS_LOGICAL_VOL_DESC].block) {
>  		ret = udf_load_logicalvol(sb,
>  				data.vds[VDS_POS_LOGICAL_VOL_DESC].block,
>  				fileset);
>  		if (ret < 0)
> -			return ret;
> +			goto out;
>  	}
>  
>  	/* Now handle prevailing Partition Descriptors */
>  	for (i = 0; i < data.num_part_descs; i++) {
>  		ret = udf_load_partdesc(sb, data.part_descs_loc[i].rec.block);
>  		if (ret < 0)
> -			return ret;
> +			goto out;
>  	}
>  
> -	return 0;
> +	ret = 0;
> +out:
> +	kfree(data.part_descs_loc);
> +	return ret;
>  }
>  
>  /*
> -- 
> 2.25.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2020-09-23 10:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-21 10:02 memory leak in udf_process_sequence syzbot
2020-09-22 15:45 ` [Linux-kernel-mentees] [PATCH] udf: Fix memory leak in udf_process_sequence() Peilin Ye
2020-09-22 15:45   ` Peilin Ye
2020-09-23 10:04   ` Jan Kara [this message]
2020-09-23 10:04     ` Jan Kara
2020-09-23 10:29     ` Peilin Ye
2020-09-23 10:29       ` Peilin Ye

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200923100405.GD6719@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=jack@suse.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=yepeilin.cs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.