Alarmtimer fixes for 3.1
cover Alarmtimer fixes for 3.1
Hey Thomas,
In reviewing the alarmtimer code, I ran across a few bugs that should be fixed for 3.1 and backported to 3.0-stable.
These are also available in the git repository at:
git://git.linaro.org/people/jstultz/linux.git fortglx/3.1/tip/timers/alarmtimers
The last of these is a pretty terrible hack, but I've got a more invasive fix (along with other cleanups) queued on top of these for 3.2 that should resolve it. Feel free to take a peek at those changes here:
git://git.linaro.org/people/jstultz/linux.git fortglx/3.2/tip/timers/alarmtimers
Let me know if you have any thoughts or feedback!
thanks
-john
John Stultz (3):
alarmtimers: Avoid possible null pointer traversal
alarmtimers: Memset itimerspec passed into alarm_timer_get
alarmtimers: Avoid possible denial of service with high freq periodic
timers
kernel/time/alarmtimer.c | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.3.2.146.gca209
PATCH 2/3 alarmtimers: Memset itimerspec passed into alarm_timer_get
Following common_timer_get, zero out the itimerspec passed in.
--- kernel/time/alarmtimer.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
kernel/time/alarmtimer.c +2 -0
@@ -441,6 +441,8 @@ static int alarm_timer_create(struct k_itimer *new_timer)static void alarm_timer_get (struct k_itimer *timr,struct itimerspec *cur_setting) { +memset (cur_setting,0 ,sizeof (struct itimerspec )); + cur_setting->it_interval =ktime_to_timespec (timr->it.alarmtimer.period); cur_setting->it_value =
Signature · 1 line
1.7.3.2.146.gca209
PATCH 3/3 alarmtimers: Avoid possible denial of service with high freq periodic timers
In reply to John StultzIts possible to jam up the alarm timers by setting very small interval timers, which will cause the alarmtimer subsystem to spend all of its time firing and restarting timers. This can effectivly lock up a box.
A deeper fix is needed, closely mimicking the hrtimer code, but for now just cap the interval to 100us to avoid userland hanging the system.
--- kernel/time/alarmtimer.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
kernel/time/alarmtimer.c +9 -0
@@ -481,6 +481,15 @@ static int alarm_timer_set(struct k_itimer *timr, int flags,if (!rtcdev)return -ENOTSUPP ; +/* +* XXX HACK! Currently we can DOS a system if the interval +* period on alarmtimers is too small. Cap the interval here +* to 100us and solve this properly in a future patch! -jstultz +*/ +if ((new_setting->it_interval.tv_sec ==0 ) && + (new_setting->it_interval.tv_nsec <100000 )) + new_setting->it_interval.tv_nsec =100000 ; +if (old_setting)alarm_timer_get (timr, old_setting);
Signature · 1 line
1.7.3.2.146.gca209
PATCH 1/3 alarmtimers: Avoid possible null pointer traversal
In reply to John StultzWe don't check if old_setting is non null before assigning it, so correct this.
--- kernel/time/alarmtimer.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
kernel/time/alarmtimer.c +2 -5
@@ -479,11 +479,8 @@ static int alarm_timer_set(struct k_itimer *timr, int flags,if (!rtcdev)return -ENOTSUPP ; -/* Save old values */ - old_setting->it_interval = -ktime_to_timespec (timr->it.alarmtimer.period); - old_setting->it_value = -ktime_to_timespec (timr->it.alarmtimer.node.expires); +if (old_setting) +alarm_timer_get (timr, old_setting);/* If the timer was already set, cancel it */ alarm_cancel (&timr->it.alarmtimer);
Signature · 1 line
1.7.3.2.146.gca209