lkml.org 
[lkml]   [2018]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH RESEND] KEYS: fix parsing invalid pkey info string
On Mon, Dec 17, 2018 at 10:49 AM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> So the *simplest* fix would seem to be to literally remove all those
> "= -1" for the Opt_err initialization. Making the code smaller,
> simpler, and fixing the bug in the process.

Something like this

git grep -l 'Opt_err = -1' | xargs sed -i 's/Opt_err = -1/Opt_err/'

would do it, but I also notice that
security/integrity/ima/ima_policy.c then has some truly funky code
that plays around with the enum numbers , ie

#define pt(token) policy_tokens[token + Opt_err].pattern

which actually depends on the ordering of policy_tokens[], and depends
on the exact values, ie it literally (and quite insanely) sets Opt_err
to -1, and then Opt_measure to 1, and leaves 0 unused. That code
seriously makes no sense at all, and is fundamentally broken.

It would be better to use

#define pt(token) policy_tokens[token - Opt_measure].pattern

instead, but even then you should have a huge comment about how the
policy_tokens[] array absolutely has to be properly ordered.

Honestly, for being about "security", all of this code seems to be
doing some really questionable things with all those Opt_xyz enums.

Linus

\
 
 \ /
  Last update: 2018-12-17 20:07    [W:5.394 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site