Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp3013930lqz; Wed, 3 Apr 2024 15:46:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUnAAYf1RX5j1hZ3hVVsdRTbxuuMim+8giG5B8k4QL++cZI8huaJ6mKrQukJCo01dQ4Rb5swJRtIJY3V/KeOZImTA5Wv11qjmlBZMwC2Q== X-Google-Smtp-Source: AGHT+IElqvCktigo35yUMy/+b86JAHMRwEeuFyY9vBO2nUnQ6LJ7j8TMTldraG5lqh2cWF8+N+ns X-Received: by 2002:a05:6870:9603:b0:22e:9c5a:233e with SMTP id d3-20020a056870960300b0022e9c5a233emr777695oaq.43.1712184365288; Wed, 03 Apr 2024 15:46:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712184365; cv=pass; d=google.com; s=arc-20160816; b=P6mAyYFIEQsqTxaxx0poEDO75gZpoBl5d9aqgYUArpl4JMHA44FOdJS8/mJ4wqldt6 7oGxPZFwFYy1J9NYZOak05rApFifzNB/6rLn6e6utP2sF6wvosNKE1SnVK8hkeElC+Xe i/56TM7DpCIXX2JZOyuD3Mw4rr6RG1GSNxwVOtn/5lfsMm9vKwIxXtAnd369JVZQXREl VjVl+0EwjO6aKylXkVEY5mbsC+bMcxELtNbB3K6CG6XPVJrZvEINdstTMwuQFSt0zfwa fPxg2jMHIyW+qUaix6LPGPUWg0IJQ8FY3guBwTvA8c+MLvGeBZr64FrXOpFKgJQOLy9p GNiA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=zlKZnL7sDm8BDCMejJeZM50ZtuMxH0tQsMbjPb3yHD8=; fh=oA3V8ARPOSpr84T+i6QYtNgpLHOc/8pugSGyO/YUNHo=; b=URLX+UIrseuM4PSM6Zy6ECI7YMqHUEOPBsHZupYTBmtxuBqLksa6FgwrXl7/7W/LaX wlpVrUI/3V+cOnYqrG6tfQfrLpPIntJsnz5K+j3U8NZeaOEpi30auyaYftO3pCte6gQt gD+kPdC+hzEETtQdWnp5eX2DNDRfJGoh3TP6w7F7qLhxXYk4714D4rMtGAhzQ+IUojjP QWHOpuEc6VtJMecb0FJVrb7qJzc4HegFix0QkFrFzIxD+F1hKf+l0bRJr1TqMb5NZ/yV iZewKoOpBPW1NUQieqaH9Yb4hOrkCUAzCsEbFxzXX/qXOqTrz1QMMtVynIMaTxTga50k 4QDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b="t2ncr//f"; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-130700-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130700-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j21-20020a63e755000000b005dc957fe128si13639461pgk.74.2024.04.03.15.46.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 15:46:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130700-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b="t2ncr//f"; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-130700-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130700-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E8348285A67 for ; Wed, 3 Apr 2024 22:46:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77D69156253; Wed, 3 Apr 2024 22:45:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="t2ncr//f" Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF2C01757A; Wed, 3 Apr 2024 22:45:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712184355; cv=none; b=XV0ZlqXRhdSpHd2bUCoC3QzVordKlsrMX68mi6jVa5hqmYJv81sb7VuTMHMomPcCrR/bxWis5DQ5kEqmfZl9aCuGw8UYaMzHS0R5Wu7KqpfmbtPSOy+UkTMK1CuLyHYmqwhjX1kvwA4hAV2N6A37m5KGQ/GO428FbKA5m8LSDQE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712184355; c=relaxed/simple; bh=Wl13HCQUnod0lTUKQ6DNuqqLHcv1UPBQ6Mocvat/Q3E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OrH3uBCPSMVU0Ltm9TKU9jkyIxQHhV4Y0cuZrRrQqRkg3S5vpgWyzsR8A3gE8Em9iaZIZ+kfpGfcGkEQEJHAbkQKiVJz911ZjXkUSLlUWP8xlWS/L4ZnoWdWMP9+RnRuWGBFx4LyxOEYDa2MlNOJ3XWc+Wz4mdvX6JwPMDpwkqw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=t2ncr//f; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk 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=zlKZnL7sDm8BDCMejJeZM50ZtuMxH0tQsMbjPb3yHD8=; b=t2ncr//fpGvPtpESJNxRb6/ovo c8kDk5LFRDFeqtIIPAWZbXg37VJMBMuLM/WrbBwybND37YVoNxDknuqeN4Xzx4n0yyAeyzIpXpD8n aRVrbdxNoGlYBges4TbCTHcW+TYHr5QBZYfmd/uYwq6HaTcmvZlvePB78sLuJFjRgp6/6R0bxL2nF QFdzEU0ksQQEYlIl4+vky3ogrI2/xGnyFkZMmoVNm7SiLB5q72L5gfUKSC/wxWD8fSciZFOQJtuYD Vzc2GB6F6rX/U93Bbdlsfwg1coD6Hc0w4G9ooDWlpfQe/RkjSnuy3VTFTdUqRruF87O2IGYqfJLC7 4hfCSTGQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rs9Md-005Bdo-27; Wed, 03 Apr 2024 22:45:51 +0000 Date: Wed, 3 Apr 2024 23:45:51 +0100 From: Al Viro To: Jens Axboe Cc: linux-fsdevel@vger.kernel.org, brauner@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] userfaultfd: convert to ->read_iter() Message-ID: <20240403224551.GN538574@ZenIV> References: <20240403140446.1623931-1-axboe@kernel.dk> <20240403140446.1623931-3-axboe@kernel.dk> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240403140446.1623931-3-axboe@kernel.dk> Sender: Al Viro On Wed, Apr 03, 2024 at 08:02:53AM -0600, Jens Axboe wrote: > - if (count < sizeof(msg)) > + if (iov_iter_count(to) < sizeof(msg)) > return ret ? ret : -EINVAL; > _ret = userfaultfd_ctx_read(ctx, no_wait, &msg, inode); > if (_ret < 0) > return ret ? ret : _ret; > - if (copy_to_user((__u64 __user *) buf, &msg, sizeof(msg))) > + _ret = copy_to_iter(&msg, sizeof(msg), to); > + if (_ret < 0) > return ret ? ret : -EFAULT; Take a look in uio.h - you'll see size_t copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i) in there. See the problem? > + fd = get_unused_fd_flags(O_RDONLY | (flags & UFFD_SHARED_FCNTL_FLAGS)); > + if (fd < 0) > + goto err_out; Same comment as for the previous patch.