Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1466572lqo; Sat, 18 May 2024 04:41:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVQus/dpvvjshLUeAalru+RUNxekTk5oG/dZLqP0O8+QHU/JfDdghYdIkGnuKQ86nNu2d2Djf+LXtYG+ijuQVIiMzIYI00saIhx7EK3HA== X-Google-Smtp-Source: AGHT+IHD/rQ10KVhx9atlVZ+YecHmBAMs2mGpoWhzuahcHWuDkUUimc0nKlDJY9D62zn4wmiYLwq X-Received: by 2002:aca:2111:0:b0:3c6:f7ce:babd with SMTP id 5614622812f47-3c9970cedb1mr29437348b6e.44.1716032496561; Sat, 18 May 2024 04:41:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716032496; cv=pass; d=google.com; s=arc-20160816; b=oXdZWx7Bjq5v7O8XgCPse4ARwLMl39yqQrDGqBv98kM7PmZDmfdRwbTwQ7iRTKIW+d GmyG4Sx8Xu4IRVSUKCxBytYobc5jMZR2meqUa1qkBh4d7dolcwQteCtH6k7mKxrZkuwh Q2Ry2uqo5kQQInIxABBRvHQJQQqfbJF0WpPuFFaVd0yjs29SAMKeKZoVM9/IFDcYJNmU 2C/zrTrOOwDVRKOhHUvyvmUtqkcUkUUQd2eAtMfUU1tT2waNbjKRdZU9JQb2GsO//K52 FJhH6GyNwTQuqAizgAfDB2nwwMOtHURS538D2FLykz57yL2eHRFm249a9rV1DL3clRgV Iaow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=yHBG7SfAoN8ZMwReQsaC9E1QtO6tTfuaWDXuTuVii0w=; fh=FTMOYpnP11Cksqj4MzZtOdjfWROeJPpTM6tRf6vEli4=; b=E0TGkVsAfjLcoP/8/fDbmVHAGDtjumlRe9DfBCL3RMhxwUFgsN5nR27MIxZuik/CZM nPoP/jymR5emTLeaaO9MPOtL14YhI1FFL+R1KAIbX3MfIOS5pK5f/XYM5sNsS8caJqnG tRUzn7/foYaKnhNJ8dROHK2Y95VAv3aKGHwd2Xr4TgSCldx1ULlSK855kPDaRhnro7Q2 LGQMw9bmBlVza2xFVyHdFyY62fNL4iRzjpezOg87cgpDgdGbNWl4FGRXmLoTVDJztJNM Mcu/3uYM/iwwpU1/L0XkCU951N/ty4zQf3VWrg5FVRUVgAeDufkHwoOwLcciYKUj7KBJ BJLw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-182834-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182834-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 af79cd13be357-792ff70a7e3si720468285a.650.2024.05.18.04.41.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 04:41:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182834-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=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-182834-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182834-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 47F111C21073 for ; Sat, 18 May 2024 11:41:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96368364BE; Sat, 18 May 2024 11:41:31 +0000 (UTC) Received: from mail115-69.sinamail.sina.com.cn (mail115-69.sinamail.sina.com.cn [218.30.115.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BFBC2E62B for ; Sat, 18 May 2024 11:41:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.69 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716032491; cv=none; b=e0gDZalqNaJCNueTf6P+KwKqYsf/Qtqf/gwIL2HWWg3jWkd5cYB/xUuK9LelbA7n3gcNOhKYlf07EOY2YdVUyB4UvKvRy+pTu6d/5AzPHyLJxtQzdpzU4AH2fPAEnPjCJdnrnngvclshk06SrRwyuWO/5Z8QBe7k9O/CCvShJfk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716032491; c=relaxed/simple; bh=FT9g0mVJkaULAbLCz6DFh6+4/pfYztHg6RKsLSGzaKc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iNnppgZWLtKzzcwUtpKm7XWhW4U9/0zqwr1a5Uo7bbZCrIAyhpcalvJGU66v2hYtvwXDAzQ06lWqLNKQxvqOr5gM5DqXYtuk5Or94TNhmI9FdVntAaE6siBnYLnpAOv8i9sBcokQJgnxgmKZd8VcQNTJ6BW9muT5o/m4p9FIEvg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=218.30.115.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.118.65.249]) by sina.com (10.75.12.45) with ESMTP id 664893DA000080FD; Sat, 18 May 2024 19:41:17 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 21449531457749 X-SMAIL-UIID: BA5C5DCC219A4AD89BC009DD1F383FB1-20240518-194117-1 From: Hillf Danton To: syzbot Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [v9fs?] KASAN: slab-use-after-free Read in p9_fid_destroy Date: Sat, 18 May 2024 19:41:05 +0800 Message-Id: <20240518114105.1730-1-hdanton@sina.com> In-Reply-To: <00000000000049897e0618a4b1ff@google.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Fri, 17 May 2024 04:31:28 -0700 > syzbot has found a reproducer for the following issue on: > > HEAD commit: ea5f6ad9ad96 Merge tag 'platform-drivers-x86-v6.10-1' of g.. > git tree: upstream > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11df3084980000 #syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git ea5f6ad9ad96 --- x/net/9p/client.c +++ y/net/9p/client.c @@ -879,15 +879,19 @@ static void p9_fid_destroy(struct p9_fid { struct p9_client *clnt; unsigned long flags; + bool empty; p9_debug(P9_DEBUG_FID, "fid %d\n", fid->fid); trace_9p_fid_ref(fid, P9_FID_REF_DESTROY); clnt = fid->clnt; spin_lock_irqsave(&clnt->lock, flags); idr_remove(&clnt->fids, fid->fid); + empty = idr_is_empty(&clnt->fids) && clnt->status == Hung + 1; spin_unlock_irqrestore(&clnt->lock, flags); kfree(fid->rdir); kfree(fid); + if (empty) + kfree(clnt); } /* We also need to export tracepoint symbols for tracepoint_enabled() */ @@ -1057,6 +1061,8 @@ EXPORT_SYMBOL(p9_client_create); void p9_client_destroy(struct p9_client *clnt) { struct p9_fid *fid; + unsigned long flags; + bool empty; int id; p9_debug(P9_DEBUG_MUX, "clnt %p\n", clnt); @@ -1068,13 +1074,18 @@ void p9_client_destroy(struct p9_client idr_for_each_entry(&clnt->fids, fid, id) { pr_info("Found fid %d not clunked\n", fid->fid); - p9_fid_destroy(fid); } p9_tag_cleanup(clnt); kmem_cache_destroy(clnt->fcall_cache); - kfree(clnt); + spin_lock_irqsave(&clnt->lock, flags); + clnt->status = Hung + 1; + empty = idr_is_empty(&clnt->fids); + spin_unlock_irqrestore(&clnt->lock, flags); + + if (empty) + kfree(clnt); } EXPORT_SYMBOL(p9_client_destroy); --