Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1286975lqo; Fri, 17 May 2024 18:34:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU3FVgUw2mS6n5atfkKDDza1fMUuYpBDlNkdD6lIM8Tig9AsnAtCk9P2SgGbmNmLm9WcFhDM4+9riOAvdXxDWIv9uHZfdoCAmzWi3J+WA== X-Google-Smtp-Source: AGHT+IHZZFySeFnEZpPj3sm5Chrfpwn8Pu0wWz4wu1EyLT5ARrL6I5grBq5tm+2TiaPrz32xRBL1 X-Received: by 2002:a05:622a:54f:b0:43a:ffa5:ec8d with SMTP id d75a77b69052e-43dfdcd7aa9mr294324771cf.42.1715996055652; Fri, 17 May 2024 18:34:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715996055; cv=pass; d=google.com; s=arc-20160816; b=vAWKkcizr4+/bueMJMi/hOT3+QE2TUJuLRzo5NXyb6bXY1dkNb4nMVQc4aQGlpEkMG Edv/OKL49xXd4HBrN56T5YHMU8JSQ9l4NCOlZWY3/pKwXhIbCCrdZ19sgkf5IC0d7AJw mMmHVFT7RZaOHf0d6Ba0q5n6f5vk5WgF1F4zmAv6elfdV9F4NO5O0pDkG8WIfBqUd/UA OE3Szmm/X04mEJ7MvOs1S6hUpy7hj6Bfk5+TXTjlD1gIJcksjUBYx1PFUX9Dea6DzoZj xvSu7Nn6cTg/SKJtnHT6CXwPjQ85oG0yEqJWEXFEQxmWRFtOg6KqmvYJElfqSe2LFgt0 9EYA== 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=nmWedAFDzQ1ChdVH4m/X2Fn/PsA4EUI0FdvtAEggZGQ=; fh=FTMOYpnP11Cksqj4MzZtOdjfWROeJPpTM6tRf6vEli4=; b=rZlxgn6tkeZ1o8RyBuF7C8T78oBbVFF0WPyvVfTPMcqF71opr/aDBCiy6CrovTJ7dM O+9ZBZqTHW3O/MaaWiDxOzqhLyo0dEre/79DOgGK+BrmY5glBpMm9IltmbNc//g10pSx JnsBhPWkGbLODH+YMntnVLq8mr2YNssSbICpMRzwcOCEPMsWcLWlJjqyxjgZcKWKmIFb 8SsAWRlwptIZS2WFbaUdMuhXY3M63BB8cydiVuyr+9NkkiOsLq46Th3vMGmEnflTTMEn fVifcbeiEOalBbQigLUOcFQSBh1UV88KbDGQnzhY8X5l6noLWGj/uH6+aZNhEfsG3Awd OuUg==; 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-182738-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182738-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 d75a77b69052e-43e3ac1115esi62117231cf.64.2024.05.17.18.34.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 18:34:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182738-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-182738-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182738-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 5EDDA1C21430 for ; Sat, 18 May 2024 01:34:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B29A62CA9; Sat, 18 May 2024 01:34:09 +0000 (UTC) Received: from mail115-24.sinamail.sina.com.cn (mail115-24.sinamail.sina.com.cn [218.30.115.24]) (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 95F0C1FBA for ; Sat, 18 May 2024 01:34:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.24 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715996049; cv=none; b=JRphs2n4AKFP45nbkIE2jU9wKDYL4iI1f8pxr5UGxNOfcX6IzWnmcX6ng96lgBsCC/hJKjXGl+6oK6cPgmNH7uMtqNF9Wh1dcZX4Z0mL5DOvk2v8jmLKRgtrurRqrDQyEMeVjyiyfrNdmX7V/RFNKL2n7bJdwMo/D7P0FXfHmlE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715996049; c=relaxed/simple; bh=ifsj8+EQBQy+H/Y8chZd2hRoJRviiAySy67SIqorXqM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uqZONVFKVtcUCaQfaVQjIxJEz2RERQaFcyMadLORwzBp7YF4rB0joMyCbVdhyeuS3mmjNCvCUxi0P8v6e6V7+48ByXgipWnmc91knqWVlmFKIyaGrV2MyA4Guk7DlmB4axIJQ8Dm7Kjh6+AgYx6ump3SH1W8RTolhns3trvdQd8= 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.24 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 6648057E00000BCE; Sat, 18 May 2024 09:33:52 +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: 85541931457862 X-SMAIL-UIID: 9697284FBA05422AA631F1BF6CC9C35B-20240518-093352-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 09:33:41 +0800 Message-Id: <20240518013341.1649-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/include/net/9p/client.h +++ y/include/net/9p/client.h @@ -11,6 +11,7 @@ #include #include +#include #include /* Number of requests per row */ @@ -122,6 +123,7 @@ struct p9_client { struct idr fids; struct idr reqs; + struct mutex destroy_mutex; char name[__NEW_UTS_LEN + 1]; }; --- x/net/9p/client.c +++ y/net/9p/client.c @@ -1041,6 +1041,7 @@ struct p9_client *p9_client_create(const 0, 0, P9_HDRSZ + 4, clnt->msize - (P9_HDRSZ + 4), NULL); + mutex_init(&clnt->destroy_mutex); return clnt; @@ -1058,6 +1059,7 @@ void p9_client_destroy(struct p9_client { struct p9_fid *fid; int id; + int clean; p9_debug(P9_DEBUG_MUX, "clnt %p\n", clnt); @@ -1066,9 +1068,18 @@ void p9_client_destroy(struct p9_client v9fs_put_trans(clnt->trans_mod); +again: + clean = 1; + mutex_lock(&clnt->destroy_mutex); idr_for_each_entry(&clnt->fids, fid, id) { pr_info("Found fid %d not clunked\n", fid->fid); - p9_fid_destroy(fid); + clean = 0; + break; + } + mutex_unlock(&clnt->destroy_mutex); + if (!clean) { + schedule_timeout_idle(2); + goto again; } p9_tag_cleanup(clnt); @@ -1454,7 +1465,9 @@ error: if (retries++ == 0) goto again; } else { + mutex_lock(&clnt->destroy_mutex); p9_fid_destroy(fid); + mutex_unlock(&clnt->destroy_mutex); } return err; } --