Skip to contentSkip to conversation

xen/multicall: xen_mc_callback(): avoid buffer overflow

PATCH In review Tim Gardner 2 participants 3 messages Feb 8, 2013

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

PATCH 1/1 xen/multicall: xen_mc_callback(): avoid buffer overflow

This buffer overflow was introduced with 91e0c5f3dad47838cb2ecc1865ce789a0b7182b1 (2.6.24).

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Jeremy Fitzhardinge <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>

---

This patch applies cleanly to 3.1.10 and newer. Requires a backport for 2.6.24-3.2.y

 arch/x86/xen/multicalls.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/xen/multicalls.c +2 -1
index 0d82003..5270407 100644
@@ -195,9 +195,10 @@ void xen_mc_callback(void (*fn)(void *), void *data)
 	struct mc_buffer *b = &__get_cpu_var(mc_buffer);
 	struct callback *cb;
 
-	if (b->cbidx == MC_BATCH) {
+	if (b->cbidx >= MC_BATCH) {
 		trace_xen_mc_flush_reason(XEN_MC_FL_CALLBACK);
 		xen_mc_flush();
+		return;
 	}
 
 	trace_xen_mc_callback(fn, data);
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 2 lines · Tim Gardner

This buffer overflow was introduced with 91e0c5f3dad47838cb2ecc1865ce789a0b7182b1 (2.6.24).

There's no buffer overflow here. xen_mc_flush() resets b->cbidx.

David

Quoted 20 lines
 arch/x86/xen/multicalls.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/xen/multicalls.c +2 -1
index 0d82003..5270407 100644
@@ -195,9 +195,10 @@ void xen_mc_callback(void (*fn)(void *), void *data)
 	struct mc_buffer *b = &__get_cpu_var(mc_buffer);
 	struct callback *cb;
 
-	if (b->cbidx == MC_BATCH) {
+	if (b->cbidx >= MC_BATCH) {
 		trace_xen_mc_flush_reason(XEN_MC_FL_CALLBACK);
 		xen_mc_flush();
+		return;
 	}
 
 	trace_xen_mc_callback(fn, data);
#2 lore raw
In reply to Tim Gardner
Quoted 2 lines · Tim Gardner

This buffer overflow was introduced with 91e0c5f3dad47838cb2ecc1865ce789a0b7182b1 (2.6.24).

There's no buffer overflow here. xen_mc_flush() resets b->cbidx.

David

Quoted 20 lines
 arch/x86/xen/multicalls.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/xen/multicalls.c +2 -1
index 0d82003..5270407 100644
@@ -195,9 +195,10 @@ void xen_mc_callback(void (*fn)(void *), void *data)
 	struct mc_buffer *b = &__get_cpu_var(mc_buffer);
 	struct callback *cb;
 
-	if (b->cbidx == MC_BATCH) {
+	if (b->cbidx >= MC_BATCH) {
 		trace_xen_mc_flush_reason(XEN_MC_FL_CALLBACK);
 		xen_mc_flush();
+		return;
 	}
 
 	trace_xen_mc_callback(fn, data);