From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f99.google.com (mail-ej1-f99.google.com [209.85.218.99]) (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 31D4242C4F8 for ; Wed, 29 Jul 2026 17:10:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.99 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785345049; cv=none; b=onU79wQD4TBiGo2xn3gbxiiNt912boNu3rMEOfeXEENbHup99eBqGQW8jFROwBJfwQ1Y7VyWYmONzzEpkzSL0K1WV+q0htP9vi+Ohi2O8JFCu20k12CAnWq4N8O+45U9hUweOdfoUEJNKhHzQC+xJK1tCGmVfkCAvy9Y2ciRHGY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785345049; c=relaxed/simple; bh=0qgKzcRkiIVyNpkzKqzraDzrTs55TNhNxffRzLDnLXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mej7JmWYsNhKn+E4zrxe++2H/q5py4STCiJu4lJurDcOEA0w/5ggMYlpA0a+FZP0nnbot5wcGyZnhGWvpUITd2eypbh7fuhLA38t0x0Zb7EfRV0eE/0PxYN00cVxFs2m9WmBrPeN0ir3+bGCaLPfFoK1Zg+lt+4WgT7pkB6w2Os= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=purestorage.com; spf=pass smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=L3pdf1Hl; arc=none smtp.client-ip=209.85.218.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="L3pdf1Hl" Received: by mail-ej1-f99.google.com with SMTP id a640c23a62f3a-c15e62c695cso10113166b.1 for ; Wed, 29 Jul 2026 10:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1785345045; x=1785949845; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RqZoonqZ0uag0x1qThpmE0Jlcr9KhM+cawrPE7VRM5k=; b=L3pdf1HlDRfoV/dE15TVu0DSVwehdsA86Dn+OgTZr4PGncxDABTKh5IJLk93b9M+it ycxN4Bvn8z9BOj43hKXtZdvdsD5G4C1XQZaWxjkbcJd+O5P5q/Z/RjhUNL3jl2zVxPno ukretvFdKOWEsWFagmdpCqw4A7ZD+SZqX9xNKs1+fO5U2EHjoDYteXxM+s3FsBzK9wae LUPTXyBE04jL+RDbQTkZPAAcxXx0XFVJX8XIlQi6cb54pczZ5vvS6ubXScV/z2WaSAUf 3Mm3hJIeWmzM5H2xS5ETX+X3/pItXRkm65hY8Ddk1SzSK1IdsEZ+Rf3CzSqIZnHGY3dK bQ8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785345045; x=1785949845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RqZoonqZ0uag0x1qThpmE0Jlcr9KhM+cawrPE7VRM5k=; b=YmSNYzzTsGfvIkVnN2AloEqu9pB5OqvtOXWelD6Ub+buQUZpdYN+R0o1toFJrAlI7E dT+uPiTYqriyueAJw4wufuHlS2ekhwDkjKCo4F7ZT6Ty2t9sO/2b2KxVlD4NDmlgdBqy F0AsR+HCfaf4dDm8fSGlOeumuhAqJGPt/hcq12OjYw5uk0KZ4ch+bHqJQauNoCqkp3ve wjc+DDTwoaO0rC6lFjuyBkWTlEocN3EOK1h488KElMf9zwwUvUGWvYLI04XckqFHWN0C B28E/ZfE4gGQBahHK3B0e9C15BoxPuuk+lF2P7fyRlqudfbxHzc+c1dlrI6SJFjP+vzC P9MA== X-Forwarded-Encrypted: i=1; AHgh+RqVuiWNjgP8MGXVnA7r820vWzSOjj6PyPCr0k3J23o5BB4BAmqTpOk1S83ztcmGnBzEG+hL3yfiZzGo6CI=@vger.kernel.org X-Gm-Message-State: AOJu0Yx6stie57CunXJcmVyDymRotHvYGqAEp5KldZB1nzPeIMWJvkgL CMxuW89nkXr6iU/76eyosSB/SEVCgwPzoqztCERjsvx+QljVKAJCkXaavJJxd4BQhtD94/APtcE WH1nVsOLnndb5Uo+OLXYjqCtb+asJ6fDhi4TM5bWEtj+ZK2bzeiZM X-Gm-Gg: AR+sD13EF0W5PxVx0nJ+gryXjP3TR5XTHf44lCJPqr6x142zEN+HFZIwzb+WXXb7ii0 rAf0dFSNKxIFts0JKGigCaFSTZ2Hmd+KbL4EOf3ck2ZmN88Zt4gkPBEWob1YL/eW2OcEMbvDF+C 0wSfYmADohGdScT8pTl4mIfz8M9X3o7CmOnt8lidv98JdlL8BFVSj2JY9z6dmuVH9g+i3+q0/fB S/HKgKWW7ht8h4SbqM+25iNFSL5JZIHokB1R/OGdvXzfQWtvb/iuXTdn3y/W6x4eZvGRCd2CtBN O90CqyPKIqC9cB/2287syAIa8BYH48MvQ144iIkW8xq2BxU58dx+XBb0RktRSBC8apGqKyds29k +5mOkRdSDnS0Q+V3GGg== X-Received: by 2002:a17:906:4784:b0:c12:732a:fe52 with SMTP id a640c23a62f3a-c1f952db03amr171690866b.4.1785345045299; Wed, 29 Jul 2026 10:10:45 -0700 (PDT) Received: from c7-smtp-2026.dev.purestorage.com ([2620:125:9017:12:36:3:6:0]) by smtp-relay.gmail.com with ESMTPS id a640c23a62f3a-c1f8404bfe5sm23717466b.73.2026.07.29.10.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2026 10:10:45 -0700 (PDT) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (bond0.slc5-n17m28-k8s.dev.purestorage.com [IPv6:2620:125:9025:20::a31:41f]) by c7-smtp-2026.dev.purestorage.com (Postfix) with ESMTP id E75C2401FA; Wed, 29 Jul 2026 11:10:43 -0600 (MDT) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id E52F1E4017C; Wed, 29 Jul 2026 11:10:43 -0600 (MDT) From: Caleb Sander Mateos To: Ming Lei , Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH v2 2/3] ublk: check for ublk_unmap_io() returning 0 Date: Wed, 29 Jul 2026 11:10:40 -0600 Message-ID: <20260729171041.45061-3-csander@purestorage.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260729171041.45061-1-csander@purestorage.com> References: <20260729171041.45061-1-csander@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit If the userspace ublk server passes an unmapped address as the data buffer for a completed ublk read, ublk_unmap_io() will return 0 indicating no bytes could be copied. Currently, this will result in calling blk_update_request() with nr_bytes=0, which doesn't seem supported. Fail the I/O with BLK_STS_IOERR in this case instead. Fixes: 71f28f3136af ("ublk_drv: add io_uring based userspace block driver") Signed-off-by: Caleb Sander Mateos --- drivers/block/ublk_drv.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index 098e046505ad..2cbc359dc196 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -1588,12 +1588,18 @@ static inline void __ublk_complete_rq(struct request *req, struct ublk_io *io, /* * Extremely impossible since we got data filled in just before * * Re-read simply for this unlikely case. */ - if (unlikely(unmapped_bytes < io->res)) + if (unlikely(unmapped_bytes < io->res)) { + if (unlikely(!unmapped_bytes)) { + res = BLK_STS_IOERR; + goto exit; + } + io->res = unmapped_bytes; + } /* * Run bio->bi_end_io() with softirqs disabled. If the final fput * happens off this path, then that will prevent ublk's blkdev_release() * from being called on current's task work, see fput() implementation. -- 2.54.0