Skip to contentSkip to conversation

kanoj-mm25-2.3.26 Fix max_mapnr<<PAGE_SHIFT overflows

PATCH New Kanoj Sarcar 1 participant 1 message Nov 9, 1999

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

PATCH 1/1 kanoj-mm25-2.3.26 Fix max_mapnr<<PAGE_SHIFT overflows

This has already been sent to Linus to be included into 2.3.27.

Kanoj

Linus,

Now that >4Gb memory support is possible, it is no longer true that (max_mapnr << PAGE_SHIFT) can be held within a 32 bit unsigned long. This patch tries to fix this overflow problem.

Please put into 2.3.27. Thanks.

Kanoj

ncpfs/dir.c renamed from usr/tmp/p_rdiff_a006_p/dir.c +1 -2
@@ -405,7 +405,6 @@
 {
 	unsigned long dent_addr = (unsigned long) dentry;
 	unsigned long min_addr = PAGE_OFFSET;
-	unsigned long max_addr = min_addr + (max_mapnr << PAGE_SHIFT);
 	unsigned long align_mask = 0x0F;
 	unsigned int len;
 	int valid = 0;
@@ -412,7 +411,7 @@
 
 	if (dent_addr < min_addr)
 		goto bad_addr;
-	if (dent_addr > max_addr - sizeof(struct dentry))
+	if (dent_addr > (unsigned long)high_memory - sizeof(struct dentry))
 		goto bad_addr;
 	if ((dent_addr & ~align_mask) != dent_addr)
 		goto bad_align;
proc/kcore.c renamed from usr/tmp/p_rdiff_a006_z/kcore.c +1 -1
@@ -20,7 +20,7 @@
 ssize_t read_kcore(struct file * file, char * buf,
 			 size_t count, loff_t *ppos)
 {
-	unsigned long p = *ppos, memsize;
+	unsigned long long p = *ppos, memsize;
 	ssize_t read;
 	ssize_t count1;
 	char * pnt;
vmalloc.c renamed from usr/tmp/p_rdiff_a006-8/vmalloc.c +1 -1
@@ -204,7 +204,7 @@
 	struct vm_struct *area;
 
 	size = PAGE_ALIGN(size);
-	if (!size || size > (max_mapnr << PAGE_SHIFT)) {
+	if (!size || ((PAGE_ALIGN(size) >> PAGE_SHIFT) > max_mapnr)) {
 		BUG();
 		return NULL;
 	}

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://humbolt.geo.uu.nl/Linux-MM/