Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4342442pxu; Mon, 12 Oct 2020 16:54:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmlS7XuuI+gOnXqcMP1R1FF0pCPIzEFpUEmU6iakUcJJyT3Jotitp39OpYSk9kGsDa/prN X-Received: by 2002:aa7:db82:: with SMTP id u2mr17439901edt.262.1602546844832; Mon, 12 Oct 2020 16:54:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602546844; cv=none; d=google.com; s=arc-20160816; b=TWXyZ9hedehWVfM/tVVlpu/Ssw9r5Aym4xZaJ8CdYyp3a7M7yFrQ3ZSDFGkacr63gf +U4qQZ6j85isqZPNAvpydQ2ZsxqqINPlvTa2xThuUZMz+wp15nprRpKtTejy2B81I2QY e7BRAsuTG0ac/MS2yAo3a3SYDdbjSHjINfk6I8DtlAuHvN6/uCR0RDJfHapIEWD2b+kt VSs9axSg9u1xE0DCFVyZArSrBNgXuOzDha/kTdVfrJV6Lh85s6W1Deggk2NC8FkwJApp p145SnguL7z4bhrZXDmrqZZWodWhvjFo9L/uhEwvKAzUghlyc76umWiAKUWnkaLK/Ayq aT4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WghWqafsnaazhWmbvQPCY99Yn38gl9j8ZGK4HxUfz7c=; b=SvIIPU4r9MHTo1ZLBKF8YsPxuqkoJRffmmWde234Chkxfa1cwShVMRNsIaYrfcmzb4 dyWOt3AUIPqp3NqRdRzwYak/z8xeneHjFlAuuV3esCDn/bM9UTZhF4cscRmKUfNdk9jM Jj9V874LWVYKNE90Gn6mokj7Qij1boN2NhUj369KVmyjB7Az9sdRZaz6jPfBWXibhHqi T33HX/3Nuku5dMZysPrXiSMQoNJWuErx8teUt3BW2bZqdI4vTxaw61X6GzLohRmXH8KO TD7nQh1e2OwoWChg81kpVjtvniHMEDnDJEl2LmcYaiYpx/prZAjzQUzIx1jnYuh28eLl uhZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kd70q63x; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si2195146eji.277.2020.10.12.16.53.42; Mon, 12 Oct 2020 16:54:04 -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=@kernel.org header.s=default header.b=Kd70q63x; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390457AbgJLNzK (ORCPT + 99 others); Mon, 12 Oct 2020 09:55:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:47388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389676AbgJLNpn (ORCPT ); Mon, 12 Oct 2020 09:45:43 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 CFA9C22267; Mon, 12 Oct 2020 13:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510269; bh=kLgP74XDZOeHGEXeKldGAeWP/IgRb+BJcNdw6TDIAtQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kd70q63xhMKgTkBVJSZ6boMPbh5wG1MQKstK9COwwC89eAhoULpSt2XGzJPX89y9P f8zS85YRhwdgLSKL71QpYTbQH3opy9W5skH1yet+HTvfMlfJeo2d0lQkdkuzMe30pj eZoYC5K4O3owVncGsW4wH2eWH4hqs3dzRWcVOPE4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Paolo Abeni , Jakub Kicinski Subject: [PATCH 5.8 027/124] macsec: avoid use-after-free in macsec_handle_frame() Date: Mon, 12 Oct 2020 15:30:31 +0200 Message-Id: <20201012133148.161197400@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012133146.834528783@linuxfoundation.org> References: <20201012133146.834528783@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet commit c7cc9200e9b4a2ac172e990ef1975cd42975dad6 upstream. De-referencing skb after call to gro_cells_receive() is not allowed. We need to fetch skb->len earlier. Fixes: 5491e7c6b1a9 ("macsec: enable GRO and RPS on macsec devices") Signed-off-by: Eric Dumazet Cc: Paolo Abeni Acked-by: Paolo Abeni Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/macsec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -1077,6 +1077,7 @@ static rx_handler_result_t macsec_handle struct macsec_rx_sa *rx_sa; struct macsec_rxh_data *rxd; struct macsec_dev *macsec; + unsigned int len; sci_t sci; u32 hdr_pn; bool cbit; @@ -1232,9 +1233,10 @@ deliver: macsec_rxsc_put(rx_sc); skb_orphan(skb); + len = skb->len; ret = gro_cells_receive(&macsec->gro_cells, skb); if (ret == NET_RX_SUCCESS) - count_rx(dev, skb->len); + count_rx(dev, len); else macsec->secy.netdev->stats.rx_dropped++;