From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C917CC433E0 for ; Wed, 13 May 2020 16:09:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 09D60205ED for ; Wed, 13 May 2020 16:09:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389496AbgEMQJn (ORCPT ); Wed, 13 May 2020 12:09:43 -0400 Received: from verein.lst.de ([213.95.11.211]:47365 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389465AbgEMQJl (ORCPT ); Wed, 13 May 2020 12:09:41 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 3DC4168B05; Wed, 13 May 2020 18:09:38 +0200 (CEST) Date: Wed, 13 May 2020 18:09:38 +0200 From: Christoph Hellwig To: Eric Dumazet Cc: Christoph Hellwig , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] net: cleanly handle kernel vs user buffers for ->msg_control Message-ID: <20200513160938.GA22381@lst.de> References: <20200511115913.1420836-1-hch@lst.de> <20200511115913.1420836-4-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.