Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp315950lqh; Mon, 6 May 2024 22:53:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWhrW2qYcCoAnb5DjZ6Ng9huUDVbKuxwB1/MPU0vPB3KzqEpZYB5yYykL0DQgseCcOBasg6Yc8E43vvpfMM4JnzLVKGc3JAVtUw8jocCQ== X-Google-Smtp-Source: AGHT+IFaHIlenhNEdofgDaA89BrYxBAOzeLKZm8+cctptWohswhIbGsfACBKJaDSwSp/jN8VM7Sm X-Received: by 2002:ae9:c20a:0:b0:790:f2dc:8b73 with SMTP id j10-20020ae9c20a000000b00790f2dc8b73mr12130604qkg.55.1715061217802; Mon, 06 May 2024 22:53:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715061217; cv=pass; d=google.com; s=arc-20160816; b=owjGRTiaiJ9KLYq43E7DKLAPdqi0UwATBr+r6equljVPFVmKnfiY3uVy1MXzrm0zOT G/htOfxnbhMKDjHdCGnhPQv1QeBfOiqwlrZ/pjM4NH6KU6pXRhuyTBDuxRUa4YPcE0Ou keQWBB02/MWSDvK3ovqVqGhwbIbAhUcU92kOsefWM4KmJxvoqHq4zblLXVv7/AWziSQo a0WT1ASaHVyWsa3E6zUzNbES+Yypee9x+cf6JLU2Ecql0o6gY1BpYtC87G6K+kqTkzTQ ycis4iScHZyhu5233jMgWKAJvwhGIjDmVl/x7WqhqenL9MtS4gSjvBMFODsGxClZ4bHX OtsQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from; bh=zLROhE25gborKo+DdxGWwS8rolaFnTLRP/yLhFsCbKY=; fh=IE3AZvDm9DC3cdTbYv1PuJ+zr4mdKz6MWG85KR/OiZ4=; b=HsGDHN4DuCKCYI8PwB7srtqePZfVw6oBle8fWUNlOtYpyYPBkSHmBSxRECysBzr5Q9 OLdtLy4bm32IZUX2AWKsf3jWySt8/SRIuyQmvNY4h1g6OnX4o8wIEnqQSg78bHu2JLFI Ps/axRSoP88Rb6Tqy1ltz115Ucq6PkZtqCcg3+oWumDzHxymdolgiX8+9ff8KsDxNthp AhJ8nvD4xr+clMNAYTQM9JhMCxbokA3W4XjdgI7wiDjuZEDpkqs2d515I/9JIoILBK/l gAE5CIG7najOKwSgvNdZcSVTqAWs3LbO8ORPzmLjNjmY94BF2GUkAAQGpD14jBTv6mPd YKkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-170710-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170710-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s9-20020a05620a29c900b0078d6f24ddeasi11607499qkp.638.2024.05.06.22.53.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 22:53:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170710-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-170710-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170710-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5EBA11C210ED for ; Tue, 7 May 2024 05:53:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7D1E6FE07; Tue, 7 May 2024 05:53:16 +0000 (UTC) Received: from zg8tmtu5ljy1ljeznc42.icoremail.net (zg8tmtu5ljy1ljeznc42.icoremail.net [159.65.134.6]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 688EE6BFA9; Tue, 7 May 2024 05:53:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.65.134.6 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715061196; cv=none; b=Kj6stmRptagxePBVAUA9Um5Sj6dt7BehIPL6qNG4BwD8Fz/OMGWuUWyUttFGlVd1ciRJhgIlES65v9lxUV8eFRyXYyEeH5edj83fG51CI1yOO7ON34QPy9nk9l4W1mGp5BQLjAAm3FoIotMv7zWwGT5r/ZXKbHfLZu9UMm+LGB8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715061196; c=relaxed/simple; bh=uY/f2XxADkXUxf5Kne/3qFuas5cvVQzyqm+DbipD+Vw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=tTztVvw4HoBEjcVzDxUGSUJAOHnRZC9y0+8VOdy2ZogJZUs2LnVA6DtMRvGLsdClyxSr6Rx4PYCp9Ckq0l3vTsVfNfMnBQ0ETkrfogCw1Bf72qKIggZ68Ia4OHDqC+YcglLDyOOGgLGtSHipj8jv8fblsYeJiGI2dIqOM/E+c7I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn; spf=pass smtp.mailfrom=zju.edu.cn; arc=none smtp.client-ip=159.65.134.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zju.edu.cn Received: from ubuntu.localdomain (unknown [221.192.179.90]) by mail-app2 (Coremail) with SMTP id by_KCgBH0Z+3wTlmoTRDAA--.41006S2; Tue, 07 May 2024 13:52:58 +0800 (CST) From: Duoming Zhou To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-hams@vger.kernel.org, pabeni@redhat.com, kuba@kernel.org, edumazet@google.com, davem@davemloft.net, jreuter@yaina.de, horms@kernel.org, Markus.Elfring@web.de, dan.carpenter@linaro.org, lars@oddbit.com, Duoming Zhou Subject: [PATCH net v4 4/4] ax25: Change kfree() in ax25_dev_free() to ax25_dev_put() Date: Tue, 7 May 2024 13:52:55 +0800 Message-Id: <7fdad05adf75ab7e2f6aad4d4c596e0361ce55dd.1715059894.git.duoming@zju.edu.cn> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-CM-TRANSID:by_KCgBH0Z+3wTlmoTRDAA--.41006S2 X-Coremail-Antispam: 1UD129KBjvdXoWrZFy3Gr4DGFWrJw4kGFW3KFg_yoWfXFg_uF ykCF4xWw1UJFyUCw1rCF4rJrW3Ww1Ygwn3JryfAFZ7t34jya4UJrWkWr1kXF1UWrW2krWS qrn5ZrWfAr43tjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbTAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr1j 6rxdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r126r1DMcIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7MxkF7I0En4kS14v26r1q6r43MxkIecxEwVAFwVW8WwCF04k20xvY0x0EwIxGrw CFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE 14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2 IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UMIIF0xvE42xK8VAv wI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14 v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUO3kuDUUUU X-CM-SenderInfo: qssqjiasttq6lmxovvfxof0/1tbiAwMOAWY4-AkEPQBDse Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The object "ax25_dev" is managed by reference counting. Thus it should not be directly released by a kfree() call in ax25_dev_free(). Replace it with a ax25_dev_put() call instead. Fixes: d01ffb9eee4a ("ax25: add refcount in ax25_dev to avoid UAF bugs") Suggested-by: Dan Carpenter Signed-off-by: Duoming Zhou --- net/ax25/ax25_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ax25/ax25_dev.c b/net/ax25/ax25_dev.c index 05e556cdc2b..d4d29879df2 100644 --- a/net/ax25/ax25_dev.c +++ b/net/ax25/ax25_dev.c @@ -194,7 +194,7 @@ void __exit ax25_dev_free(void) list_for_each_entry_safe(s, n, &ax25_dev_list, list) { netdev_put(s->dev, &s->dev_tracker); list_del(&s->list); - kfree(s); + ax25_dev_put(s) } spin_unlock_bh(&ax25_dev_lock); } -- 2.17.1