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=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 B4839C8300A for ; Thu, 30 Apr 2020 11:23:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E46D20774 for ; Thu, 30 Apr 2020 11:23:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZNOQHT6S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727875AbgD3LXI (ORCPT ); Thu, 30 Apr 2020 07:23:08 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:40374 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726483AbgD3LXI (ORCPT ); Thu, 30 Apr 2020 07:23:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588245787; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZH79RTrqNEsWsIDtHYmP1vv8R2/Hbw946zRrNmszoms=; b=ZNOQHT6S0vAM/kiIvtg/iSbG/iQmU/oNN3DsH8nAVRQGkrHd9roKd/ngTmhf/bLulM+niL QNhgUquoFzXYbm6WqVrMG+xy/ldUTPOTmyCYqtk2EKBSZpGwe1vhK3sVpJv6ZHzlXylNvB kyt6kFvTTbb08YGYNxKD9hwcgMPIY88= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-206-97kBMGDdORy6maLutXbcVQ-1; Thu, 30 Apr 2020 07:23:03 -0400 X-MC-Unique: 97kBMGDdORy6maLutXbcVQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DDFB2107ACCA; Thu, 30 Apr 2020 11:23:00 +0000 (UTC) Received: from firesoul.localdomain (unknown [10.40.208.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03740605E1; Thu, 30 Apr 2020 11:22:55 +0000 (UTC) Received: from [192.168.42.3] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 04D23324DB2C1; Thu, 30 Apr 2020 13:22:54 +0200 (CEST) Subject: [PATCH net-next v2 30/33] xdp: clear grow memory in bpf_xdp_adjust_tail() From: Jesper Dangaard Brouer To: sameehj@amazon.com Cc: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , Jesper Dangaard Brouer , netdev@vger.kernel.org, bpf@vger.kernel.org, zorik@amazon.com, akiyano@amazon.com, gtzalik@amazon.com, =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , Daniel Borkmann , Alexei Starovoitov , John Fastabend , Alexander Duyck , Jeff Kirsher , David Ahern , Willem de Bruijn , Ilias Apalodimas , Lorenzo Bianconi , Saeed Mahameed , steffen.klassert@secunet.com Date: Thu, 30 Apr 2020 13:22:54 +0200 Message-ID: <158824577394.2172139.14338239626840236208.stgit@firesoul> In-Reply-To: <158824557985.2172139.4173570969543904434.stgit@firesoul> References: <158824557985.2172139.4173570969543904434.stgit@firesoul> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Content-Transfer-Encoding: quoted-printable Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Clearing memory of tail when grow happens, because it is too easy to write a XDP_PASS program that extend the tail, which expose this memory to users that can run tcpdump. Signed-off-by: Jesper Dangaard Brouer Acked-by: Toke H=C3=B8iland-J=C3=B8rgensen --- net/core/filter.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/core/filter.c b/net/core/filter.c index 40e749d57cc1..7af583648c8d 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -3438,6 +3438,10 @@ BPF_CALL_2(bpf_xdp_adjust_tail, struct xdp_buff *,= xdp, int, offset) if (unlikely(data_end < xdp->data + ETH_HLEN)) return -EINVAL; =20 + /* Clear memory area on grow, can contain uninit kernel memory */ + if (offset > 0) + memset(xdp->data_end, 0, offset); + xdp->data_end =3D data_end; =20 return 0;