Skip to contentSkip to conversation

pagemap: require aligned-length, non-null reads of /proc/pid/pagemap

PATCH New Vitaly Mayatskikh 1 participant 1 message Apr 20, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pagemap: require aligned-length, non-null reads of /proc/pid/pagemap

The intention of commit aae8679b0ebcaa92f99c1c3cb0cd651594a43915 was to force reads of /proc/pid/pagemap to be a multiple of 8 bytes, but now it allows to read 0 bytes, which actually puts some data to user's buffer. According to POSIX, if count is zero, read() should return zero and has no other results.

fs/proc/task_mmu.c +4 -0
index 39e4ad4..6f61b7c 100644
@@ -665,6 +665,10 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
 		goto out_task;
 
 	ret = 0;
+
+	if (!count)
+		goto out_task;
+
 	mm = get_task_mm(task);
 	if (!mm)
 		goto out_task;
Signature · 1 line
wbr, Vitaly