Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp318919lqh; Mon, 6 May 2024 23:02:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWFi7p9cqVbQRFqweexcG5lAUS7UB8iLS7E/KMQoU6fCW54kr2Cj4QAAWCjrqflu9DFkCWSPTJmViTDl4Lwlb/iDKg/G6PIcBqHRXMEgQ== X-Google-Smtp-Source: AGHT+IFlbff5qPWZld9XeU7btXAanoOwoMEKJrYXEtTpkNMfCXKgyJyjDYtYuMSd1fAojsfoG/i+ X-Received: by 2002:a4a:ab47:0:b0:5aa:4d23:9114 with SMTP id j7-20020a4aab47000000b005aa4d239114mr13922403oon.3.1715061732204; Mon, 06 May 2024 23:02:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715061732; cv=pass; d=google.com; s=arc-20160816; b=JYBkz96JNwQ0dWT4zrEm2bL/a4vS8RfxDuF73HDFayEI3CBT0jCsJZccXZVLknh9ni xHHYh9riBVUbdxBz6qP+QOa5y/upnDhVDNxKMJiiVSEK0KhBICPZC48dsfBaZHwkluwp 0313RDjDlZm3hY+/XpB7CCicUTGMb2vc3NERY97kXDfWU4M+R+P9u/b6ObEUY49LkSqJ 4uR8NH7apY8ZxnIWR5UuFb2bOcQSaCj5xBAWFp703GTkQni0dbO3lT2DvxdXpFs90fhT wWgGQoyrr944A+xN6lZuQvgy/A8jCdhCh4MM+4T3+M6VHBlyRhblDDnCTWhrreqTH0Ou fHwQ== 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:message-id:date :subject:cc:to:from; bh=6QfxmpujcShMrEzc1wZbTMHN3v2ys7mfOjbIsZzr4WA=; fh=IE3AZvDm9DC3cdTbYv1PuJ+zr4mdKz6MWG85KR/OiZ4=; b=jWCeuGLwWE1b1gMCwpdw8g3yhc0fjER/MggXS0h8Ka+cEGDCEPPErQXIApCMi0urUv QoZbVLTar80cXhH5/YpiHjKlKWVsUvgX1fw0vkjDth6Gml2Wy8896h1ajoneefl0QBJO u2+D5E6Ot1o26Sl2Jp1cuga7rsGM+kwr8tL99hHty2JpRjdvXKqD/zrLu6wIm/iA0USM C5rGT8fhQ88DYX3TMdcFtdJj4vFrjL+yeTOK/kiQMjRUkfFmK5C8Tkp56Co3nZmXnbsP LpUqgPq9shlhJUxxUvYvMLIj05YicJGZl/F19x4gqwvWpApdOy9x5+3oogXdIYkYy6wS rQrA==; 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-170719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170719-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t20-20020a05622a149400b0043c6e1cf5ccsi11377933qtx.432.2024.05.06.23.02.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 23:02:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-170719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170719-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 8068A1C2198C for ; Tue, 7 May 2024 06:02:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A73A36EB59; Tue, 7 May 2024 06:01:52 +0000 (UTC) Received: from zg8tmja5ljk3lje4ms43mwaa.icoremail.net (zg8tmja5ljk3lje4ms43mwaa.icoremail.net [209.97.181.73]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E241631; Tue, 7 May 2024 06:01:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.97.181.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715061712; cv=none; b=uY9EL5ucJ7kSkxqtlda0TwA16LO+n5/8o1FE4T9SHkhUkuZxgcW8cC8f/QDaURqyuCkdd9agWE/N/tLqOVx5VTElD49Rn+2sRsX1763qjXQKbUi0iyrlVgRT44DVQwnZ2ywKZ6SOmuwasntrXojufOI0dDaIE6b8/FvpOlX2+FQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715061712; c=relaxed/simple; bh=Uny6ysNJYlVeTJeo8VMjigzzMqR3H2CiDYHMK8hqilU=; h=From:To:Cc:Subject:Date:Message-Id; b=A72C3BWEXoiSW2LwQ+7Zfi0jggd86LrCXCjJphbFmZV+F2hzlTzD9EAYAKceCw2CN+V0tX7o3aZ6Yc4MQ/WMnr2C4AVIMXKWDGbnCqSdnC3EsMzlZ2nnvfBi9B5a9WYqzYA2AfSCm0x1c9s6a6hVFIyWnA4v3dkg5U6LnlxNuno= 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=209.97.181.73 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_KCgAnIJ6wwzlmH1VDAA--.3259S2; Tue, 07 May 2024 14:01:27 +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 14:01:20 +0800 Message-Id: <20240507060120.20095-1-duoming@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID:by_KCgAnIJ6wwzlmH1VDAA--.3259S2 X-Coremail-Antispam: 1UD129KBjvdXoWrZFy3Gr4DGFWrJw4kGFW3KFg_yoWfXFX_uF ykCF1xWw1UJ34UCw1rCF4rJrW3Ww1Fgwn3Gr1fAFZ7t34jya4UJrWkWr18XF1UWrW2krWS qrn5ZrWfAr4akjkaLaAFLSUrUUUUbb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbTAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr1j 6rxdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r126r1DMcIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7MxkF7I0En4kS14v26r4a6rW5MxkIecxEwVAFwVW8AwCF04k20xvY0x0EwIxGrw CFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE 14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2 IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UMIIF0xvE42xK8VAv wI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14 v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjTRWQ6pUUUUU X-CM-SenderInfo: qssqjiasttq6lmxovvfxof0/1tbiAwMOAWY4-AkEPQBLsW 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..7fa859f064a 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