Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1092536pxb; Thu, 9 Sep 2021 20:29:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi6aGoHlap9Drpp8grmAbEVuNq260fMf0ZL00l9BZrrdWoL/GWxtF/eZCrQ5BYFSZaTJDG X-Received: by 2002:a5d:8b4b:: with SMTP id c11mr5329104iot.98.1631244599368; Thu, 09 Sep 2021 20:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631244599; cv=none; d=google.com; s=arc-20160816; b=s/4ycoRUW3lyNSD0GWTqZ+6pVwbP9PMi76dbXfjkR7fYXqyuPnGcNN/j/pm5giYYGa +tSHxPGCgUZEL4Ky0RbOcVGhbUxFfPTv03/NwW223npjUTzOoVKKtyGc/u2XZI4ajzjy LmaY7DCiEPDorT1XcWCu8hqYfyEjlnYZ/OK4/Y2EZ3qrYrniZnARxLD5ouNXDz5BaZog yXI1OJ07FIYaT+65TQbqQIwae5UVjqcYNtI7Qv5vbjmgpJR6VkSDZ9ZnwRH4MH6k2SVp D4Z4ADLCwE/Ar46473aIgt+3XRSrANo2hheue1V3Y4H+8W/bvKAs7WhSkkfU1AveUnZF DRYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=HkeHhnqkzSEVCG8RBViWFhN/hyIZCVQVxMZ4nK2bjs8=; b=NC61Mdbj2ObH+p1UG3FNC0yFeDZnISPuW8taXiymYq3+2m20CnsmYoQ8GsC86Nw+uw 5KAU3DHapj/Vyi3QESm4Ds4ykV7MfChswnxpG7P6GLrJOEyG/ucH5hOBkW14ch0JGmtQ 2WlulJ7HX6eNiMoaAMrqPkFpleStvvGQPlvRF9egoCunCDSUfJLl0OretUEgRtqNgUAe oA0iABOXjrFtk3hd3Kf/CyQWLcRhisFFL/UaRFSQB/m783E5NgppVBPWJOHDc5GdGofn ZdKCuT34M9npUWCIdKdyG8n0+zF2xRRsvO71X8z9qfW47d4YXfu8mk1WalNLrBGg98e1 HX/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=PkWP9UGy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h13si3742005ilc.131.2021.09.09.20.29.47; Thu, 09 Sep 2021 20:29:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=PkWP9UGy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230117AbhIJDaE (ORCPT + 99 others); Thu, 9 Sep 2021 23:30:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230060AbhIJDaD (ORCPT ); Thu, 9 Sep 2021 23:30:03 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5399CC061574 for ; Thu, 9 Sep 2021 20:28:53 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id j18so610443ioj.8 for ; Thu, 09 Sep 2021 20:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=HkeHhnqkzSEVCG8RBViWFhN/hyIZCVQVxMZ4nK2bjs8=; b=PkWP9UGyF379pXe/D9Yf+Ivd9Eruhf+xmAuxu9RC2rNGoNLpkUGMDnp6G5oIuI8hQ2 xbTqhTOfVOBA41nsgUthZ2RcHT6sOyQp7Bv2iMAwiUJSVxdnha8b+nYnwT8JDwW1gj6L KCu3onchyYKvwKNOYmsyf1ltANK5T7B/NQ6+NkZDlrWwymOlFSBQQyA50LlDKaN3DArh sNq1hDQokhDbuswGnyJa5j400ekgZ9yVbHbrxz4E0N5gfO++NsYq7aKUjp8tR7R+jFY+ 1a94D/qkCQzhh+VEzOafB4SFOCwpRlc/BfbaLfqSs41fraajURLFkSIheRelXV1SGOfs 9Y3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=HkeHhnqkzSEVCG8RBViWFhN/hyIZCVQVxMZ4nK2bjs8=; b=0dd1szWe20OGPMNs0IDWZ2x9WAXZSELOy7Fiu/py8HAxd6F3K378hNeEg2vNPB/+pw BCipvuJNoji1j26km4FMZvF5CLuNtkhAfhkzHmCBaJsFgEZ6eybzZL1ggKWQRGih0Z27 pIiQMYVU2AkhGxvp4X0VXvoo9tnMiWwULYMTGn9NfkhW1YmHS4JQS9Q2REEIC29J3znO zmEiiQWcSwFuGwlhaP355aXJPQKhlZlaYPxbZ1gDtKCbwH/vVCDSSx1doVUL/vMAxfAc x4nARrlQQk1oSaFCEHHGdWuzFp+8nd8sHQ0q9VSHkOrqlDn+cyCQY3BfGi3+4mDarFmN TnpQ== X-Gm-Message-State: AOAM5303kTUzk2yH00WOB6wHj9khi4ow0ANm/1gfuaecM0HKwsGD5aN0 4KVyaWcGG7llJKIzQJGWHMkUxg== X-Received: by 2002:a5e:c00a:: with SMTP id u10mr5291469iol.60.1631244532538; Thu, 09 Sep 2021 20:28:52 -0700 (PDT) Received: from [192.168.1.116] ([66.219.217.159]) by smtp.gmail.com with ESMTPSA id h9sm1870320ioz.30.2021.09.09.20.28.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Sep 2021 20:28:52 -0700 (PDT) Subject: Re: [git pull] iov_iter fixes To: Al Viro Cc: Linus Torvalds , Pavel Begunkov , Linux Kernel Mailing List , linux-fsdevel References: <5971af96-78b7-8304-3e25-00dc2da3c538@kernel.dk> <88f83037-0842-faba-b68f-1d4574fb45cb@kernel.dk> <8d9e4f7c-bcf4-2751-9978-6283cabeda52@kernel.dk> From: Jens Axboe Message-ID: <4f9960f0-26bd-5972-3dcf-f2e2d63ea283@kernel.dk> Date: Thu, 9 Sep 2021 21:28:51 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/9/21 9:24 PM, Al Viro wrote: > On Fri, Sep 10, 2021 at 03:15:35AM +0000, Al Viro wrote: >> On Thu, Sep 09, 2021 at 09:06:58PM -0600, Jens Axboe wrote: >>> On 9/9/21 8:48 PM, Al Viro wrote: >>>> On Thu, Sep 09, 2021 at 07:35:13PM -0600, Jens Axboe wrote: >>>> >>>>> Yep ok I follow you now. And yes, if we get a partial one but one that >>>>> has more consumed than what was returned, that would not work well. I'm >>>>> guessing that a) we've never seen that, or b) we always end up with >>>>> either correctly advanced OR fully advanced, and the fully advanced case >>>>> would then just return 0 next time and we'd just get a short IO back to >>>>> userspace. >>>>> >>>>> The safer way here would likely be to import the iovec again. We're >>>>> still in the context of the original submission, and the sqe hasn't been >>>>> consumed in the ring yet, so that can be done safely. >>>> >>>> ... until you end up with something assuming that you've got the same >>>> iovec from userland the second time around. >>>> >>>> IOW, generally it's a bad idea to do that kind of re-imports. >>> >>> That's really no different than having one thread do the issue, and >>> another modify the iovec while it happens. It's only an issue if you >>> don't validate it, just like you did the first time you imported. No >>> assumptions need to be made here. >> >> It's not "need to be made", it's "will be mistakenly made by >> somebody several years down the road"... > > E.g. somebody blindly assuming that the amount of data read the last > time around will not exceed the size of reimported iov_iter. What I'm > saying is that there's a plenty of ways to fuck up in that direction, > and they will *not* be caught by normal fuzzers. If the plan pans out, it's literally doing the _exact_ same thing that we did originally. No assumptions are made about the contents of the iovecs originally passed in, none of that state is reused. It's an identical import to what was originally done. I'm not saying it's trivial, but as long as the context is correct, then it really should be pretty straight forward... > I'm not arguing in favour of an uncoditional copy, BTW - I would like > to see something resembling profiling data, but it's obviously not a > pretty solution. I can tell you right now that it's unworkable, it'll be a very noticeable slowdown. And it's very much a case of doing the slow path for the extreme corner case of ever hitting this case. For most workloads, you'll _never_ hit it. But we obviously have to be able to do it, for the slower cases (like SCSI with low QD, it'd trigger pretty easily). -- Jens Axboe