[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200513160938.GA22381@lst.de>
Date: Wed, 13 May 2020 18:09:38 +0200
From: Christoph Hellwig <hch@....de>
To: Eric Dumazet <eric.dumazet@...il.com>
Cc: Christoph Hellwig <hch@....de>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [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.
Powered by blists - more mailing lists