From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp153-162.sina.com.cn (smtp153-162.sina.com.cn [61.135.153.162]) (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 510001A9F96 for ; Sat, 6 Jun 2026 21:41:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=61.135.153.162 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780782092; cv=none; b=Q2XW8oBiQVqGXFDG7BnIuAyCWukGbZ18kMnEjw341UoGi7cCqjqrYXYLIRFvlgrE99uklnoSTOi7d3f4cy+K2eGEA3H0gotkPUhQ1GgqCSHdkMeGX25/Xd0Sbw2Zf1RvYEFccd6IbVEFIX7TGuMLqNME+5EJcMHatqkeoPblxnY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780782092; c=relaxed/simple; bh=ROdCohOd94ncYE4sZ3BhZt66mHFoivsEW3UAID41/wA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pX5b3TA4tJvkZ+tWnV+jQytV5G81euGIBlwzs9fIG9uDrNn7o027NBK9abbTp6uShUCvIXWEHIX6IatYIjPfGWr6TzNSajz+bv4l5YoHdMj8hZQR3Tka4bK5InCLJ3GuN2M4KH10Y+GBA25TD17b+roYAccG8LPGcUaUi69VQiM= 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=DslrZo7+; arc=none smtp.client-ip=61.135.153.162 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="DslrZo7+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sina.com; s=201208; t=1780782086; bh=qNLOgN+LXhZZgb6meOLoiZtlnUvTkXpFCjk0OIbWn2o=; h=From:Subject:Date:Message-ID; b=DslrZo7+t1UD6sL7R/sIQC9Bdt1VmEJJsJxTFvaIPqt+eHOR1zKUh9UbB91JxrQ35 zja6/+bHie5KkasreK118P7SGaANEfAc0rZq1DEF4/Bp3rO1Quvl5ukmhNB5Klcca+ yjXdv+7rpmfIrRnSn4zyvgNVb458wz7NGVEe3G6Y= 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 6A2493FC000025B8; Sat, 7 Jun 2026 05:41:18 +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: 2448456816027 X-SMAIL-UIID: 7BE32AD5E0F948309664C91DF544C285-20260607-054118-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: Sun, 7 Jun 2026 05:41:05 +0800 Message-ID: <20260606214106.1638-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: --- x/net/9p/trans_virtio.c +++ y/net/9p/trans_virtio.c @@ -298,6 +298,7 @@ req_retry: return -EIO; } } + p9_req_get(req); virtqueue_kick(chan->vq); spin_unlock_irqrestore(&chan->lock, flags); --