From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp153-141.sina.com.cn (smtp153-141.sina.com.cn [61.135.153.141]) (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 63C843815D6 for ; Sat, 6 Jun 2026 13:14:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=61.135.153.141 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780751660; cv=none; b=hrtelfz3HFu1XjkkO7D3FkFuhbZCyG48Iln4Rh90kEGlmCFSpiXPfmD3s5IO0rz7E/YS6lXM2SLldYpjff7FPttP23zetOtFWCp5CDt/htW5ko9tL4elaptqR9B8aAmKKwBdLuCBttlfC2gQFQ/P7xmjObqv6A3mxBm9O3JsvlM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780751660; c=relaxed/simple; bh=2GYsQ4w14OPznMgLz4jXA5ygYwQbxtxMfbJ3REwT4K8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qSqo/3IcYWXO+abWsbC44FPDKhFZ49+moppdqTQbS7gSxY6zCJuA7K46VfQfpeqeEIyQnXz/Xh3yot0kB9ku6TWunx2D4Ko/lXUfWSTgk/5Vvv4xUFvjlsyMeYAjrwf0GFGQawWuGl5cVVq2QL25q9qDLdQEpeWmTEaQJO2hLUk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b=AwJRMAoo; arc=none smtp.client-ip=61.135.153.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b="AwJRMAoo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sina.com; s=201208; t=1780751652; bh=QcClKpKBhO/HrHCJ5Semkt47Fb532cIdIPOExT+6/eY=; h=From:Subject:Date:Message-ID; b=AwJRMAoo9zt/sMQfPwTPBFJJj/FuwnlCisCLO48zGPiNqmdVdJk4F8gWD4JYmevMO jrfK4rn5d00VSMtKKVPb/rN8aBAN5CA74dSvMkQI9+u6stcyU8ipcgOlMw+abVWMva hxt2XxLmIrFEradDX0BnZMWIqlUIICAE+um3PxPU= X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([114.249.62.144]) by sina.com (10.54.253.31) with ESMTP id 6A241C8600005EFC; Sat, 6 Jun 2026 21:11:36 +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: 6035816816240 X-SMAIL-UIID: B07D0815A39B404E89C9184004531355-20260606-211136-1 From: Hillf Danton To: syzbot Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [v9fs?] WARNING: refcount bug in p9_req_put (4) Date: Sat, 6 Jun 2026 21:11:24 +0800 Message-ID: <20260606131125.1604-1-hdanton@sina.com> In-Reply-To: <6a240600.c25708ab.1b19ef.0003.GAE@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 > Date: Sat, 06 Jun 2026 04:35:28 -0700 [thread overview] > Hello, > > syzbot found the following issue on: > > HEAD commit: ba3e43a9e601 Merge tag 'soc-fixes-7.1-2' of git://git.kern.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=12b65a86580000 > kernel config: https://syzkaller.appspot.com/x/.config?x=8118209836970b54 > dashboard link: https://syzkaller.appspot.com/bug?extid=f6fdb3bdd2c1d419e263 > compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=158b5f2e580000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13d47dd2580000 #syz test --- x/net/9p/client.c +++ y/net/9p/client.c @@ -181,11 +181,18 @@ p9_tag_alloc(struct p9_client *c, int8_t p9pdu_reset(&req->rc); req->t_err = 0; req->status = REQ_STATUS_ALLOC; - /* refcount needs to be set to 0 before inserting into the idr - * so p9_tag_lookup does not accept a request that is not fully - * initialized. refcount_set to 2 below will mark request ready. + req->tc.tag = -1; + /* Init ref to two because in the general case there is one ref + * that is put asynchronously by a writer thread, one ref + * temporarily given by p9_tag_lookup and put by p9_client_cb + * in the recv thread, and one ref put by p9_req_put in the + * main thread. The only exception is virtio that does not use + * p9_tag_lookup but does not have a writer thread either + * (the write happens synchronously in the request/zc_request + * callback), so p9_client_cb eats the second ref there + * as the pointer is duplicated directly by virtqueue_add_sgs() */ - refcount_set(&req->refcount, 0); + refcount_set(&req->refcount, 2); init_waitqueue_head(&req->wq); INIT_LIST_HEAD(&req->req_list); @@ -202,18 +209,6 @@ p9_tag_alloc(struct p9_client *c, int8_t if (tag < 0) goto free; - /* Init ref to two because in the general case there is one ref - * that is put asynchronously by a writer thread, one ref - * temporarily given by p9_tag_lookup and put by p9_client_cb - * in the recv thread, and one ref put by p9_req_put in the - * main thread. The only exception is virtio that does not use - * p9_tag_lookup but does not have a writer thread either - * (the write happens synchronously in the request/zc_request - * callback), so p9_client_cb eats the second ref there - * as the pointer is duplicated directly by virtqueue_add_sgs() - */ - refcount_set(&req->refcount, 2); - return req; free: --