From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f44.google.com (mail-yx1-f44.google.com [74.125.224.44]) (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 DF0A5299959 for ; Wed, 29 Jul 2026 01:56:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785290207; cv=none; b=P8qnevJa5Lv3jGEFvPxg+Huz8xXl/unohfPp3GKbVbsExHRO0BI/jZqr11MdhZu4NV614cG3sA60quc99u2Fowhm0RRrk261G3NpCE99zEtB8QWn63/CKdqQzsQKGV6iA3n9/ISWkNmMWbZZmbLqYLeeWqIJTteltsAnrFRopm4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785290207; c=relaxed/simple; bh=BETsDAziAoC+O7WZ5Awn6WeCnMZNnNKP3zEU3MxtQ1Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=L20SM8kz0emDVBEo4idcD3D3IZ6RvPrEW9nTnGYVLQF5pYK18iqAGbLkkxdU7dOGFbZRO8azkZz9zv3ic7oqQ2OK9tNZdH7mSqmpDCv923k57BbdSIruGPXhCXL6MpFVYoGSEZ6hcvY8ADKuypjk7VIkIQoaURwIyEuo5QQRvYI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=pAWwWe2H; arc=none smtp.client-ip=74.125.224.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pAWwWe2H" Received: by mail-yx1-f44.google.com with SMTP id 956f58d0204a3-668296d0ff3so482865d50.0 for ; Tue, 28 Jul 2026 18:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785290205; x=1785895005; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=ydSVwQUrbSVpK0x49Cka1T+m8lC2etzef5HLF1DxF30=; b=pAWwWe2H5SUmhlLJji55x6ibkhsVGab9iAHp7Zuha2ySWoboQuf9WZrvy2cQFi1dra ejPk+hj+8gY7+Q54c6FEio/tUBoFOE4X8ifLHqa5xZDZAnqbzX8rIkwct7hdWny40moO 28oytOF+8MXih4QTaPPdzTzCG1P9gC6KIrASEA8HFfjbYC2PwnARMXsvHjNbubuFpUO9 2JUWuVZi0vJYvY5laXDnJd7yQGJYiBhmjiO9j3KpFR41llZqY0ASRnD/l3nZ2P2XbIW9 R1JF9cGBya6Bi1VjWEnKlFH5zOR4+hCYRbMWM+38vXC9cAUNLPeOqnbb5fmNAz1zYDTc O/sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785290205; x=1785895005; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=ydSVwQUrbSVpK0x49Cka1T+m8lC2etzef5HLF1DxF30=; b=QCU+7rf7bz5bJE0aFxfpQaRbAJK7m6HRbeyUKbuRxmzfs1UcG2yY5+optJmwFhnExu BzYKgNvUfZKnPZ1SUwoEqrZXLnibBIkxJpMagKRtM7wDN8/pJV50gonFmrgBuUYIde92 b3QRujTWshbym9dXlcCzhjIVBpK+o5kgVzjslIb39HMqjCmgflO/0daQX7raQDqDQyhX wWhmnlk82/ZRQqUXicV6bThz/CI0rZirz5MzcjXtBtbYtMMzeD5wUHTht1Stx5n8/4IH kO1sFrzd/A/txYmnwJqdVK4Pb+1Jco+DNaXSusJQd85koyUe0WKyD7I/kJ6/fMh6yKV2 DCIg== X-Forwarded-Encrypted: i=1; AHgh+RpNykFvVeo27nYa/PjjAOoG8cRqNgTPQ/7q+po9+UyWD0B63dzmTqcBXEKLfopOcCIEzB7p2/t1PAP93SI=@vger.kernel.org X-Gm-Message-State: AOJu0YwcgKGY3MgSQdYWQFrkQafkgpa7/hVqPBKPa5XerhhzEtzLwLVX ZTbsppcB92hReui6JnIqRz6fT/WVXtJTi+G8nWDTtBdNTTbePlUy0W91 X-Gm-Gg: AR+sD12tPeN3QbZQHIqSqAJjTbK72E6O2C8JbNcxd8Dx812fR+60kzSGAF1jtLO/7Ih HnvS1TJVEDImYQbu8rnuvIkgxKIP5tGAri2XrAwGy7MddQIbGtikAUyuSu42+ev9QwBPJjE7y61 3CoyzbWNtTKbmZAaYwCCZHvMAcMwWQ4+KjxmcRKp3sukAd1GKkQv7QzxfVLHm31z/dVXxqq1Fdc 1LGKjVIvloSmGEsn4QTqiRSCBUlO0bSXSqtnaWZzqCa3okow0/H5mnvDAVmO/tuP95Jf1EbQ9wk CWIroko/tyIHgeHJ9LkrWzzj9Coud92HYDpXgZepImj5Sv31low/NOk1tKYYsKIFK2kp9F9yu5M WLCU2EQb8MsuEyV704hZnadAOhqsmYhvKuSrK7mpdLUKLCXf3TC6MzVm6hJBK0iKUfzejgdeCGw jCgx7MlQ/9th+3OTkI32uw6IE92yDgT4FrDbehdJS9/F6ZJgsMqous+MO6i6+FFVorLiq0vD8Hv Q+obGlzb3ZKteUk+dlHiJhLk4pVzprueZ8qmTdRb8vA4fX1/SN9y5OezINIlbFfmHxU X-Received: by 2002:a05:690e:250e:10b0:667:8b90:3566 with SMTP id 956f58d0204a3-66905842ccfmr1641232d50.88.1785290204723; Tue, 28 Jul 2026 18:56:44 -0700 (PDT) Received: from fedora-laptop ([172.245.82.59]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-669125fad3asm927723d50.10.2026.07.28.18.56.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2026 18:56:44 -0700 (PDT) Date: Tue, 28 Jul 2026 20:56:38 -0500 From: Ming Lei To: Caleb Sander Mateos Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ublk: remove WARN_ON_ONCE() in ublk_unmap_io() Message-ID: References: <20260727162450.2921500-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-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Jul 28, 2026 at 11:22:00AM -0700, Caleb Sander Mateos wrote: > On Mon, Jul 27, 2026 at 7:47 PM Ming Lei wrote: > > > > On Mon, Jul 27, 2026 at 11:24 AM Caleb Sander Mateos > > wrote: > > > > > > io->res is set from struct ublksrv_io_cmd's result field, which is > > > controlled by the ublk server process, without any validation. It's thus > > > possible for userspace to trigger the io->res > rq_bytes warning. > > > ublk_copy_user_pages() already limits the copy length to the request > > > data length, so drop the warning. > > > > > > Signed-off-by: Caleb Sander Mateos > > > --- > > > drivers/block/ublk_drv.c | 2 -- > > > 1 file changed, 2 deletions(-) > > > > > > diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c > > > index 4ca6ec738c93..4f30644756df 100644 > > > --- a/drivers/block/ublk_drv.c > > > +++ b/drivers/block/ublk_drv.c > > > @@ -1492,12 +1492,10 @@ static unsigned int ublk_unmap_io(bool need_map, > > > > > > if (ublk_need_unmap_req(req)) { > > > struct iov_iter iter; > > > const int dir = ITER_SOURCE; > > > > > > - WARN_ON_ONCE(io->res > rq_bytes); > > > - > > > import_ubuf(dir, u64_to_user_ptr(io->buf.addr), io->res, &iter); > > > return ublk_copy_user_pages(req, 0, &iter, dir); > > > } > > > return rq_bytes; > > > > The change may be fine, however access_ok() still can fail from import_ubuf(), > > so can we consolidate ublk_unmap_io() a bit? > > Sorry, not quite sure what you mean by "consolidate". Are you saying > there should be a check of the import_ubuf() return value in > ublk_map_io() and ublk_unmap_io()? Yeah. Thanks, Ming