Skip to contentSkip to conversation

makedumpfile: fix off-by-one bug in page_to_pfn()

PATCH In review Wen Congyang 3 participants 5 messages Nov 23, 2011 – Dec 13, 2011

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

PATCH 1/1 makedumpfile: fix off-by-one bug in page_to_pfn()

The pfn region in a mmd is [mmd->pfn_start, mmd->pfn_end). So the max index should be mmd->pfn_end - mmd->pfn_start -1. If index >=(not >) mmd->pfn_end - mmd->pfn_start, we should check the next mmd.

---
 makedumpfile.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
makedumpfile.c +1 -1
index 7b7c266..db8e53f 100644
@@ -2879,7 +2879,7 @@ page_to_pfn(unsigned long page)
 		if (page < mmd->mem_map)
 			continue;
 		index = (page - mmd->mem_map) / SIZE(page);
-		if (index > mmd->pfn_end - mmd->pfn_start)
+		if (index >= mmd->pfn_end - mmd->pfn_start)
 			continue;
 		pfn = mmd->pfn_start + index;
 		break;
Signature · 6 lines
1.7.1

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

Hi Wen,

Thank you for the patch.
I will check it.

Thanks
Kumagai

Quoted 26 lines · On Wed, 23 Nov 2011 13:53:51 +0800 Wen Congyang <[email protected]> wrote:

The pfn region in a mmd is [mmd->pfn_start, mmd->pfn_end). So the max index should be mmd->pfn_end - mmd->pfn_start -1. If index >=(not >) mmd->pfn_end - mmd->pfn_start, we should check the next mmd.

---
 makedumpfile.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
makedumpfile.c +1 -1
index 7b7c266..db8e53f 100644
@@ -2879,7 +2879,7 @@ page_to_pfn(unsigned long page)
 		if (page < mmd->mem_map)
 			continue;
 		index = (page - mmd->mem_map) / SIZE(page);
-		if (index > mmd->pfn_end - mmd->pfn_start)
+		if (index >= mmd->pfn_end - mmd->pfn_start)
 			continue;
 		pfn = mmd->pfn_start + index;
 		break;
Signature · 1 line
1.7.1

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#2 lore raw

At 11/24/2011 01:20 PM, Atsushi Kumagai Write:

Quoted 4 lines

Hi Wen,

Thank you for the patch.
I will check it.

Hi, kumagai

do you have any comment for this patch?

Thanks
Wen Congyang

Quoted 31 lines

Thanks
Kumagai

Quoted 23 lines · On Wed, 23 Nov 2011 13:53:51 +0800 Wen Congyang <[email protected]> wrote:

The pfn region in a mmd is [mmd->pfn_start, mmd->pfn_end). So the max index should be mmd->pfn_end - mmd->pfn_start -1. If index >=(not >) mmd->pfn_end - mmd->pfn_start, we should check the next mmd.

---
 makedumpfile.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
makedumpfile.c +1 -1
index 7b7c266..db8e53f 100644
@@ -2879,7 +2879,7 @@ page_to_pfn(unsigned long page)
 		if (page < mmd->mem_map)
 			continue;
 		index = (page - mmd->mem_map) / SIZE(page);
-		if (index > mmd->pfn_end - mmd->pfn_start)
+		if (index >= mmd->pfn_end - mmd->pfn_start)
 			continue;
 		pfn = mmd->pfn_start + index;
Quoted 9 lines
Quoted 3 lines
makedumpfile.c +0 -0
 		break;
Signature · 1 line
1.7.1

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#3 lore raw

Hi Wen,

Quoted 9 lines · Wen Congyang

At 11/24/2011 01:20 PM, Atsushi Kumagai Write:

Quoted 4 lines

Hi Wen,

Thank you for the patch.
I will check it.

Hi, kumagai

do you have any comment for this patch?

Sorry for late reply.
I will merge your fix to the next makedumpfile. By the way, did you detect this problem only by source program? Or by result of makedumpfile? If there is no problem, please let me know it.

Thanks
tachibana

Quoted 46 lines

Thanks
Wen Congyang

Quoted 31 lines

Thanks
Kumagai

Quoted 23 lines · On Wed, 23 Nov 2011 13:53:51 +0800 Wen Congyang <[email protected]> wrote:

The pfn region in a mmd is [mmd->pfn_start, mmd->pfn_end). So the max index should be mmd->pfn_end - mmd->pfn_start -1. If index >=(not >) mmd->pfn_end - mmd->pfn_start, we should check the next mmd.

---
 makedumpfile.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
makedumpfile.c +1 -1
index 7b7c266..db8e53f 100644
@@ -2879,7 +2879,7 @@ page_to_pfn(unsigned long page)
 		if (page < mmd->mem_map)
 			continue;
 		index = (page - mmd->mem_map) / SIZE(page);
-		if (index > mmd->pfn_end - mmd->pfn_start)
+		if (index >= mmd->pfn_end - mmd->pfn_start)
 			continue;
 		pfn = mmd->pfn_start + index;
Quoted 9 lines
Quoted 3 lines
makedumpfile.c +0 -0
 		break;
Signature · 1 line
1.7.1

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Quoted 4 lines

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw

At 12/13/2011 08:21 AM, [email protected] Write:

Quoted 9 lines

Hi Wen,

Quoted 6 lines · Wen Congyang

At 11/24/2011 01:20 PM, Atsushi Kumagai Write:

Quoted 4 lines

Hi Wen,

Thank you for the patch.
I will check it.

Quoted 8 lines
Quoted 3 lines

Hi, kumagai

do you have any comment for this patch?

Sorry for late reply.
I will merge your fix to the next makedumpfile. By the way, did you detect this problem only by source program? Or by result of makedumpfile? If there is no problem, please let me know it.

By result of makedumpfile. I find some pages are still in vmcore.

Thanks
Wen Congyang

Quoted 56 lines

Thanks
tachibana

Quoted 50 lines

Thanks
Wen Congyang

Quoted 31 lines

Thanks
Kumagai

Quoted 23 lines · On Wed, 23 Nov 2011 13:53:51 +0800 Wen Congyang <[email protected]> wrote:

The pfn region in a mmd is [mmd->pfn_start, mmd->pfn_end). So the max index should be mmd->pfn_end - mmd->pfn_start -1. If index >=(not >) mmd->pfn_end - mmd->pfn_start, we should check the next mmd.

---
 makedumpfile.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
makedumpfile.c +1 -1
index 7b7c266..db8e53f 100644
@@ -2879,7 +2879,7 @@ page_to_pfn(unsigned long page)
 		if (page < mmd->mem_map)
 			continue;
 		index = (page - mmd->mem_map) / SIZE(page);
-		if (index > mmd->pfn_end - mmd->pfn_start)
+		if (index >= mmd->pfn_end - mmd->pfn_start)
 			continue;
 		pfn = mmd->pfn_start + index;
Quoted 9 lines
Quoted 3 lines
makedumpfile.c +0 -0
 		break;
Signature · 1 line
1.7.1

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec