Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp211068ybg; Tue, 28 Jul 2020 04:08:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyq6+0Y0pdAfwBdOfwTbXZg8xCwB2wfDBkqkIrREiK14EJulQ2J36Jn4I29yxOebtfF/wA9 X-Received: by 2002:a17:906:3a4c:: with SMTP id a12mr8407282ejf.306.1595934520259; Tue, 28 Jul 2020 04:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595934520; cv=none; d=google.com; s=arc-20160816; b=E4IO2fwhni6fRbpgcr0Y8k1LcOLVgeGPjRG/viGb0lKmpbdFlXu9jAL19qBx7lQYpb MSZN+ImbwDk0kIoh3g1ELlr+KEwhVvGV9W5J/3RmiHOenGmMdLABSGk/gvmkCDld2ZlC CzRjkcaKeFiV9R3DY5Ks9k3HDPTAxTUSatpWNkMw4EWrvb/5p2hxZSLvI/it90kpaQIg 54wllcP+/Lfp9aEM/HxBcHSqB5u5zzMIOlNS2uydE5IQSxRJuRs8c7JYQtj/FIQEtzJ3 QN66D5lXH+Sayzt/Re5u+SWfJxV7BsYgY2bhujON/qUSrLdgpUNaVKYGaPjSl7tHxJ5P bXzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=wLRXskVaKu10kKah7+1ZWwTzJMplfGNwKsb4sfPQ7ak=; b=XzGvUBLiG/6St5Flk1jAx+T35YJ9RJHguc8Yh9ndyh5atYaeQkf2+FZrEYqNfsR7fy JJhVJudSKuk6VKigDDR84IgIedYqxtoGKo0TUCIiDWLgpn6t/RuleYgLYRAFHNH/EG7X bY3sb0NqhpD6nk2tDzkto7xxlFsBe9jd3rYg7NKEf/l0IEy66//hudWQTdxpJQlZXd60 Xi6F/QwA5Mwm2AWOgIcqIABynplCUv8qeO3/X2LH8IucgZos+2qd7LrfhbR0bg8FccEe cXaCB8uw+aKciLigYnj57G9T7U0zl+nROKzA+qoOkabcwSweBxsRjYOVSjfZ/X/av2IK MCEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sgfX1eh6; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p25si7832205ejc.560.2020.07.28.04.08.17; Tue, 28 Jul 2020 04:08:40 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sgfX1eh6; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728977AbgG1LHT (ORCPT + 99 others); Tue, 28 Jul 2020 07:07:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728934AbgG1LHT (ORCPT ); Tue, 28 Jul 2020 07:07:19 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C63C061794; Tue, 28 Jul 2020 04:07:19 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id 11so18214467qkn.2; Tue, 28 Jul 2020 04:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=wLRXskVaKu10kKah7+1ZWwTzJMplfGNwKsb4sfPQ7ak=; b=sgfX1eh6PjlazK3wgSHQ415H8m+UBPUU8R3tO4ZsSmhtZdu4jQ2SlzK4HgG1G0tLVE 8tsuKH1q6TPaQ0PMrI6yt8WL1ek/r6OON4CbtPsXvG3ZfXcmoVUZ8XAliXnL14qphX2k fetgg6O4GWNMftHGuWYYAocPoHj+il/WpwHNlXoQnaXKumWPm+Lr0+s8e+qVOBJMYlsK t1Oc7wAlp/3ce4lc7aQaepamAIF/PN2KmGcLJJ8TPgiHnf+8ERMU1YNf/FeupwT3HHOO 59kSCHtT3StU0YukVuenn6vZhohK4+0W/Gov1ibxaV8Fp9X8gJbNqApnjhjosIrZtUtj KxeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wLRXskVaKu10kKah7+1ZWwTzJMplfGNwKsb4sfPQ7ak=; b=hJGeIrhXOdJF7OS091tqxZuxzD4bEv6YWf5X1gBSAwc5HtSCU72QcD1UxodOZ21ZBG FDa0Oh/b69gYISxYX77mpeZJZEfuJSnlp0odmB0LAwYC7ZAWo1rrASCqGnMUEFPhsXw8 huBuJERDALz1iRzw5M7VQl9fvROmBhre2ft6Iqwk7lx3MvsyQOZInlBlYubfY77XNry+ Q3RMekduYS6wrCxjHRyNd9iiK0eag6uj3S35UTFEN0m8NCS1zATAE0uDzdXFYJoTj+pN rC+SyDeKfaRwGcYIX4oi+c3YIMB6PHCLtRc/d9jmevbQwIAtvgVCmyUo12U4/IeqKqtX mdhQ== X-Gm-Message-State: AOAM530rfQDCqSZ8V2tssj1DqGomnWzRGrfVLbW8SOSQPjCrwK2vuaAi Bb2hjXQP8KaCOzNqHPlx5g== X-Received: by 2002:a37:8a06:: with SMTP id m6mr27080177qkd.191.1595934438341; Tue, 28 Jul 2020 04:07:18 -0700 (PDT) Received: from PWN (c-76-119-149-155.hsd1.ma.comcast.net. [76.119.149.155]) by smtp.gmail.com with ESMTPSA id g21sm10634593qts.18.2020.07.28.04.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 04:07:17 -0700 (PDT) Date: Tue, 28 Jul 2020 07:07:15 -0400 From: Peilin Ye To: Daniel Borkmann , Song Liu , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , 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 Subject: Re: [Linux-kernel-mentees] [PATCH net v2] xdp: Prevent kernel-infoleak in xsk_getsockopt() Message-ID: <20200728110715.GA407606@PWN> References: <20200728022859.381819-1-yepeilin.cs@gmail.com> <20200728053604.404631-1-yepeilin.cs@gmail.com> <916dbfd3-e601-c4be-41f0-97efc4aaa456@iogearbox.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <916dbfd3-e601-c4be-41f0-97efc4aaa456@iogearbox.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 28, 2020 at 12:53:59PM +0200, Daniel Borkmann wrote: > 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! Ah, I see. Thank you for reviewing the patch! Peilin Ye