Re: [RFC][PATCH] timer: Add function-change canary
From: Kees Cook
Date: Tue Aug 08 2017 - 13:59:55 EST
On Mon, Aug 7, 2017 at 5:33 PM, Kees Cook <keescook@xxxxxxxxxxxx> wrote:
> This introduces canaries to struct timer_list in an effort to protect the
> function callback pointer from getting rewritten during stack or heap
> overflow attacks. The struct timer_list has become a recent target for
> security flaw exploitation because it includes the "data" argument in
> the structure, along with the function callback. This provides attackers
> with a ROP-like primitive for performing limited kernel function calls
> without needing all the prerequisites to stage a ROP attack.
>
> Recent examples of exploits using struct timer_list attacks:
>
> http://www.openwall.com/lists/oss-security/2016/12/06/1
> (https://www.exploit-db.com/exploits/40871/)
>
> https://googleprojectzero.blogspot.com/2017/05/exploiting-linux-kernel-via-packet.html
> (https://www.exploit-db.com/exploits/41458/)
>
> Timers normally have their callback functions initialized either via
> the setup_timer_*() macros or manually before calls to add_timer(). The
> per-timer canary gets set in either case, and then checked at timer
> expiration time before calling the function.
Har har, I missed DEFINE_TIMER() which is rather widely used. :P
I'll send a v2, though the canary may end up being a bit weaker to
deal with static initializers.
-Kees
--
Kees Cook
Pixel Security