Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp203118ybg; Tue, 28 Jul 2020 03:55:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhbMi765KtdMO8PBVhPLjcnLt590hRqj9n2QV90LFkho9jC6TfUEcaWzB8cWfCQTOdyzZg X-Received: by 2002:a17:906:37c3:: with SMTP id o3mr6845459ejc.54.1595933758262; Tue, 28 Jul 2020 03:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595933758; cv=none; d=google.com; s=arc-20160816; b=mbePqZKi9LLTY2pl46kOew4kKyy+MEq5lS9nmIcGsAjWZZDGZoj1bPqJxrzRIV/wcY s6LRWPNDhOT/7pJNMES1DzhrlKhXRdzGQC2HELKT7+OqV2MFLKAterjuJJWJ4UOwiOrf 1tP0uJWTeFgooZVqmb7yqfmWLaDnd1S3fbKscb0ZJ0scZnmJV5pN86GqKnddV2oemM3m TCWAA8NuhUIDO5f78hLsem1o7Wmyj/gCpUIA7CvLqEzdQra5AuqrV8GI10170+qgfLHF yf2hoH7g6CE+h2kkC2IOWPNfoLG0VLqh+DoJrZHuM0Kr+OY/ovdgwcyNP+dXi8dZsVda wi4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=gp9BwtjqJD+LF/xnKuMs0ifPRocb8KmdbZ5i5NzcPQI=; b=jUXewpQ/b8sSKwPJx+5va76HB2JoicEOzl+n860rwrUUXZy8xp3l4Hzf0LnSj+Zdfg 4QZDeJ1GItQCftbaq25a5drBqcuT943iivzvpwZ0fZrAxnIH10GEMBZLr27D3QO+IfzV 687RqhiYLLQbi4baWSVcqzUrk7q6GNTmaLikvwquwPvPh85SGDtobpdmkyA2pg2kVR5z B2rB1wM7Hv38A2/YyauNjPAqAuyIOOAQMDSW2noK0STNzaz98MJwkrm6fH1eMMH+lIAz VXPuZ2L7dxglhmw6W5qBkO/NIEminSO4VNRt8WOamebsSqVBU4XQNpFGdR1JkOkmnh1y uxkA== 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 r3si6758530ejr.664.2020.07.28.03.55.36; Tue, 28 Jul 2020 03:55:58 -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 S1728931AbgG1Kyo (ORCPT + 99 others); Tue, 28 Jul 2020 06:54:44 -0400 Received: from www62.your-server.de ([213.133.104.62]:49934 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728876AbgG1Kyo (ORCPT ); Tue, 28 Jul 2020 06:54:44 -0400 Received: from sslproxy02.your-server.de ([78.47.166.47]) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1k0NFD-0004CE-Pr; Tue, 28 Jul 2020 12:54:03 +0200 Received: from [178.196.57.75] (helo=pc-9.home) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k0NFD-000VJh-8W; Tue, 28 Jul 2020 12:54:03 +0200 Subject: Re: [Linux-kernel-mentees] [PATCH net v2] xdp: Prevent kernel-infoleak in xsk_getsockopt() To: Peilin Ye , Song Liu , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Jonathan Lemon Cc: Dan Carpenter , Arnd Bergmann , Greg Kroah-Hartman , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Jesper Dangaard Brouer , John Fastabend , Martin KaFai Lau , Yonghong Song , Andrii Nakryiko , KP Singh , linux-kernel-mentees@lists.linuxfoundation.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200728022859.381819-1-yepeilin.cs@gmail.com> <20200728053604.404631-1-yepeilin.cs@gmail.com> From: Daniel Borkmann Message-ID: <916dbfd3-e601-c4be-41f0-97efc4aaa456@iogearbox.net> Date: Tue, 28 Jul 2020 12:53:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20200728053604.404631-1-yepeilin.cs@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.3/25886/Mon Jul 27 16:48:28 2020) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/28/20 7:36 AM, Peilin Ye wrote: > xsk_getsockopt() is copying uninitialized stack memory to userspace when > `extra_stats` is `false`. Fix it. > > Fixes: 8aa5a33578e9 ("xsk: Add new statistics") > Suggested-by: Dan Carpenter > Signed-off-by: Peilin Ye > --- > Doing `= {};` is sufficient since currently `struct xdp_statistics` is > defined as follows: > > struct xdp_statistics { > __u64 rx_dropped; > __u64 rx_invalid_descs; > __u64 tx_invalid_descs; > __u64 rx_ring_full; > __u64 rx_fill_ring_empty_descs; > __u64 tx_ring_empty_descs; > }; > > When being copied to the userspace, `stats` will not contain any > uninitialized "holes" between struct fields. I've added above explanation to the commit log since it's useful reasoning for later on 'why' something has been done a certain way. Applied, thanks Peilin!