lkml.org 
[lkml]   [2020]   [May]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/3] net: cleanly handle kernel vs user buffers for ->msg_control
On Wed, May 13, 2020 at 08:41:57AM -0700, Eric Dumazet wrote:
> > + * recv* side when msg_control_is_user is set, msg_control is the kernel
> > + * buffer used for all other cases.
> > + */
> > + union {
> > + void *msg_control;
> > + void __user *msg_control_user;
> > + };
> > + bool msg_control_is_user : 1;
>
> Adding a field in this structure seems dangerous.
>
> Some users of 'struct msghdr ' define their own struct on the stack,
> and are unaware of this new mandatory field.
>
> This bit contains garbage, crashes are likely to happen ?
>
> Look at IPV6_2292PKTOPTIONS for example.

I though of that, an that is why the field is structured as-is. The idea
is that the field only matters if:

(1) we are in the recvmsg and friends path, and
(2) msg_control is non-zero

I went through the places that initialize msg_control to find any spot
that would need an annotation. The IPV6_2292PKTOPTIONS sockopt doesn't
need one as it is using the msghdr in sendmsg-like context.

That being said while I did the audit I'd appreciate another look from
people that know the networking code better than me of course.

\
 
 \ /
  Last update: 2020-05-13 18:10    [W:0.069 / U:1.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site