Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp643064ybk; Wed, 13 May 2020 09:14:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx00HuVqMRQ6cMSqgBnwujk4bDzHS1BnflPu2JylLQY0b+1oF6OK+rGrmo5WDJGTNlUXDHz X-Received: by 2002:a17:906:2455:: with SMTP id a21mr3909756ejb.73.1589386476275; Wed, 13 May 2020 09:14:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589386476; cv=none; d=google.com; s=arc-20160816; b=MdjUKaVWJZwZ4+DZ6gXTO99aJB9noWbKEF8ysvFV+RMny5n/4IMJYLTNV8ePcuJI9m i1KnQ03O4Tj+vJ5tZNwsQ2UR+cQmx7HpsDPJY5aXORJJSHI22uc40F3QqWuGFTIq3zrs YEPcfX+gKXJb1TWKvRwkbTPVWXUSjSIeeIJT4S8NrtPjDZ3FddNVKy2P46Qkbjx047YK M96tNRu/rpKq1iBnd/ZvVrgmZm8ITGTr91Ty2o68JBi0LM/tpxLU6+/2O1RIH/fUvH9s 9HyQ+3evDbJ48jtLEXtgYeOR4I4Q4r9vIku5hE7bg0ubj4sIEaaif2u7T1e568a8eg+3 7VDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=y10ZUw5JLZUy5X7NpM34S9RAF9684VrN59b2tymdxhM=; b=tCmC63qFnwABDB0aiZkD7fShvZVuwQf7FYHclM0eaCGzs7jh9f6MWfZ56JM13Uh/CM kNEOZpkmR6i9dvGP9UUcw+hBGm3cdePy7bjGRefTx6+Lptx9rGKUnhjnXNEFUNzbIXq+ XhXRsL85GivkYbjc3ab8aHNoBxvx+z5r1f5p3OJD7x3x7fakJXLoIIdREkqykG1DiVQk YhGmVZWe+XQhZw8HAuKb1QVz2o6C0GyKJi4LfvvualvsWuO5zqKxDiCgnfQBYKteQjVK YgIFqXXeQDkzDHw2HuhexgduOeYTQI+pDu8a/V1qH3nXt3dOxeJs3Vxvp6vbO1Rpa/R8 nJRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b10si83112ejd.323.2020.05.13.09.14.12; Wed, 13 May 2020 09:14:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389486AbgEMQJn (ORCPT + 99 others); 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.