OSDN Git Service

linux-user: Fix up timer id handling
authorAlexander Graf <agraf@suse.de>
Mon, 10 Nov 2014 20:33:03 +0000 (21:33 +0100)
committerRiku Voipio <riku.voipio@linaro.org>
Tue, 11 Nov 2014 06:13:09 +0000 (08:13 +0200)
commitaecc88616a64a4e0a1ae0d6986de0054ea9f37d2
treeff3f27cb5e8e23ae7bc3e146f97f7ccbbd406e1c
parentccf661f827faf700b03a30076b5f944e8f787280
linux-user: Fix up timer id handling

When creating a timer handle, we give the timer id a special magic offset
of 0xcafe0000. However, we never mask that offset out of the timer id before
we start using it to dereference our timer array. So we always end up aborting
timer operations because the timer id is out of bounds.

This was not an issue before my patch e52a99f756e ("linux-user: Simplify
timerid checks on g_posix_timers range") because before we would blindly mask
anything above the first 16 bits.

This patch simplifies the code around timer id creation by introducing a proper
target_timer_id typedef that is s32, just like Linux has it. It also changes the
magic offset to a value that makes all timer ids be positive.

Reported-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Tested-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user/syscall.c
linux-user/syscall_defs.h