lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <5b8bce06-de7c-e600-557b-6885abac0f43@omp.ru>
Date: Thu, 19 Sep 2024 22:55:18 +0300
From: Sergey Shtylyov <s.shtylyov@....ru>
To: Jan Kara <jack@...e.cz>, <linux-kernel@...r.kernel.org>,
	<stable@...r.kernel.org>
CC: <lvc-project@...uxtesting.org>
Subject: [PATCH v2 5.10.y] udf: Fold udf_getblk() into udf_bread()

Subject: [PATCH v2 5.10.y] udf: Fold udf_getblk() into udf_bread()

From: Jan Kara <jack@...e.cz>

[ Upstream commit 32f123a3f34283f9c6446de87861696f0502b02e ]

udf_getblk() has a single call site. Fold it there.

[Sergey: moved back to using udf_get_block() and buffer_{mapped|new}().]

Signed-off-by: Jan Kara <jack@...e.cz>
Signed-off-by: Sergey Shtylyov <s.shtylyov@....ru>

---
This patch prevents NULL pointer dereference in case sb_getblk() fails...

Changes in version 2:
- mentioned the original commit.

 fs/udf/inode.c |   45 +++++++++++++++++++--------------------------
 1 file changed, 19 insertions(+), 26 deletions(-)

Index: linux-stable/fs/udf/inode.c
===================================================================
--- linux-stable.orig/fs/udf/inode.c
+++ linux-stable/fs/udf/inode.c
@@ -458,30 +458,6 @@ abort:
 	return err;
 }
 
-static struct buffer_head *udf_getblk(struct inode *inode, udf_pblk_t block,
-				      int create, int *err)
-{
-	struct buffer_head *bh;
-	struct buffer_head dummy;
-
-	dummy.b_state = 0;
-	dummy.b_blocknr = -1000;
-	*err = udf_get_block(inode, block, &dummy, create);
-	if (!*err && buffer_mapped(&dummy)) {
-		bh = sb_getblk(inode->i_sb, dummy.b_blocknr);
-		if (buffer_new(&dummy)) {
-			lock_buffer(bh);
-			memset(bh->b_data, 0x00, inode->i_sb->s_blocksize);
-			set_buffer_uptodate(bh);
-			unlock_buffer(bh);
-			mark_buffer_dirty_inode(bh, inode);
-		}
-		return bh;
-	}
-
-	return NULL;
-}
-
 /* Extend the file with new blocks totaling 'new_block_bytes',
  * return the number of extents added
  */
@@ -1197,10 +1173,27 @@ struct buffer_head *udf_bread(struct ino
 			      int create, int *err)
 {
 	struct buffer_head *bh = NULL;
+	struct buffer_head dummy;
+
+	dummy.b_state = 0;
+	dummy.b_blocknr = -1000;
+	*err = udf_get_block(inode, block, &dummy, create);
+	if (*err || !buffer_mapped(&dummy))
+		return NULL;
 
-	bh = udf_getblk(inode, block, create, err);
-	if (!bh)
+	bh = sb_getblk(inode->i_sb, dummy.b_blocknr);
+	if (!bh) {
+		*err = -ENOMEM;
 		return NULL;
+	}
+	if (buffer_new(&dummy)) {
+		lock_buffer(bh);
+		memset(bh->b_data, 0x00, inode->i_sb->s_blocksize);
+		set_buffer_uptodate(bh);
+		unlock_buffer(bh);
+		mark_buffer_dirty_inode(bh, inode);
+		return bh;
+	}
 
 	if (buffer_uptodate(bh))
 		return bh;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ