linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] udf: NULL dereference at udf_symlink() on error
@ 2015-03-23  6:11 Changwoo Min
  2015-04-01 10:55 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Changwoo Min @ 2015-03-23  6:11 UTC (permalink / raw)
  To: jack, linux-kernel
  Cc: taesoo, changwoo, sanidhya, blee, csong84, Changwoo Min

There is no check for udf_tgetblk(), which could return NULL, in udf_symlink(). 
So there is a possibility of returning NULL under heavy memory pressure and 
possibility of NULL dereference. 

Signed-off-by: Changwoo Min <changwoo.m@gmail.com>
---
 fs/udf/namei.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 33b246b..ed2f221 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -902,6 +902,10 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
 				iinfo->i_location.partitionReferenceNum,
 				0);
 		epos.bh = udf_tgetblk(sb, block);
+		if (!epos.bh) {
+			err = -ENOMEM;
+			goto out_no_entry;
+		}
 		lock_buffer(epos.bh);
 		memset(epos.bh->b_data, 0x00, bsize);
 		set_buffer_uptodate(epos.bh);
-- 
1.9.1


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

* Re: [PATCH] udf: NULL dereference at udf_symlink() on error
  2015-03-23  6:11 [PATCH] udf: NULL dereference at udf_symlink() on error Changwoo Min
@ 2015-04-01 10:55 ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2015-04-01 10:55 UTC (permalink / raw)
  To: Changwoo Min
  Cc: jack, linux-kernel, taesoo, changwoo, sanidhya, blee, csong84

On Mon 23-03-15 02:11:49, Changwoo Min wrote:
> There is no check for udf_tgetblk(), which could return NULL, in udf_symlink(). 
> So there is a possibility of returning NULL under heavy memory pressure and 
> possibility of NULL dereference. 
> 
> Signed-off-by: Changwoo Min <changwoo.m@gmail.com>
> ---
>  fs/udf/namei.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/fs/udf/namei.c b/fs/udf/namei.c
> index 33b246b..ed2f221 100644
> --- a/fs/udf/namei.c
> +++ b/fs/udf/namei.c
> @@ -902,6 +902,10 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
>  				iinfo->i_location.partitionReferenceNum,
>  				0);
>  		epos.bh = udf_tgetblk(sb, block);
> +		if (!epos.bh) {
> +			err = -ENOMEM;
  This should be -EIO as per our discussion at the previous patch.
Otherwise I agree.

								Honza

> +			goto out_no_entry;
> +		}
>  		lock_buffer(epos.bh);
>  		memset(epos.bh->b_data, 0x00, bsize);
>  		set_buffer_uptodate(epos.bh);
> -- 
> 1.9.1
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

end of thread, other threads:[~2015-04-01 10:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-23  6:11 [PATCH] udf: NULL dereference at udf_symlink() on error Changwoo Min
2015-04-01 10:55 ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).