mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] FS: nilfs2: clamps ns_r_segments_percentage to [1, 99]
@ 2012-02-20 21:55 Haogang Chen
  2012-02-22 15:46 ` Ryusuke Konishi
  0 siblings, 1 reply; 4+ messages in thread
From: Haogang Chen @ 2012-02-20 21:55 UTC (permalink / raw)
  To: konishi.ryusuke; +Cc: linux-nilfs, linux-kernel, haogangchen

ns_r_segments_percentage is read from the disk. Bogus or malicious
value could cause integer overflow and potential security holes.
This patch reports error when mounting such bogus volumes.

Signed-off-by: Haogang Chen <haogangchen@gmail.com>
---
 fs/nilfs2/the_nilfs.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index d327140..e12b47b 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -409,6 +409,12 @@ static int nilfs_store_disk_layout(struct the_nilfs *nilfs,
 	nilfs->ns_first_data_block = le64_to_cpu(sbp->s_first_data_block);
 	nilfs->ns_r_segments_percentage =
 		le32_to_cpu(sbp->s_r_segments_percentage);
+	if (nilfs->ns_r_segments_percentage < 1 ||
+		nilfs->ns_r_segments_percentage > 99) {
+		printk(KERN_ERR "NILFS: invalid reserved segments percentage.\n");
+		return -EINVAL;
+	}
+
 	nilfs_set_nsegments(nilfs, le64_to_cpu(sbp->s_nsegments));
 	nilfs->ns_crc_seed = le32_to_cpu(sbp->s_crc_seed);
 	return 0;
-- 
1.7.5.4


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

end of thread, other threads:[~2012-02-23  2:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-20 21:55 [PATCH] FS: nilfs2: clamps ns_r_segments_percentage to [1, 99] Haogang Chen
2012-02-22 15:46 ` Ryusuke Konishi
2012-02-22 15:59   ` Xi Wang
2012-02-23  2:31     ` Ryusuke Konishi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®