Received: by 10.213.65.68 with SMTP id h4csp2259837imn; Thu, 5 Apr 2018 11:45:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+TOz8b42GJfd20afI7TDfZE9y95d/jvK8vNBAMpCySFr3DRF4/rU6mk+kib9A/Bpu66U9t X-Received: by 10.101.83.65 with SMTP id w1mr15672401pgr.111.1522953900008; Thu, 05 Apr 2018 11:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522953899; cv=none; d=google.com; s=arc-20160816; b=SjJRGr/Y2WU0ms7MIkjoDjBOhorrKTNfBSY4CaopvIP6NEi1olKL9mAMUTVpJJMbcz /QApFF2VP3DwtmFUKM/1VeKnFmYBdPbAqEQqGywK3sv4r96s1oN9iXrfbrWJxcSiXb2j cZPv17emAa+SgvYGX1KpwufoDK4qpBkfgZdG/fzRBIU5j3zn0padptEpjxaHbnEuaf3Z rwuhECeJsb+tmWeFMUliLCXH4A3BPexlqfKqZJlIYFaO0gocLITcsvlyxOp9VOzLUaog ORdbDO1HKmuqB9vO0ZX4gPOrxjief8ZYU2Pz+alfzfI/5OJ3f8/mYpF8cy1WrxurgSLA Xvcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=DZqcsvjdGu8ok9xB3iUUclQrt0sAULOePRuvdEXd+F8=; b=1AC6Ssf4ksuAcT426oSBG2TsrkEDEuihsx1O75b1sVZrbAGFYt0A6sf0OWcCG7/Ra+ QkTX/6eEN3ka4AFfhBOSxY8Px5EwNdE1kVs+rHfWrEpQmxHC+RpNALxdB/gWJw7oOpba xCSUHKZ0AeEIB+EXhGV6YSAq5eweL6wfF4SVhlLeP/Bb4WPZ+10o5j55QQYcKHccBShY /hRrojzGEaEz0FF+5fCjDTLZGOHsVwdd16Aq9GcXiaVRTJU9nNttqQWwy3+dxEK7X+ph mMUfxBicYsm3clhYm4FKkMbzuv9Di+XZY+5AXIim62AD8//lLQ4qgZ3K3PzBrTliwmYi 0ULQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=jNYc+qIw; dkim=fail header.i=@linux-foundation.org header.s=google header.b=U8NXEjdg; 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 l7-v6si6864083plk.380.2018.04.05.11.44.45; Thu, 05 Apr 2018 11:44:59 -0700 (PDT) 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=fail header.i=@gmail.com header.s=20161025 header.b=jNYc+qIw; dkim=fail header.i=@linux-foundation.org header.s=google header.b=U8NXEjdg; 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 S1752014AbeDESnd (ORCPT + 99 others); Thu, 5 Apr 2018 14:43:33 -0400 Received: from mail-io0-f175.google.com ([209.85.223.175]:41618 "EHLO mail-io0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751973AbeDESn3 (ORCPT ); Thu, 5 Apr 2018 14:43:29 -0400 Received: by mail-io0-f175.google.com with SMTP id m83so31760479ioi.8; Thu, 05 Apr 2018 11:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=DZqcsvjdGu8ok9xB3iUUclQrt0sAULOePRuvdEXd+F8=; b=jNYc+qIwGto13UgwLyj4BR3HEjP4/ZKrEIDfhioKosKDYk+VFCbtWVkU28yXWk+iJI DDOHN3sfMcD8+cMezKul/1elshjiIREj7yQQOOCiMe3J0LbFn8Ryfi7sBmN1k7IJgLyI WRCJNglSWociUDP/ZBv0ROZml2991vEpJ6u+Q6ceUbTScCZ6WdgCo6TqRosQWKftPyCI YrUnh0pt5DSDGv3ZRz1LmLBNnEozWb3tge5ThjEKDXL0u7wk3c3wyWd3HdUWNxH52ggZ q40mwMXhzuQTk5UdhGXRv5tmUvjMpkvGMTNTkoRahtu2mrIo5j7ehA5GADxa7b4feMJ0 jCgw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=DZqcsvjdGu8ok9xB3iUUclQrt0sAULOePRuvdEXd+F8=; b=U8NXEjdg2wkGG79DSL6VS5Ev+hLS9P752oyunbZPUXpRcQg3R4U8FHXDXfNpdoDZUK 4dAp6C/B8QWqztMNQlk+wZrnfLRVM8C/Er1g6rL+tQxqIwYraBV7xo5eW9tF5zbFzfQ+ /VpdssIt+tCfrymFUwTE7nv4nOY0KGfUptcZI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=DZqcsvjdGu8ok9xB3iUUclQrt0sAULOePRuvdEXd+F8=; b=ZKdArE69r4Mwkz4r0T2WyoGunbxG1NWC2+bZcllpjxXNK1YZ8SRVHt2lIW9Lb+zorW 8PnQTcP3yrM0AupMfrb17tILGbNSHG4j1fA/Etgic1cfwIfEMiM9SIW0vQKHEnOvpZZf GPTjXdrqE5D31oYiCBpA+9onevN1SgbrOlHDV/U23tUkfR1hQbmo27HIxP+WlOyWMOlO IItqCDuTFEOvEaK2gV9x27AcLtFDjrYdsO6RJYC4KazWyr6ACfcOyCEp97zrvL53GCTj z/ikzntOlIFsA/u9EFZrqcqYBJxq61t+XYy4FG9XzLa17s3L+qg3MYxZsuEbZFbl4KfO MbDQ== X-Gm-Message-State: ALQs6tDCzdjoNVFfiL6RsH22r0EBscb/l61pD6bL3ucyxGFzGGTr5yqI dBHglMrg3cTLuZgfZdCxGIGvoBzoyJntTPpDkL0= X-Received: by 10.107.12.201 with SMTP id 70mr21686265iom.48.1522953808249; Thu, 05 Apr 2018 11:43:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.95.15 with HTTP; Thu, 5 Apr 2018 11:43:27 -0700 (PDT) In-Reply-To: <20180405211945-mutt-send-email-mst@kernel.org> References: <1522431382-4232-1-git-send-email-mst@redhat.com> <20180405045231-mutt-send-email-mst@kernel.org> <20180405171009-mutt-send-email-mst@kernel.org> <20180405211945-mutt-send-email-mst@kernel.org> From: Linus Torvalds Date: Thu, 5 Apr 2018 11:43:27 -0700 X-Google-Sender-Auth: 3qYC2e4XU2TscrglRHB_xmJDn-4 Message-ID: Subject: Re: [PATCH] gup: return -EFAULT on access_ok failure To: "Michael S. Tsirkin" Cc: Al Viro , Linux Kernel Mailing List , stable , syzbot+6304bf97ef436580fede@syzkaller.appspotmail.com, linux-mm , "Kirill A. Shutemov" , Andrew Morton , Huang Ying , Jonathan Corbet , Peter Zijlstra , Thomas Gleixner , Thorsten Leemhuis Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 5, 2018 at 11:28 AM, Michael S. Tsirkin wrote: > > to repeat what you are saying IIUC __get_user_pages_fast returns 0 if it can't > pin any pages and that is by design. Returning 0 on error isn't usual I think > so I guess this behaviour should we well documented. Arguably it happens elsewhere too, and not just in the kernel. "read()" at past the end of a file is not an error, you'll just get 0 for EOF. So it's not really "returning 0 on error". It really is simply returning the number of pages it got. End of story. That number of pages can be smaller than the requested number of pages, and _that_ is due to some error, but note how it can return "5" on error too - you asked for 10 pages, but the error happened in the middle! So the right way to check for error is to bverify that you get the number of pages that you asked for. If you don't, something bad happened. Of course, many users don't actually care about "I didn't get everything". They only care about "did I get _something_". Then that 0 ends up being the error case, but note how it depends on the caller. > What about get_user_pages_fast though? We do seem to special-case the first page there. I'm not sure it's a good idea. But like the __get_user_pages_fast(), we seem to have users that know about the particular semantics and depend on it. It's all ugly, I agree. End result: we can't just change semantics of either of them. At least not without going through every single user and checking that they are ok with it. Which I guess I could be ok with. Maybe changing the semantics of __get_user_pages_fast() is acceptable, if you just change it *everywhere* (which includes not just he users, but also the couple of architecture-specific versions of that same function that we have. Linus