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=-4.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 2D007C41604 for ; Wed, 7 Oct 2020 14:46:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC453212CC for ; Wed, 7 Oct 2020 14:46:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="f4vrDl15" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728698AbgJGOp7 (ORCPT ); Wed, 7 Oct 2020 10:45:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56259 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728663AbgJGOp7 (ORCPT ); Wed, 7 Oct 2020 10:45:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602081958; 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=Fnb5nkSzHmdj0EZqMF1MCuYhoEgksBdco1M0vT+a7t4=; b=f4vrDl15prijRw14oHrzXrfPmMaoDB8AP1x6gBs6Y+GmHiHCAPSadgf9hjS5AOkId7Jw+7 xnZnqhTXTPhVLcHtzP3E4p+kz16xpz0u9UTmqA+OAw8GZMqb/yDflyagCPLDVHZlgy1Bn7 esTZfhUyFacBDjA6yyJ2aAnmtAdJByg= 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-386-E4PSZWEgN_CqWqxrDXUDzw-1; Wed, 07 Oct 2020 10:45:54 -0400 X-MC-Unique: E4PSZWEgN_CqWqxrDXUDzw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79D93805EFB; Wed, 7 Oct 2020 14:45:53 +0000 (UTC) Received: from ovpn-112-245.ams2.redhat.com (ovpn-112-245.ams2.redhat.com [10.36.112.245]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FFF05577A; Wed, 7 Oct 2020 14:45:52 +0000 (UTC) Message-ID: Subject: Re: [PATCH net] macsec: avoid use-after-free in macsec_handle_frame() From: Paolo Abeni To: Eric Dumazet Cc: Eric Dumazet , "David S . Miller" , netdev Date: Wed, 07 Oct 2020 16:45:51 +0200 In-Reply-To: References: <20201007084246.4068317-1-eric.dumazet@gmail.com> <4544483dd904540cdda04db3d2e2e70bad84efda.camel@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, 2020-10-07 at 16:31 +0200, Eric Dumazet wrote: > On Wed, Oct 7, 2020 at 4:09 PM Paolo Abeni wrote: > > Hi, > > > > On Wed, 2020-10-07 at 01:42 -0700, Eric Dumazet wrote: > > > @@ -1232,9 +1233,10 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb) > > > 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++; > > > > I'm sorry I'm low on coffee, but I can't see the race?!? here we are in > > a BH section, and the above code dereference the skb only if it's has > > been enqueued into the gro_cells napi. It could be dequeued/dropped > > only after we leave this section ?!? > > We should think of this as an alias for napi_gro_receive(), and not > make any assumptions. > Semantically the skb has been given to another layer. > netif_rx() can absolutely queue the skb to another cpu backlog (RPS, > RFS...), and the other cpu might have consumed the skb right away. Ah! I completely missed that code path in gro_cells_receive()! Thank you for pointing that out! Acked-by: Paolo Abeni