Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4272264pxu; Mon, 12 Oct 2020 14:28:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5KdLbhyHUzh5ozVAeiccP6tJHaZKRSV4M6b2j6Q9Jx0lU+lv8hWknvGq3YjAYYJJGmOhC X-Received: by 2002:a17:906:268c:: with SMTP id t12mr29389203ejc.377.1602538137121; Mon, 12 Oct 2020 14:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602538137; cv=none; d=google.com; s=arc-20160816; b=R5Oeam7bambxvD6VKb8NUlEITFokPGTBY8gLw272kTE3Q/lqfIUnOG2Dtep9luj9JV jrJDNAzSv2YkypOxzUj655fFeZQ0f0CGzRsZ1+SLOqiN+9vDVRKIF56FCyNeD4XCV0f9 r7ynlG6p2RiHOotM9ScInFE03QB2mmDlqXj/mNZsh7x90OVS6Jzxr9u/gQMlV8z32x6I PbciN6AfRKZ7IL5BqUKTDrkippTfdQDZPHs1SV9P1acsjg/CFZUUvV/7VnDIisfGfLIx 6yHh+HX45ULW4ZiKYya84ORKReQR6rVVyOYKKjZ/2S2OkV7igOH7i/23Im2R++GTBmJd pbWQ== 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=SHXzMtHrJtYZroo9wcZAhyT0sDJEOeEwOZkJ8vK5bzE=; b=rMRVVELHfIy8AUZokBk/5mQwY+IahYjUm+rfVmWVcMavTlQpes0dAzPm64qlulYTPu CYeftJXbym3XKgQBPsAlUKfk73iSmPrM4cvrH3qfWzPyIQNePPbUPKJhZ3zcQ9SP8il4 OppoVO5/AM/AvW9xln2yssJbeOJJn7C37joepmG1A1sgyxMsm/UFBsbWg5+pB99ji725 xqvodWUXkwWC78hOohvk1WP/BKiWR8nTyNyU0Y3urJA1xWnkJ44s+QRYrrL6EFtICICC Gdl6ikaCsDy79C6F6ycaC4ShhIdG6v16yr6OBTU+KyQ/zp+V2VKiABAiOTKVW5++6Uls 6fZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J2HwSzK0; 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 x18si14800564ejd.43.2020.10.12.14.28.34; Mon, 12 Oct 2020 14:28:57 -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=J2HwSzK0; 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 S1728446AbgJLNjI (ORCPT + 99 others); Mon, 12 Oct 2020 09:39:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:42386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730291AbgJLNir (ORCPT ); Mon, 12 Oct 2020 09:38:47 -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 E252E20678; Mon, 12 Oct 2020 13:38:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602509926; bh=2UScKxsKiQ4yW6zBcZG68y9/Sr72p5mYnaR5HyUBc8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J2HwSzK0fQYeURVkjOL0k6BdZr/fEt7q7zFX4EUWdQ74vX+LhqxGvVjOMGA0u+n1a 8x+Iz7Bm/x00HakU/mvitu4pHf0K5qoyskcWJwChWY+Ahi0lBJmzsiKUJe35pAfOm6 g/7MnqSNt/UTcHbKQ4wY+JYCyguv+hUm7j1FmFnA= 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 4.19 18/49] macsec: avoid use-after-free in macsec_handle_frame() Date: Mon, 12 Oct 2020 15:27:04 +0200 Message-Id: <20201012132630.290423413@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132629.469542486@linuxfoundation.org> References: <20201012132629.469542486@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 @@ -1085,6 +1085,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 pn; bool cbit; @@ -1240,9 +1241,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++;