Re: [PATCH] Race condition in del_timer_sync (2.5)

From: Linus Torvalds
Date: Tue Sep 02 2003 - 02:56:58 EST



On Tue, 2 Sep 2003, Tejun Huh wrote:
>
> I'll submit the patch to Linus soon.

I actually already committed it to my tree, since everybody seems to agree
on it...

Linus

----
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1412 -> 1.1413
# kernel/timer.c 1.66 -> 1.67
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/09/02 torvalds@xxxxxxxxxxxxx 1.1413
# Fix del_timer_sync() SMP memory ordering (from Tejun Huh <tejun@xxxxxxxxxxxxx>)
#
# From Tejun's posting:
# >
# > This patch fixes a race between del_timer_sync and recursive timers.
# > Current implementation allows the value of timer->base that is used
# > for timer_pending test to be fetched before finishing running_timer
# > test, so it's possible for a recursive time to be pending after
# > del_timer_sync. Adding smp_rmb before timer_pending removes the race.
# --------------------------------------------
#
diff -Nru a/kernel/timer.c b/kernel/timer.c
--- a/kernel/timer.c Tue Sep 2 00:55:15 2003
+++ b/kernel/timer.c Tue Sep 2 00:55:15 2003
@@ -338,6 +338,7 @@
break;
}
}
+ smp_rmb();
if (timer_pending(timer))
goto del_again;


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/