From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bsdbackstore.eu (128-116-240-228.dyn.eolo.it [128.116.240.228]) (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 76AE320551A; Wed, 12 Feb 2025 08:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=128.116.240.228 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739348612; cv=none; b=Jc8tMbHHcJ7BY0xluQf5igxMWnRW/gE66Y5Kq6VFz9Wr5hO4g3fPCu8K4TZjE7mLswA7azWmFCo0+zbQ0+90IRZo91m4nM3dSwxxB9xcRS8tyrlRTD7A9CN84G71jfcPzDTS1P2v7bo+Bj2Wrsh1Tsew/Ks0qxno2/qHKi8dqdE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739348612; c=relaxed/simple; bh=U7FibLmnbo459XjlNA7JSk7O9RTrKMRxetmxEmNH7I0=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=MheOPbvVwevFsWL4RI8wyQHAvuoQaal95ay7Blh80ignaptHbUs+vHj7reVTOPgewhhAQs7Prz9S+qgklfouHY8LRv471qa2NRCKSWgirAc3hEIr/g4XWMrIue1UbH8tb+cwjVuuJWMHAxrNC4wfJFTZYEaogNd7qB90SIYjYv0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bsdbackstore.eu; spf=pass smtp.mailfrom=bsdbackstore.eu; arc=none smtp.client-ip=128.116.240.228 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bsdbackstore.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bsdbackstore.eu Received: from localhost (25.205.forpsi.net [80.211.205.25]) by bsdbackstore.eu (OpenSMTPD) with ESMTPSA id 7d8026c6 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 12 Feb 2025 09:23:28 +0100 (CET) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 12 Feb 2025 09:23:26 +0100 Message-Id: Cc: "mgurtovoy" , "sagi" , "kbusch" , "sashal" , "linux-kernel" , "linux-nvme" , "linux-block" Subject: Re: nvme-tcp: fix a possible UAF when failing to send request From: "Maurizio Lombardi" To: "Maurizio Lombardi" , "zhang.guanghui@cestc.cn" , "chunguang.xu" X-Mailer: aerc References: <2025021015413817916143@cestc.cn> <3f1f7ec3-cb49-4d66-b2b0-57276a6c62f0@nvidia.com> <202502111604342976121@cestc.cn> In-Reply-To: On Wed Feb 12, 2025 at 9:11 AM CET, Maurizio Lombardi wrote: > Hello, could you try this patch? > > Concurrent calls to try_recv() should already be protected by > sock_lock. > > + mutex_lock(&queue->send_mutex); > nvme_tcp_try_recv(queue); > + r =3D queue->nr_cqe; > + mutex_unlock(&queue->send_mutex); Well, reading nr_cqe like this is still racy, but should be a minor issue and not hard to fix. Maurizio