From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ADCF28EA72 for ; Sat, 20 Dec 2025 20:25:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766262351; cv=none; b=Y1p7kqn3ZriFY8GCF97dxx4iK+qEpGUkAPZeZxsA5gnbEKUQ7wFB69Rjc577N5iorONADVDJtPwKeEgIEwAcdKZEhYZSB3a/VyeRAyB4ji97vmO5m0hy7ZmznCHXT1LbgPQbtmyMZECa2IUpO2sCNqL/UYkp0i4ghluyiI2AXLE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766262351; c=relaxed/simple; bh=WYiBPoNN15TRawXbXQ89ngXqO29M2xbANzu1FZDc32w=; h=From:To:Cc:In-Reply-To:References:Subject:Message-Id:Date: MIME-Version:Content-Type; b=YGC5yIWdt+7QBO4gpl4ZK7ECqx02PMnW1jQrc7lFMlpl1hgBvT5wCJZqNuO4OJs+0n3fhTOzRB/MfEpHrftiyCiU72jUDTsb4CT0BmopjiX42MfpNXzVKAjEcmV+aczamyMAw9cHuliF5qlmRqmfHP5TBs/rW5rAvBBbfumGnvs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=bRWJHGeC; arc=none smtp.client-ip=209.85.210.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="bRWJHGeC" Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-7cac9225485so2468745a34.3 for ; Sat, 20 Dec 2025 12:25:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1766262347; x=1766867147; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:date:message-id:subject :references:in-reply-to:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H/lgamY9SXCimSG62HLgmOca+s6T4w5UYIKxECAKLIo=; b=bRWJHGeC6n7pgXvYnYX83YRwPiY89ncCwAHgUi1qWKOKM7EnsQKVULSNMOjOiUmpcY TLfFRhTRTUP9BjciSaDjgznVaA9zhD+Pzi/T9j5SPE65KOXIijiwTMdETZvb/Q3i7O+k PIXDA1VgiW4/kULiXA/y8ryONImPQQCSi2F2a9TJRQHaiLT5YkbKODlK+RBv6kl4vQpD 7njhRVcCR2NYsJeMVUucd/zHQ3lsFzDnJ9qthF2BNBpkJBq0yjgwU9+tel7iYKRqFef8 jeF/3WK0QO6QBF8xLr+tVx08VkZgl0ReoBj4cD+iLEt4BPCxRwjIN/TpaZDF/bsqX4uI EkNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766262347; x=1766867147; h=content-transfer-encoding:mime-version:date:message-id:subject :references:in-reply-to:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=H/lgamY9SXCimSG62HLgmOca+s6T4w5UYIKxECAKLIo=; b=vK1Hl4CoYTSiM7N2jFYiyF7Ozm7/bc9Fs88OlssASzRk/CxWFatc4dAbjqLAo44uke tQDAJq7YMEK+5o2u8RFpNuwPxUgLV6zb8INWtX2wccyPuLpV4PNDUttG6pwLClZMu2o0 4NglGbN6BsJvp8mfZGFTqOmaMML7twpQkY66Cavx4BD08mClmdXe1Jae+OmAkOTwWcjO /V0ltmuXtxIlgQcaPWT/ZGBXfcS3NK2jJrikjSUXNRq2BB4zzgqZwGHDYvYCY8RTzj5G fo3kg9tssbM/1syE8j3rcodBQYlkRVkcMaeGxXQL7kKOjvpSx98c28aoF6fgwES2GCRQ Gqog== X-Forwarded-Encrypted: i=1; AJvYcCWkEtBh/FC04UwBixiZ5lg2AF2uGo6oahRlJdVYpo1cN8RVcuSbN1CP+taMOLofbwYWXu6Kytg4/Vfvuq8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9LM59DDy+QmKICKRRvbGAqCy5ptNOGSJFrx89HzG+AHZdfQu9 ftr7n8WrRBoGaPhIixGEG23kjumB0s3/n6PP7ZtFnRuhkNXpO43rChSscNc4seF7i9Y= X-Gm-Gg: AY/fxX4gpsTghZGnjD14kXZ8/fDqK+qvooLc0tGGkKXRmcFFcR5+TH0MXAqiUob5frD TAeBpdIIDsSj9KrqKrf/KBaEkXew0dLDwtWP8MsuRo0lLo86nXTcuxjIPNrWZZfOVhytEVTQruG RdJ4VFKmaAz5LokZ/y4JVgPvd1I8QknH5uZ9EzQ45AyjUCcHk2tee6vL3hE69APz5Ox43d3OMpP tc/R/+LVkp8aTLX2AymvKI81R0LJ6mwsnXXA/isGFsaB0Dpff0HkUT1JFIz3dOqEutRdDt0Lswr g/OoKpysrzVTilF9ISICUaZ34QD9Jkb8497Ar7UJCEIVMdeHMPR8UK2H5WvmHMHSuKpY4+0vcsX 7r+4YSM7cjxkBuqXn9KeqWrgr8B0WUbVXGqrXW9q6/M/w6VNXPhWq2ovAY4GtmDphqTr4ZE+wj7 j6+6Q= X-Google-Smtp-Source: AGHT+IFu2TOReZKWvA4ImfOcDfP76tmGhfg9TIAZOlwn1PwsJysVvxo/+zeCRv31OC5KYhiPkd1OwA== X-Received: by 2002:a05:6830:6731:b0:7bb:7a28:51ba with SMTP id 46e09a7af769-7cc66a95465mr3361625a34.26.1766262346970; Sat, 20 Dec 2025 12:25:46 -0800 (PST) Received: from [127.0.0.1] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7cc6673ccc2sm4240033a34.12.2025.12.20.12.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Dec 2025 12:25:45 -0800 (PST) From: Jens Axboe To: Ming Lei , Caleb Sander Mateos Cc: Uday Shankar , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20251213001950.2103303-1-csander@purestorage.com> References: <20251213001950.2103303-1-csander@purestorage.com> Subject: Re: [PATCH] ublk: clean up user copy references on ublk server exit Message-Id: <176626234523.413702.6264984213970998907.b4-ty@kernel.dk> Date: Sat, 20 Dec 2025 13:25:45 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Mailer: b4 0.14.3 On Fri, 12 Dec 2025 17:19:49 -0700, Caleb Sander Mateos wrote: > If a ublk server process releases a ublk char device file, any requests > dispatched to the ublk server but not yet completed will retain a ref > value of UBLK_REFCOUNT_INIT. Before commit e63d2228ef83 ("ublk: simplify > aborting ublk request"), __ublk_fail_req() would decrement the reference > count before completing the failed request. However, that commit > optimized __ublk_fail_req() to call __ublk_complete_rq() directly > without decrementing the request reference count. > The leaked reference count incorrectly allows user copy and zero copy > operations on the completed ublk request. It also triggers the > WARN_ON_ONCE(refcount_read(&io->ref)) warnings in ublk_queue_reinit() > and ublk_deinit_queue(). > Commit c5c5eb24ed61 ("ublk: avoid ublk_io_release() called after ublk > char dev is closed") already fixed the issue for ublk devices using > UBLK_F_SUPPORT_ZERO_COPY or UBLK_F_AUTO_BUF_REG. However, the reference > count leak also affects UBLK_F_USER_COPY, the other reference-counted > data copy mode. Fix the condition in ublk_check_and_reset_active_ref() > to include all reference-counted data copy modes. This ensures that any > ublk requests still owned by the ublk server when it exits have their > reference counts reset to 0. > > [...] Applied, thanks! [1/1] ublk: clean up user copy references on ublk server exit commit: daa24603d9f0808929514ee62ced30052ca7221c Best regards, -- Jens Axboe