Skip to contentSkip to conversation

mm: Fail when offset == num in first check of vm_map_pages_zero()

PATCH In review Miguel Ojeda 2 participants 3 messages May 28, 2019 – Jun 1, 2019

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

PATCH 1/1 mm: Fail when offset == num in first check of vm_map_pages_zero()

If the user asks us for offset == num, we should already fail in the first check, i.e. the one testing for offsets beyond the object.

At the moment, we are failing on the second test anyway, since count cannot be 0. Still, to agree with the comment of the first test, we should first there.

---
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +1 -1
index ddf20bd0c317..74cf8b0ce353 100644
@@ -1547,7 +1547,7 @@ static int __vm_map_pages(struct vm_area_struct *vma, struct page **pages,
 	int ret, i;
 
 	/* Fail if the user requested offset is beyond the end of the object */
-	if (offset > num)
+	if (offset >= num)
 		return -ENXIO;
 
 	/* Fail if the user requested size exceeds available object size */
Signature · 1 line
2.17.1
#1 lore raw
Quoted 7 lines · Miguel Ojeda

If the user asks us for offset == num, we should already fail in the first check, i.e. the one testing for offsets beyond the object.

At the moment, we are failing on the second test anyway, since count cannot be 0. Still, to agree with the comment of the first test, we should first there.

I think, we need to cc linux-mm.

Quoted 22 lines
---
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +1 -2
index ddf20bd0c317..74cf8b0ce353 100644
@@ -1547,7 +1547,7 @@ static int __vm_map_pages(struct vm_area_struct *vma, struct page **pages,
        int ret, i;
 
        /* Fail if the user requested offset is beyond the end of the object */
-       if (offset > num)
+       if (offset >= num)
                return -ENXIO;
 
        /* Fail if the user requested size exceeds available object size */
--

2.17.1

#2 lore raw
Quoted 4 lines · Souptick Joarder
Quoted 1 line · Miguel Ojeda
Quoted 8 lines
Quoted 6 lines

If the user asks us for offset == num, we should already fail in the first check, i.e. the one testing for offsets beyond the object.

At the moment, we are failing on the second test anyway, since count cannot be 0. Still, to agree with the comment of the first test, we should first there.

I think, we need to cc linux-mm.

Cc'ing Andrew as well as Souptick suggested me.

Cheers,
Miguel