Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4642489iob; Sun, 8 May 2022 20:19:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhCMf+P6aFXOaok9hQH4WZ2XuPv8Gu7uEPbJCvsQ2y+gVQANlKGfs7xMzW7Orhk8PmxxYE X-Received: by 2002:a63:1a01:0:b0:3c2:1974:1686 with SMTP id a1-20020a631a01000000b003c219741686mr11578479pga.595.1652066392710; Sun, 08 May 2022 20:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652066392; cv=none; d=google.com; s=arc-20160816; b=HpXjKf7oB3iMk8kyRRoRGb7YQy0FRKGKNYDfxxVLKBe6LT0N8uOPzfh/Mc2UpE8Ja8 5UVAevksviLJRk3QqlK2qa6tvx8qK5VFjWpWnq9KoDy48Sa5a243fC9dzawuh63AhAyd fu4j/cy7TF44ibdmvTXdhF59HPSmzssJdIJLu5yxxaNR/Lhn6Tg7GKzxQPJmPb146hWc PXEilA1i5jK4wAKnmvMOpEx2yNq+502zobl37QPGYMsmm4KWbm6wOmN6JHYVl29mERWE dcyPe+5fowzcGqJ51cAUzat0Y0d7ydOOK1uJ+ZQx+PzGkpyW40KboEcz3fLxutUhNNfr cqHQ== 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=N7u97OY99tOx15q0zf5siXSIVycfXsrUWIyPbJl4U3o=; b=xeWifEsT2oiKBCcUrWa969mxlHGJOtaYBDIPTG6VpOerGEs1m8En/v0awxh1IqgkN4 nq5I4TzvSfPdfdbIxL6VmR+hc791kglsXKT/zjZfvt0VGS4qjvJftN69MfWdMIKwp2Pn TEX1lwSOhxAy9j/MbrrumApHh0i+Od9/QKeEpGDV10T4mNfNeAdYwzxgHylJPdPxd82Z NEGNlgCzynfJEwr3wa0+o9708M1+rJlM9pvLMp9fXAmUG8pccbOIFOBHEo7Ax8mHY+Xx Opvem+SYSlDA881lKNgwOyGnlgBtzHGnHsFQnO3ULO+ZCCDsAFLqdew3BanfwI22J/O9 zBmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=utthZ9CZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l16-20020a62be10000000b0050d434ae30csi11133303pff.217.2022.05.08.20.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 20:19:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=utthZ9CZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1017F986EF; Sun, 8 May 2022 20:19:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353705AbiEDQwR (ORCPT + 99 others); Wed, 4 May 2022 12:52:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353644AbiEDQv4 (ORCPT ); Wed, 4 May 2022 12:51:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E66D746B03; Wed, 4 May 2022 09:48:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 790526174B; Wed, 4 May 2022 16:48:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCDC1C385A4; Wed, 4 May 2022 16:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651682896; bh=VtJerBDQCYbUCgpxXLdGU8t1nlWfii6eDosdmY9hF0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=utthZ9CZETq++VVWtdVAXfYSkj14Xieers63trhoj4q/ITccm1B44xTneu4qADs1d F+Ri0BmpLHpU82dlu3nSc1ON49h9bztPuU+6NfiPwuwySC8Ubk5bQrXTrT6V6+1o47 OqR70mK7rcplVXf6htRIU0SkPGni9iBggvZq8cm8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lin Ma , Jakub Kicinski , Ovidiu Panait Subject: [PATCH 5.4 03/84] hamradio: remove needs_free_netdev to avoid UAF Date: Wed, 4 May 2022 18:43:44 +0200 Message-Id: <20220504152927.990766404@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504152927.744120418@linuxfoundation.org> References: <20220504152927.744120418@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lin Ma commit 81b1d548d00bcd028303c4f3150fa753b9b8aa71 upstream. The former patch "defer 6pack kfree after unregister_netdev" reorders the kfree of two buffer after the unregister_netdev to prevent the race condition. It also adds free_netdev() function in sixpack_close(), which is a direct copy from the similar code in mkiss_close(). However, in sixpack driver, the flag needs_free_netdev is set to true in sp_setup(), hence the unregister_netdev() will free the netdev automatically. Therefore, as the sp is netdev_priv, use-after-free occurs. This patch removes the needs_free_netdev = true and just let the free_netdev to finish this deallocation task. Fixes: 0b9111922b1f ("hamradio: defer 6pack kfree after unregister_netdev") Signed-off-by: Lin Ma Link: https://lore.kernel.org/r/20211111141402.7551-1-linma@zju.edu.cn Signed-off-by: Jakub Kicinski Signed-off-by: Ovidiu Panait Signed-off-by: Greg Kroah-Hartman --- drivers/net/hamradio/6pack.c | 1 - 1 file changed, 1 deletion(-) --- a/drivers/net/hamradio/6pack.c +++ b/drivers/net/hamradio/6pack.c @@ -311,7 +311,6 @@ static void sp_setup(struct net_device * { /* Finish setting up the DEVICE info. */ dev->netdev_ops = &sp_netdev_ops; - dev->needs_free_netdev = true; dev->mtu = SIXP_MTU; dev->hard_header_len = AX25_MAX_HEADER_LEN; dev->header_ops = &ax25_header_ops;