Skip to contentSkip to conversation

mm: BUG when __kmap_atomic_idx crosses boundary

PATCH In review Chintan Pandya 3 participants 5 messages Jul 30, 2014 – Jul 31, 2014

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

PATCH 1/1 mm: BUG when __kmap_atomic_idx crosses boundary

__kmap_atomic_idx >= KM_TYPE_NR or < ZERO is a bug. Report it even if CONFIG_DEBUG_HIGHMEM is not enabled. That saves much debugging efforts.

---
 include/linux/highmem.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
include/linux/highmem.h +1 -5
index 7fb31da..f42cafd 100644
@@ -93,8 +93,8 @@ static inline int kmap_atomic_idx_push(void)
 
 #ifdef CONFIG_DEBUG_HIGHMEM
 	WARN_ON_ONCE(in_irq() && !irqs_disabled());
-	BUG_ON(idx > KM_TYPE_NR);
 #endif
+	BUG_ON(idx >= KM_TYPE_NR);
 	return idx;
 }
 
@@ -105,13 +105,9 @@ static inline int kmap_atomic_idx(void)
 
 static inline void kmap_atomic_idx_pop(void)
 {
-#ifdef CONFIG_DEBUG_HIGHMEM
 	int idx = __this_cpu_dec_return(__kmap_atomic_idx);
 
 	BUG_ON(idx < 0);
-#else
-	__this_cpu_dec(__kmap_atomic_idx);
-#endif
 }
 
 #endif
Signature · 10 lines
Chintan Pandya

QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer
#1 lore raw
Quoted 3 lines · On Wed, 30 Jul 2014 14:22:35 +0530 Chintan Pandya <[email protected]>…

__kmap_atomic_idx >= KM_TYPE_NR or < ZERO is a bug. Report it even if CONFIG_DEBUG_HIGHMEM is not enabled. That saves much debugging efforts.

Please take considerably more care when preparing patch changelogs.

kmap_atomic() is a very commonly called function so we'll need much more detail than this to justify adding overhead to it.

I don't think CONFIG_DEBUG_HIGHMEM really needs to exist. We could do s/CONFIG_DEBUG_HIGHMEM/CONFIG_DEBUG_VM/g and perhaps your secret bug whatever it was would have been found more easily.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw
Quoted 6 lines · Andrew Morton
Quoted 3 lines · On Wed, 30 Jul 2014 14:22:35 +0530 Chintan Pandya <[email protected]>…

__kmap_atomic_idx >= KM_TYPE_NR or < ZERO is a bug. Report it even if CONFIG_DEBUG_HIGHMEM is not enabled. That saves much debugging efforts.

Quoted 8 lines

Please take considerably more care when preparing patch changelogs.

kmap_atomic() is a very commonly called function so we'll need much more detail than this to justify adding overhead to it.

I don't think CONFIG_DEBUG_HIGHMEM really needs to exist. We could do s/CONFIG_DEBUG_HIGHMEM/CONFIG_DEBUG_VM/g and perhaps your secret bug whatever it was would have been found more easily.

Agreed, it would be nice to fold DEBUG_HIGHMEM into DEBUG_VM. However you'd still need some kind of intermediate option as DEBUG_VM must still exist if !HIGHMEM.

Thanks,
Davidlohr

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw
Quoted 12 lines · Davidlohr Bueso
Quoted 11 lines · Andrew Morton
Quoted 3 lines · On Wed, 30 Jul 2014 14:22:35 +0530 Chintan Pandya <[email protected]>…

__kmap_atomic_idx >= KM_TYPE_NR or < ZERO is a bug. Report it even if CONFIG_DEBUG_HIGHMEM is not enabled. That saves much debugging efforts.

Please take considerably more care when preparing patch changelogs.

kmap_atomic() is a very commonly called function so we'll need much more detail than this to justify adding overhead to it.

Quoted 7 lines
Quoted 3 lines

I don't think CONFIG_DEBUG_HIGHMEM really needs to exist. We could do s/CONFIG_DEBUG_HIGHMEM/CONFIG_DEBUG_VM/g and perhaps your secret bug whatever it was would have been found more easily.

Agreed, it would be nice to fold DEBUG_HIGHMEM into DEBUG_VM. However you'd still need some kind of intermediate option as DEBUG_VM must still exist if !HIGHMEM.

Actually no, it's a lot more straightforward than I thought.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
In reply to Andrew Morton
Quoted 7 lines · Andrew Morton
Quoted 3 lines · On Wed, 30 Jul 2014 14:22:35 +0530 Chintan Pandya<[email protected]>…

__kmap_atomic_idx>= KM_TYPE_NR or< ZERO is a bug. Report it even if CONFIG_DEBUG_HIGHMEM is not enabled. That saves much debugging efforts.

Please take considerably more care when preparing patch changelogs.

Okay. I will prepare new commit message.

Quoted 7 lines

kmap_atomic() is a very commonly called function so we'll need much more detail than this to justify adding overhead to it.

I don't think CONFIG_DEBUG_HIGHMEM really needs to exist. We could do s/CONFIG_DEBUG_HIGHMEM/CONFIG_DEBUG_VM/g and perhaps your secret bug whatever it was would have been found more easily.

Um, we didn't get bug directly hitting here.

Quoted 1 line

__kmap_atomic_idx should not be equal to KM_TYPE_NR anyway. So, at least I will share that patch. For changing DEBUG_HIGHMEM to DEBUG_VM, I will work on it.

Signature · 8 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>