Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp129423iog; Sun, 12 Jun 2022 21:32:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzG7DCz/Z/P/AXmjQqYwAZiiO0vuo5fbLtQTRCI+vk1h8Qx5yazvRwfj1kLW2/VLys0Ocgf X-Received: by 2002:a05:6402:26ce:b0:431:52c9:5a9 with SMTP id x14-20020a05640226ce00b0043152c905a9mr44555460edd.61.1655094757941; Sun, 12 Jun 2022 21:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655094757; cv=none; d=google.com; s=arc-20160816; b=xquKSmIDDfStbWLsVfILHzNmCVyE+PDUA51+FYyATziffYde1mjhyVz5BFboXINsIo S6G3OYy5M3MYQnEu+eTYDQAg2Wf2XdBqDdG7rs25kmGE1s1fGBZvzhtivA1Y5YFDVI1n jm6kxwV6oBTPVqUmrx60EE0GmDRx1pCMuU/2MckqK2+DVaNriFYPQ6pfXH/L8X3v966O Gh0t4EumO5O1BoCUDf3YEKGclzIXuVxyW+F9Rv++qaR83xlOZchnarTTDgs/fB953vBl rQvihYKTxM+2VSq9FV3LBhFk+43z/qddFK1tm+os3Ch+0rrbB8aCFKGRdmnOa5OEkXLd LPUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=GhvwGtANvQuSTVMPqK7IxNnDhsY33Zq7Pk8pkhDCiJU=; b=MQPkHPVk/c5pohs3chJ8/0it0ZI1aBeKn0B6HXvgVKdpe4YsWTAsPAGsL8U+yKy5jI VdHA+EJ8jZu9wyEGZTjdKuAdCddzqX8mLOOMmnCCCqNZEp6He0hYMJI2X5P2LOFwAtBd o8rcuIZiy2uT4eZjDFq/54n6sul6I88Js2Vo19Kf0nIoc7hbhk8pWhpSXdhKhgxVwyK+ FZpDf9AAmemmxAU7TrzSjGdQAUPp6UBjKT7nOC0gT9IDHWXgRfL4yXxKhT640OL5w50L Padnl7XWFaq/0Sl/ipbfj0ukemm8Kn5t09Ya4EBWsw90dsDEaV5QLHlG1NPAN6++q+xY iKgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=YgceE5qD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v24-20020a17090651d800b00715777cb7f2si5445356ejk.86.2022.06.12.21.32.13; Sun, 12 Jun 2022 21:32:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=YgceE5qD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230272AbiFMEZt (ORCPT + 99 others); Mon, 13 Jun 2022 00:25:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230140AbiFMEZn (ORCPT ); Mon, 13 Jun 2022 00:25:43 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D64F35FA6 for ; Sun, 12 Jun 2022 21:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=GhvwGtANvQuSTVMPqK7IxNnDhsY33Zq7Pk8pkhDCiJU=; b=YgceE5qD9fGWZa50WxH4nVDPhe fwjFxU49mvChJnWW4wrdwRRXEfJi2HwtXiLgK1k0HzYiJYwZZI9KuwdXOFX21Rfeypb51tsWcjEbL XY2Kv4IrcJFH9XBsLgqqf425IoJ7JzdGQr6DYASiQgT8PD0P3psj0KTvi/Mpfx8Fe+snctwyGB7lg +7XUwFLM8TzuBW+yFjV3bRywZcY/KTYBYFf4U9c6IZ/oIAr19xhLhrH6K8YSMozAb7EB7/xQNEuKE E1SLpS78NgZyGwIofPEQYg6HHnziyxoIcjSl54pegWdq7BpPHMUWWOxXvdVi0RML4H6ev6cBxGbaR iVGx7AyQ==; Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o0bdz-006cYj-Hj; Mon, 13 Jun 2022 04:25:39 +0000 Date: Mon, 13 Jun 2022 04:25:39 +0000 From: Al Viro To: Joe Damato Cc: linux-kernel@vger.kernel.org Subject: Re: [RFC,iov_iter v2 3/8] iov_iter: add copyin_iovec helper Message-ID: References: <1655024280-23827-1-git-send-email-jdamato@fastly.com> <1655024280-23827-4-git-send-email-jdamato@fastly.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1655024280-23827-4-git-send-email-jdamato@fastly.com> Sender: Al Viro X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 12, 2022 at 01:57:52AM -0700, Joe Damato wrote: > copyin_iovec is a helper which wraps copyin and selects the right copy > method based on the iter_copy_type. > > Signed-off-by: Joe Damato > --- > lib/iov_iter.c | 19 ++++++++++++++----- > 1 file changed, 14 insertions(+), 5 deletions(-) > > diff --git a/lib/iov_iter.c b/lib/iov_iter.c > index d32d7e5..6720cb2 100644 > --- a/lib/iov_iter.c > +++ b/lib/iov_iter.c > @@ -168,6 +168,15 @@ static int copyin(void *to, const void __user *from, size_t n) > return n; > } > > +static int copyin_iovec(void *to, const void __user *from, size_t n, > + struct iov_iter *i) > +{ > + if (unlikely(iov_iter_copy_is_nt(i))) > + return __copy_from_user_nocache(to, from, n); > + else > + return copyin(to, from, n); > +} Just a sanity check - your testing is *not* with KASAN/KCSAN, right? And BTW, why is that only on the userland side? If you are doing that at all, it would make sense to cover the memcpy() side as well...