Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2096376ybl; Thu, 30 Jan 2020 11:17:27 -0800 (PST) X-Google-Smtp-Source: APXvYqyUnhJDBz/vqKX7s+aZ6OZRBz3ZKN9trLgaMx0OXcgJgRv8fP0IxMWNu03SUw9aggzV78gP X-Received: by 2002:a9d:4e99:: with SMTP id v25mr4861800otk.363.1580411847548; Thu, 30 Jan 2020 11:17:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411847; cv=none; d=google.com; s=arc-20160816; b=mQ2VpXPvw84c0n3lWUe2hKQ+oK0JiOR5a8t1GnopDjfPsrJ1FVhhKz5P1PNeOYvmMM IXaqs9iJ5iipMV9CIaAkz/ae1Ro8jPHnYnjT/PSYKlFYXZR1Vr2MqmFlQYbZ8Kewhqex DWTuhPHVgXVUJbThcRnee6dwStwOxGlzewD3mPVb0/GAbcLK+wecugsCIOwFFXBmSIXn FIWu0/OMS2GlA/jk9UMdCD1f8FCUVgQJmfpOti5KyKER5NoOC0NXnBOXkJ7vx/0HPmtc 6yb14tBthXt3hBi2fxq1pJfhvxYL7lDediWWDuDHWu7exHDa2EZs/ZNmBbn0aJpTof6j ZHGA== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ivKR2UsjH5c2N7Ji4LqMnYzvfTOLZmjn/Cf91xqbE60=; b=wCSs0KHBLJsSX7C822kgbn+4UBLSazIhInbwM4hnUdghxs3uuOY3bKbD3Z24JPLtFz ZwoXXADMvufelJhOpt+eKrLZgtL5UiQnc2ivgQfoLk0M3jVMGyV39xRY83ziPawKE2PS GtKzmBtzGz63//9nosWf0/ns73ibuxw+LRBmVxA7q28lQNyQfnbawIkYwvJ00kCIUUh3 EKesGNpQY5j+mSrgrUuJKej77IBYZNBIXj2Dn0gpNkj8MRl8AFYqTqXetAb/LnI6j+ex /sN/SIciyjs/QPC8d3LNmbNZPfG728MSJQxKozZaG0fsINjElRb4CwC//XkXE2c5aFQ6 +ykA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M+L2P7pj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u1si3669619otg.113.2020.01.30.11.17.15; Thu, 30 Jan 2020 11:17:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M+L2P7pj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730620AbgA3Sn3 (ORCPT + 99 others); Thu, 30 Jan 2020 13:43:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:52084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730606AbgA3SnZ (ORCPT ); Thu, 30 Jan 2020 13:43:25 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3BA9F20CC7; Thu, 30 Jan 2020 18:43:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409804; bh=umTeR8oIiJjmU04XF6OMoKh/l1/mt83qwBM0dTA8Rd4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M+L2P7pj4TtTnHhM68FaAc7OOSWvntPJk9CXDgIiABDKxZzif5SXES9k/s5/ZZImr BP5ZDNUMAEZzudKa8axMiP/6rf2Vh4XneoaYhXB0+xuupn9HzP72VApmyqauatti9R kDgjgyEYdkTcgFiU742ZvmHmCeCPKq9lTB35jyw4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Jesper Dangaard Brouer , Ilias Apalodimas , "David S. Miller" Subject: [PATCH 5.4 038/110] net: socionext: fix possible user-after-free in netsec_process_rx Date: Thu, 30 Jan 2020 19:38:14 +0100 Message-Id: <20200130183619.890025567@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183613.810054545@linuxfoundation.org> References: <20200130183613.810054545@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lorenzo Bianconi [ Upstream commit b5e82e3c89c78ee0407ea8e8087af5519b6c7bae ] Fix possible use-after-free in in netsec_process_rx that can occurs if the first packet is sent to the normal networking stack and the following one is dropped by the bpf program attached to the xdp hook. Fix the issue defining the skb pointer in the 'budget' loop Fixes: ba2b232108d3c ("net: netsec: add XDP support") Signed-off-by: Lorenzo Bianconi Acked-by: Jesper Dangaard Brouer Acked-by: Ilias Apalodimas Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/socionext/netsec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -928,7 +928,6 @@ static int netsec_process_rx(struct nets struct netsec_rx_pkt_info rx_info; enum dma_data_direction dma_dir; struct bpf_prog *xdp_prog; - struct sk_buff *skb = NULL; u16 xdp_xmit = 0; u32 xdp_act = 0; int done = 0; @@ -942,6 +941,7 @@ static int netsec_process_rx(struct nets struct netsec_de *de = dring->vaddr + (DESC_SZ * idx); struct netsec_desc *desc = &dring->desc[idx]; struct page *page = virt_to_page(desc->addr); + struct sk_buff *skb = NULL; u32 xdp_result = XDP_PASS; u16 pkt_len, desc_len; dma_addr_t dma_handle;