Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp447990ybv; Wed, 5 Feb 2020 08:18:40 -0800 (PST) X-Google-Smtp-Source: APXvYqw9YtRJuyaUfa1VUnfP3MrW/08cI+xg7XkZKszp5m5gViGPAiO+ba8ajdRsDF4P58OpIC0O X-Received: by 2002:a05:6808:aa8:: with SMTP id r8mr3337781oij.7.1580919519924; Wed, 05 Feb 2020 08:18:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580919519; cv=none; d=google.com; s=arc-20160816; b=s0In7uZm4H6fNQ7EjLcFJOY3Za6ms31ptrzPc4VQDIFSrOo2PS3vL/FwjgvMSlOV9l Iw5lBnlDQopzpHLvUhtuXZawljmuFWBbsUQ4OUQXCFsOMF7cCOsn+mSgrVbHMXTUEnQ8 C4xbjtKGDQ4ejHFeeu95eJfIOTSnY0O7VnKyGQitNMKrXbrUENjg2UWw4+zoZJtFXuBH m5z6CSutohI0j5d/4o/D2JIx5+H9KwCCqyl5WtCKZo9bUfQTIgOvUfKylA4zaeHdCA1L dzteK7cN4aTifizhGABwPzSseh5k86jM+6Z2KZ5Qm+bglArVuPWAIPjQBTHHeFaNtrKM OY2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:to:from:subject:dkim-signature; bh=7fnEMkwzTHdpkgtBHgX/yCKrRgu+mReSL+3/dsveHJo=; b=cYVapnrA8UbTTUQJYFfs9ShPw2EjUgCLmgPnzQv1Y1BQPmPi+uCKMduNr2Nr4Fo+AP 8j4cmN53KMJe95Ern+z+LvabqCEj/RbnKBvR8ZCdWMAawfBcIV1IPJ6m3upv/lymWlMZ w4T0y0ndObjXBCntsAYVGheEnNLqIrCMV+k2xMLKxrdrSUG+n24GSnKiW8DQGjbvFyDy tjeygxGJvOHyyVWCYYJRYvjFdTWRqafR6zZ2asBJic8RVsqBWfsUbYP1dc6CPrEOqOf/ FZRzdqzd9Yvy3PHT5mxnWwUbLS8eszLjyt6g89nyckJxpJNbqA50lZ/MzvD+sVD2XE31 WUbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=lhyawHAr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l5si13685104otn.35.2020.02.05.08.18.26; Wed, 05 Feb 2020 08:18:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=lhyawHAr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727116AbgBEQQ6 (ORCPT + 99 others); Wed, 5 Feb 2020 11:16:58 -0500 Received: from mail-il1-f193.google.com ([209.85.166.193]:33538 "EHLO mail-il1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbgBEQQ6 (ORCPT ); Wed, 5 Feb 2020 11:16:58 -0500 Received: by mail-il1-f193.google.com with SMTP id s18so2357323iln.0 for ; Wed, 05 Feb 2020 08:16:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:from:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=7fnEMkwzTHdpkgtBHgX/yCKrRgu+mReSL+3/dsveHJo=; b=lhyawHArSLhT69zDHi2XFHPwC9wcSw9kWWwugQ3p8LmspyLVMoMRRuYLbv9s656P/L 3sn3D/OIBjIJTJ8eUHAVMSbbCN3RrLYij6FKndLytnGo+8x9mueIu8ItdJwCPMxX5kiF mTB6+avniaTA8DZ2Dfop5O5mqcwK6i2ql0xQEM1hDYP3fa/vog4C26jCCJeRZXYHEt3j 5KKs+7CL1HoehVveZydAG9M2meCTW4b59EFAWecdiDKTMJ5bUS37uNRFwRQTtBL8UI85 mQmgSGVMj0ElCN7mRvWoDgcCeqpyt5SwUTXlPcYE+HKjXtbvOrXBhddZDXmD/tDqe7DX 9yKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=7fnEMkwzTHdpkgtBHgX/yCKrRgu+mReSL+3/dsveHJo=; b=auIJ8u9gzujzh4ZfGUzYB4vDUtJdF/OHkSZPmzYS9FUC9uzcA9KFK/tZJKunhu5Wy5 zgLptRCbrystkGu3Pqj/E1EIsnrRdNMveWPSCrrFvEAewYFA6ic8BXVdcrc/Dhw2hPHc 1D0DBZKJg54IJAFTz5ViW6xahKQmop+64mGYpFuT//3TkVLun4RcfpP4y6hSRJncYjKe xL96Wf3ijZ92t8hDDoDcjdlO2G47ym/KZe62BjV43BFWxYtuUCK+3Qlhj+p4dUpvpL2D inF5YSH5ErWPmIgwSVvWE7IgtahRa7ZrDJEPo7wBOFCZOgeC9p8aPdAJnCO4/8wlW4X3 +ZEQ== X-Gm-Message-State: APjAAAUDUkHvQZaEZnzZZlvIOzVe1El9rcUdQPM0ebLo+G24GppOkaxi TVS6wadMAVZNxkXA9fH2tfDoZAQ3Zc4= X-Received: by 2002:a92:8808:: with SMTP id h8mr24352201ild.253.1580919416694; Wed, 05 Feb 2020 08:16:56 -0800 (PST) Received: from [192.168.1.159] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id h4sm3173ioq.40.2020.02.05.08.16.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Feb 2020 08:16:56 -0800 (PST) Subject: Re: [PATCH] io_uring: fix mm use with IORING_OP_{READ,WRITE} From: Jens Axboe To: Pavel Begunkov , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org References: <951bb84c8337aaac7654261a21b03506b2b8a001.1580914723.git.asml.silence@gmail.com> Message-ID: Date: Wed, 5 Feb 2020 09:16:55 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/5/20 9:05 AM, Jens Axboe wrote: > On 2/5/20 9:02 AM, Pavel Begunkov wrote: >> On 05/02/2020 18:54, Jens Axboe wrote: >>> On 2/5/20 8:46 AM, Pavel Begunkov wrote: >>>> IORING_OP_{READ,WRITE} need mm to access user buffers, hence >>>> req->has_user check should go for them as well. Move the corresponding >>>> imports past the check. >>> >>> I'd need to double check, but I think the has_user check should just go. >>> The import checks for access anyway, so we'll -EFAULT there if we >>> somehow messed up and didn't acquire the right mm. >>> >> It'd be even better. I have plans to remove it, but I was thinking from a >> different angle. > > Let me just confirm it in practice, but it should be fine. Then we can just > kill it. OK now I remember - in terms of mm it's fine, we'll do the right thing. But the iov_iter_init() has this gem: /* It will get better. Eventually... */ if (uaccess_kernel()) { i->type = ITER_KVEC | direction; i->kvec = (struct kvec *)iov; } else { i->type = ITER_IOVEC | direction; i->iov = iov; } which means that if we haven't set USER_DS, then iov_iter_init() will magically set the type to ITER_KVEC which then crashes when the iterator tries to copy. Which is pretty lame. How about a patch that just checks for uaccess_kernel() and -EFAULTs if true for the non-fixed variants where we don't init the iter ourselves? Then we can still kill req->has_user and not have to fill it in. -- Jens Axboe