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=-9.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 EC30EC433E5 for ; Tue, 28 Jul 2020 05:07:36 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B1EDD2177B for ; Tue, 28 Jul 2020 05:07:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="GiEob/uU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1EDD2177B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-kernel-mentees-bounces@lists.linuxfoundation.org Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 8CA15877D6; Tue, 28 Jul 2020 05:07:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S5lvx1IdWwdz; Tue, 28 Jul 2020 05:07:35 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id ABDEA877FA; Tue, 28 Jul 2020 05:07:35 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 94EDCC0050; Tue, 28 Jul 2020 05:07:35 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 18E21C004D for ; Tue, 28 Jul 2020 05:07:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 0824A86141 for ; Tue, 28 Jul 2020 05:07:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zOsQ42EfuZnX for ; Tue, 28 Jul 2020 05:07:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by fraxinus.osuosl.org (Postfix) with ESMTPS id A314380351 for ; Tue, 28 Jul 2020 05:07:33 +0000 (UTC) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 202B32070A for ; Tue, 28 Jul 2020 05:07:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595912853; bh=julnmZ6d99C3BH6F52UlRn44Ck82VwZ9mFMWkFSJq0E=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=GiEob/uUATJb6NGdNXNRPIXJMwx5B1hmd89pvpgQ1A7bneO6GstY8d5UUx/Xzh3cX rTw+eqI8jlyDCvT8aDqgDW2shNnG1Ip+L41mIssxsr9WnhIF264dq+dfevQdECGoYd IBJsfXYE+eCnZir5jQMZr1HGV8XIwIL9uKm2aL48= Received: by mail-lj1-f181.google.com with SMTP id t6so6760481ljk.9 for ; Mon, 27 Jul 2020 22:07:33 -0700 (PDT) X-Gm-Message-State: AOAM530Q4F6u10PQjtVurRuGGckJxkdyOqZju+SRlnKLu//NlERa5lih sx3VtB5xMK5bAJthL+GScv6kXaRbBEL4UlcqxJI= X-Google-Smtp-Source: ABdhPJytszNTur7+L8yYaMkkhh+bgs5XLkap0KlVaVnWI6a+xCWLQT4+KIxYTOVT5ftgIxWwP5luaCd2mGdDBu/bXb8= X-Received: by 2002:a2e:9996:: with SMTP id w22mr12656350lji.446.1595912851449; Mon, 27 Jul 2020 22:07:31 -0700 (PDT) MIME-Version: 1.0 References: <20200728022859.381819-1-yepeilin.cs@gmail.com> In-Reply-To: <20200728022859.381819-1-yepeilin.cs@gmail.com> From: Song Liu Date: Mon, 27 Jul 2020 22:07:20 -0700 X-Gmail-Original-Message-ID: Message-ID: To: Peilin Ye Cc: Song Liu , open list , Daniel Borkmann , Arnd Bergmann , John Fastabend , Alexei Starovoitov , Martin KaFai Lau , Yonghong Song , linux-kernel-mentees@lists.linuxfoundation.org, Networking , Magnus Karlsson , Jonathan Lemon , KP Singh , Jakub Kicinski , bpf , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Andrii Nakryiko , "David S. Miller" , Dan Carpenter , Jesper Dangaard Brouer Subject: Re: [Linux-kernel-mentees] [PATCH net] xdp: Prevent kernel-infoleak in xsk_getsockopt() X-BeenThere: linux-kernel-mentees@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-kernel-mentees-bounces@lists.linuxfoundation.org Sender: "Linux-kernel-mentees" On Mon, Jul 27, 2020 at 7:30 PM Peilin Ye wrote: > > xsk_getsockopt() is copying uninitialized stack memory to userspace when > `extra_stats` is `false`. Fix it by initializing `stats` with memset(). > > Cc: stable@vger.kernel.org 8aa5a33578e9 is not in stable branches yet, so we don't need to Cc stable. > Fixes: 8aa5a33578e9 ("xsk: Add new statistics") > Suggested-by: Dan Carpenter > Signed-off-by: Peilin Ye > --- > net/xdp/xsk.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c > index 26e3bba8c204..acf001908a0d 100644 > --- a/net/xdp/xsk.c > +++ b/net/xdp/xsk.c > @@ -844,6 +844,8 @@ static int xsk_getsockopt(struct socket *sock, int level, int optname, > bool extra_stats = true; > size_t stats_size; > > + memset(&stats, 0, sizeof(stats)); > + xsk.c doesn't include linux/string.h directly, so using memset may break build for some config combinations. We can probably just use struct xdp_statistics stats = {}; Thanks, Song > if (len < sizeof(struct xdp_statistics_v1)) { > return -EINVAL; > } else if (len < sizeof(stats)) { > -- > 2.25.1 > _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees