Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6249191iob; Tue, 10 May 2022 13:58:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvRNfIuIWAUQ6lZkgdrJravOFgDPL5tm0veid7EaWBckeQZRXW7EO1nbpYztvT2ptjS5Id X-Received: by 2002:a17:907:6d1e:b0:6f9:ffbd:477a with SMTP id sa30-20020a1709076d1e00b006f9ffbd477amr12866536ejc.104.1652216286231; Tue, 10 May 2022 13:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652216286; cv=none; d=google.com; s=arc-20160816; b=i2+QlgqIvQJkIR6O/cTn9H7Sbv2OpmiYZoZWHPGTivcakY/8nlvdSRP4afUcO5rxMl arAs8zZpjV5aYuMK8brgar5psNzJByK/Apqexarb/GVKPMdAmoj4pNsfo8WiSN8rRsMg KKBdH/IX1yIP7FpEEYK8St5HaGsRtqSw383FGOP9jitjuBGAMlX49UsjOHSfceiQxW+e hFIMLH15fhXxQcSrf/AEi/AG0peucjPw0kNADyTz1t3LGXDMRlwXWxzcp6kYfvdxpWC0 pH+Se64JVczm1uDoN480zOqZQW4fvBghmYguSRxz7y6EcT4anmpTfMlW2fE7Xo/Endjr RB6Q== 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=Z9RTv/0HaSEu6nuQW1CiTZekATNHg4+cf1/Vhp74H7/NRWpiqJFpfJgZaSRdicKJKx U6T7Y2L36GsTF4YyYXNC6lvq/dy4YmMgxBUJwWoP7qmjNYrR6HBFQaPekuljrUTdvNI9 o9OUE1T7P8hEq/tGeXWcax+jTpjx2MncLFO9D4melZBQvTVNILsQ4zDBFOFRyogLIR7o ZoCfQTudASRg8kHMj2vsrefAXXzse3zkqJSIHobB4CY67aEgE9qBfNnGYx+2YozPy9Rp ruTrfMwag/mcIe3OfBRA/ITM4LaW1FKe5ovAfcnKXSZynFmQEYnAwbU3bDKy13ldj+o9 8RVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=F0mAqS3Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b6-20020a056402350600b00425f7ca0ce9si275612edd.505.2022.05.10.13.57.42; Tue, 10 May 2022 13:58:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=F0mAqS3Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243111AbiEJN21 (ORCPT + 99 others); Tue, 10 May 2022 09:28:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243203AbiEJNVj (ORCPT ); Tue, 10 May 2022 09:21:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E0792C183F; Tue, 10 May 2022 06:15:11 -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 ams.source.kernel.org (Postfix) with ESMTPS id 725C2B81DAA; Tue, 10 May 2022 13:15:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E598FC385A6; Tue, 10 May 2022 13:15:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652188507; bh=VtJerBDQCYbUCgpxXLdGU8t1nlWfii6eDosdmY9hF0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F0mAqS3Zfdi0NS+57tmp/Q0jyInaDB6RGYUuVqrp2LMIz1SvBIXQ8mMedhHM2LajV 678Aw2yC1B/7sZlGdl1AegAO78Y9pz+NKDXYibSHHH39jcC77Yy4q2cDPXEygMJpZ2 Acjk3Zn63yMEH0xemsXLKDFsrdMkpx68Bw6c/kRA= 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 4.14 03/78] hamradio: remove needs_free_netdev to avoid UAF Date: Tue, 10 May 2022 15:06:49 +0200 Message-Id: <20220510130732.628205315@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220510130732.522479698@linuxfoundation.org> References: <20220510130732.522479698@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=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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;