lkml.org 
[lkml]   [2018]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] posix-timers: Use array safe helper when fetching notification symbolic name
On Fri, Nov 09, 2018 at 10:18:25AM +0100, Thomas Gleixner wrote:
> > + nidx = array_index_nospec(notify & ~SIGEV_THREAD_ID, ARRAY_SIZE(nstr));
>
> I completely understand your intention, but this is misleading. The above
> is really not a speculation gadget.
>
> I'd rather do an open coded check here and fail the thing instead of
> printing wrong information:
>
> nidx = timer->it_sigev_notify & ~SIGEV_THREAD_ID;
> if (nidx >= ARRAY_SIZE(nstr))
> return -EINVAL;

Yes, I thought about such approach and did the similar code
in first place, then I dropped it because didn't want additional
"if"s here (your fix in the former commit already does all verification
needed). But thinking more I agree: this code is not time critical
and spending a few cycles won't hurt much. Will update, thanks Thomas!

\
 
 \ /
  Last update: 2018-11-09 10:29    [W:0.055 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site