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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210122212229.17072-5-richard@nod.at>
Date:   Fri, 22 Jan 2021 22:22:29 +0100
From:   Richard Weinberger <richard@....at>
To:     linux-mtd@...ts.infradead.org
Cc:     david@...ma-star.at, richard@....at, linux-kernel@...r.kernel.org
Subject: [PATCH 4/4] ubifs: Harden ubifs_jnl_write_inode()

Make sure that ubifs_jnl_write_inode() cannot be abused and will
not write less data then expected.

Signed-off-by: Richard Weinberger <richard@....at>
---
 fs/ubifs/journal.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index 03410ae0813a..1b28fcc5b9fe 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -844,10 +844,12 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
 	struct ubifs_ino_node *ino, *ino_start;
 	struct ubifs_inode *ui = ubifs_inode(inode);
 	int sync = 0, write_len = 0, ilen = UBIFS_INO_NODE_SZ;
-	int last_reference = !inode->i_nlink;
+	int last_reference = !inode->i_nlink, xattr_inos_written = 0;
 	int kill_xattrs = ui->xattr_cnt && last_reference;
 	u8 hash[UBIFS_HASH_ARR_SZ];
 
+	ubifs_assert(c, !ui->xattr);
+
 	dbg_jnl("ino %lu, nlink %u", inode->i_ino, inode->i_nlink);
 
 	/*
@@ -917,12 +919,14 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
 			pack_inode(c, ino, xino, 0);
 			ino = (void *)ino + UBIFS_INO_NODE_SZ;
 			iput(xino);
+			xattr_inos_written++;
 
 			kfree(pxent);
 			pxent = xent;
 			key_read(c, &xent->key, &key);
 		}
 		kfree(pxent);
+		ubifs_assert(c, xattr_inos_written == ui->xattr_cnt);
 	}
 
 	pack_inode(c, ino, inode, 1);
-- 
2.26.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ