Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp54194ybg; Mon, 27 Jul 2020 23:14:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFq3mhQHOKBJuXAIZ6mN49Ga76dfO9Wibsm7T6Fb62s3wy3/4F1l1vImaeqsUR2hDgZ2uu X-Received: by 2002:a17:906:3449:: with SMTP id d9mr4289733ejb.460.1595916842891; Mon, 27 Jul 2020 23:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595916842; cv=none; d=google.com; s=arc-20160816; b=hk/1/LLccXTWvJY78q9Az1lXuxcKV7oHSYvNxGH7o6Yhf6ndlKwzvu44JGPt4i+o3k 4rP+lfVhCPPy47OVXEaOMgFQJVCtv+5HXKv+DA9rXl/f1r2PNK+xaRs+eGCBF5JC8cvH HgHe5kXqdXwsAbxKNsz+mSZWVbl8fKB3PN0ws9yoUuT22qnw9u06Xc5cMW2AEuFNdiWr gA3bL3q5oLiWO83GlSpk1LB5Q8m0c+ikfN1CYJIOmfBplCjYENAxEnUS4b61yB6DjO/n kkzpzjK/htzAxemfHFkj2i7qE0yE8/PoxwZUKvcbuBRR/zxZRYNmfp+hadmfOPOIeMWP xOqA== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=2LOYqENCC/eIrr+vps1mwgcYedxxXRrO5H846Z3NgUo=; b=DGYzjN4+SK8mjPQST1GVb1AqUIF5pmKAqScFQ49tr12Vj8VeDxxr4bSayLk61Zoas1 Z5Y56bwClxw1HeamgLk6D7qEXEhLivjR6GsxProL7tswU1mQHVA5H0WDJR1amh53ufkJ HHK6TxWXsidJUn4KwDp2uUm0gYMb75rrtRbDKcwnUAahqSUhryiD2lS8RFmr86thr7sn q2xo7/cR+SwhO3vBr6/3PkRBxQEk+OvhaZm69SCy9I8xZ8G8TkKtmtsG55rUk24tA/47 pt/OP2JNwTtB5hGP8kNYnvcrwe1wKUO8vuqnajC8NLzRddt6IyFRZEIsYWOTTC445ypf GZ+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mbl+AJvV; 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 d9si6717235edv.44.2020.07.27.23.13.40; Mon, 27 Jul 2020 23:14:02 -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=mbl+AJvV; 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 S1727772AbgG1GNQ (ORCPT + 99 others); Tue, 28 Jul 2020 02:13:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726407AbgG1GNP (ORCPT ); Tue, 28 Jul 2020 02:13:15 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69D31C0619D2; Mon, 27 Jul 2020 23:13:15 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id k8so6612155wma.2; Mon, 27 Jul 2020 23:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=2LOYqENCC/eIrr+vps1mwgcYedxxXRrO5H846Z3NgUo=; b=mbl+AJvVCtxBnMFq8DuuLlqHTL4gHyTbIOttBv3k953y68Z+1ntGiEJRFlYBKXDUxq at3beMmZ4nYgwETfxeHttu1lrrMnXw0cW8mc5UZO/1PcdRAhE7gdK6GdySWKB4TKOJxU 9q9X9YSryZesE2SCSJhjQXwims5fwEE5U5FGQeR8kMT28xrUEy70mSktfOGDPA9BvZVN yZR3DqusSGWjbi/CwYdY8K4YbMJm1Od95W/nts2/h/sbinAi1cFhnkpDhiL5lsJZtyU5 ILD5h9KIxEIMzfohPLpXsk69jBNUJsrgRx+VaRWT1O8A7dc42EcIMrP9QRJ6aLns3yH2 Z7KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=2LOYqENCC/eIrr+vps1mwgcYedxxXRrO5H846Z3NgUo=; b=HKzM7HcTey2Dr56NJkhtooWZtHBFVF6BFu6uRmdxjPdsvMOeNANOJHDlrm/vry+ujx GdFl5hq+W5uXSQU8OK5KWoYgnKTbn/1BHujUccdP98R2JBgjvI2/gb90MwFOgJ2+yM5s 73sBbr8H8FkEvWaq8GJcJXwMwaC0d6Pn0QlEEoAZOdOmV316AzmrIUh+SnAfa5SxzrWA /Al46VM+wXS9JOdjYqO/mPv+2aYagWHhX7wmO2ULaT+Qy8oBC3iWvQHsdtfIODUHXViX xjLdpwBj2JhWkuOiFkSbd4MgZQOX/MH43jFdBaoMsjLEBR0VmCqa2n8C5WxCpGD/gXXa cJFQ== X-Gm-Message-State: AOAM5325uoe0nKCV5kVyjNFtemZ2uWpoxNFH7J2XUlDNHaGUDM0tzhFb ibhIoubV7X9xD+lAB63iE+Zql8TpyusZrNr2ikY= X-Received: by 2002:a7b:c857:: with SMTP id c23mr2586762wml.155.1595916794109; Mon, 27 Jul 2020 23:13:14 -0700 (PDT) MIME-Version: 1.0 References: <20200728022859.381819-1-yepeilin.cs@gmail.com> <20200728053604.404631-1-yepeilin.cs@gmail.com> In-Reply-To: <20200728053604.404631-1-yepeilin.cs@gmail.com> From: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= Date: Tue, 28 Jul 2020 08:13:05 +0200 Message-ID: Subject: Re: [Linux-kernel-mentees] [PATCH net v2] xdp: Prevent kernel-infoleak in xsk_getsockopt() To: Peilin Ye Cc: Song Liu , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Jonathan Lemon , Dan Carpenter , Arnd Bergmann , Greg Kroah-Hartman , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Martin KaFai Lau , Yonghong Song , Andrii Nakryiko , KP Singh , linux-kernel-mentees@lists.linuxfoundation.org, Netdev , bpf , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 Jul 2020 at 07:37, 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 > --- Acked-by: Bj=C3=B6rn T=C3=B6pel > Doing `=3D {};` 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. > > Changes in v2: > - Remove the "Cc: stable@vger.kernel.org" tag. (Suggested by Song Liu > ) > - Initialize `stats` by assignment instead of using memset(). > (Suggested by Song Liu ) > > net/xdp/xsk.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c > index 26e3bba8c204..b2b533eddebf 100644 > --- a/net/xdp/xsk.c > +++ b/net/xdp/xsk.c > @@ -840,7 +840,7 @@ static int xsk_getsockopt(struct socket *sock, int le= vel, int optname, > switch (optname) { > case XDP_STATISTICS: > { > - struct xdp_statistics stats; > + struct xdp_statistics stats =3D {}; > bool extra_stats =3D true; > size_t stats_size; > > -- > 2.25.1 >