Skip to contentSkip to conversation

f2fs: use parameter max_items instead of PIDVEC_SIZE

PATCH In review Sheng Yong 2 participants 4 messages Mar 8, 2017 – Mar 9, 2017 F2FS file system

lore
Share & tools
lore

Sheng Yong

author
#0 lore raw

PATCH 1/2 f2fs: use parameter max_items instead of PIDVEC_SIZE

---
 fs/f2fs/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/trace.c +1 -1
index 73b4e1d..c82ab40 100644
@@ -138,7 +138,7 @@ static unsigned int gang_lookup_pids(pid_t *results, unsigned long first_index,
 
 	radix_tree_for_each_slot(slot, &pids, &iter, first_index) {
 		results[ret] = iter.index;
-		if (++ret == PIDVEC_SIZE)
+		if (++ret == max_items)
 			break;
 	}
 	return ret;
Signature · 9 lines
2.10.1


------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
author
#1 lore raw

PATCH 2/2 f2fs: check range before defragment

This patch checks the parameter range passed by ioctl to void that range exceeds the max_file_blocks limit.

---
 fs/f2fs/file.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/f2fs/file.c +6 -0
index e0b2378..eb675f1 100644
@@ -2045,6 +2045,12 @@ static int f2fs_ioc_defragment(struct file *filp, unsigned long arg)
 		goto out;
 	}
 
+	if (unlikely((range.start + range.len) >> PAGE_SHIFT >
+					sbi->max_file_blocks)) {
+		err = -EINVAL;
+		goto out;
+	}
+
 	err = f2fs_defragment_range(sbi, filp, &range);
 	f2fs_update_time(sbi, REQ_TIME);
 	if (err < 0)
Signature · 9 lines
2.10.1


------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] f2fs: check range before defragment

Quoted 4 lines · Sheng Yong

This patch checks the parameter range passed by ioctl to void that range exceeds the max_file_blocks limit.

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition.
http://sdm.link/oxford

Reviewed-by on v1 1/2
#3 lore raw
In reply to Sheng Yong
Quoted 1 line · Sheng Yong

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition.
http://sdm.link/oxford