lkml.org 
[lkml]   [2023]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] bpf: Add length check for SK_DIAG_BPF_STORAGE_REQ_MAP_FD parsing
Hello Leon,

>
> Jakub, it seems like Lin adds this check to all nla_for_each_nested() loops.
> IMHO, the better change will be to change nla_for_each_nested() skip empty/not valid NLAs.
>
> Thanks

I guess you just get these fixes misunderstood. I do not add the nla_len check
to **all nla_for_each_nested** :(. I only add checks to those who do not access
the attributes without verifying the length, which is buggy.

The others, either do a similar nla_len check already or just do nla_validate
somewhere else. That is to say, they **validate** the relevant attributes.

In short, nla_for_each_nested is just a loop macro that iterates the nlattrs,
like nla_for_each macro. It is weird for them to do nlattr validation as there
could have already been a call to nla_validate to ensure those attributes are
correct. That is, for those who do not, a simple nla_len check is the simplest
and most efficient choice.

Regards
Lin
\
 
 \ /
  Last update: 2023-07-25 07:25    [W:0.093 / U:0.412 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site