Received: by 10.213.65.68 with SMTP id h4csp2083821imn; Thu, 5 Apr 2018 08:41:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx49lOr46h9OdQN0Ovbqvj/Q4kkJ8zLZfPPBQCUdqG4EnogeV6ptkjLHUJfs2DVec/pMuKwG3 X-Received: by 10.98.165.19 with SMTP id v19mr17627012pfm.51.1522942905163; Thu, 05 Apr 2018 08:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522942905; cv=none; d=google.com; s=arc-20160816; b=aIBaEprOSfVhdPh+Y6po1cwbcS9IHuWqwkFg24bKAsXQ8i7NvmP00jwAnn350ajvXD gNqltFdne+wRRS2u5zbbTaRQnrNqWHi45XP+Sqmcf1jpLfa0Ttd2lDalRZITqiVqG8wS w8aIpp67c3O5LfGlGlPEkRJODrK6QNz2eUEhhzyDiWI/RfavCb+2EJbW9MHBpeM1iPPd uXOJ7TpBc/iLD603gJ2yjOUx5Lj2naRn5m1Fh85p50i+iorl9aCAoMRXuqwhAVzCRA6w XtkLDcl2+HMt1temVen9S4aBzaPbVv8lzQqDU1ICLyOePWOMihIxgVXYRULAfAe6sCd4 HjyQ== 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=V1iMT86t3f7cVH8gxJA2Jujtn55VxGYxQNqx4EWKhxk=; b=rNWuvhnbDHBj9d3c+oiLP7xsE9s7kfp6JGZ9+OUHvvSAf4KX8zs9z9Ak5/t9SaMWQA clVhHb8IbHlh9zuqNki5wJ9SowLrNnjCqtxAKOdw7Si8eYHRR2DWywxIswa9HrR65h8x Fi37mMjbxQMgSZU91VNLNRtg44A+ZugpFbGUq9AyJiI1oBfiyrIBbc6YzLv6Q9XRVzwv 3NHXz8yIz0nMX/mVDwNV7XYT/ywZm948AHqoAk0syAQ/vTgBmmlW8GndOvvwu15Uo8zp Ox1Ute+GUb9xuS3v/FoG8bNifPMlCdXIClV1WItJX5Zyd+yoDTznXIDlriqu0RiNprmf Hl/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=LUbhtONv; dkim=fail header.i=@linux-foundation.org header.s=google header.b=iL61lSzw; 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 z62si5580851pgd.819.2018.04.05.08.41.30; Thu, 05 Apr 2018 08:41:45 -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=LUbhtONv; dkim=fail header.i=@linux-foundation.org header.s=google header.b=iL61lSzw; 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 S1751356AbeDEPkJ (ORCPT + 99 others); Thu, 5 Apr 2018 11:40:09 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:43618 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750835AbeDEPkH (ORCPT ); Thu, 5 Apr 2018 11:40:07 -0400 Received: by mail-io0-f195.google.com with SMTP id q84so31114154iod.10; Thu, 05 Apr 2018 08:40:07 -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=V1iMT86t3f7cVH8gxJA2Jujtn55VxGYxQNqx4EWKhxk=; b=LUbhtONvRu+DubJchx3Rhm0FCnJt7J3Wh/X8LaxqwxGI5x4Ua0RhrXwqdxNA9qJVXk f6iMT2oL8PXNlgcXxZf0poYQzsW4ivmzdYGfcaCp4XfLOXuG7Ip16tB2kbD7mwSqFp7E rSPfcwZVSHP70i6fjj8FwJjc1x5s8vOEHYZDSNFNl7+YQUK65gsh0yOcPB0ialNaFMEq 6/9dOk1mvu07lvA2lmh6VdW787aHVeJB1wPAuvbzENd6/taJiKFJG+Y6KYuYKRD3yn4m HxjdJu/Ho5RrFondKyMwFvfYxZM7rIZz9qmW+98MqJRIHLUF+SUhN0OSmQWjJP7worfT o7NA== 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=V1iMT86t3f7cVH8gxJA2Jujtn55VxGYxQNqx4EWKhxk=; b=iL61lSzwIvfMLMATZojVg54gaW0NkWtOwtzJxKi/uXr9wWq7jai7tluMiKNG+B03hd eXiSulryyLG2Lq+sOZRKayrIMRvk8W1O1yFHTDT/7Q0UoDxTL5cn/37B0SUe/wSMlSru 9fLcId47OTgt0pzkVDVW/dzwWXWXznPIKWI2M= 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=V1iMT86t3f7cVH8gxJA2Jujtn55VxGYxQNqx4EWKhxk=; b=Ron1Lu3ntHtUymBWVk9bUtq5L9MbfEpdu6S0UOu5qai/Alwgb1VYAJYNHxN54PVwOP m3iueBrvjAfXMc535N4/LoYIJdtm1VbpcIgailIIyLlxK0XJBgyur7ZgRG6PPB09kJ4o 5jrjWogzpRvIdwq52jVQN9YsY9ttpckOOppLnnS/orw9EfZ2OCzd/5HHBlUyy9vlCwrU Kx+z0J64J0SusnFkcetPElMVNmAyyCS5kIoFocNdE9EKMQxNdnl5FgCDetRRkr8GjYpY Y+KVu0flt4CW9uvfuCwIuiZCxG37vULoNWfF+fzjns3rQEUOF88PhRbEX8cZynUmRsDT Nrpg== X-Gm-Message-State: ALQs6tBrOSSRSqgl0d+f2+6QyIJizwJCOZZ6FV5Rj0UJIWBKhhaCIwg/ HZQA53Xk4mvytWaKDseQ2v7kgya0zXH/L8fDtlU= X-Received: by 10.107.164.13 with SMTP id n13mr21934788ioe.238.1522942806446; Thu, 05 Apr 2018 08:40:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.95.15 with HTTP; Thu, 5 Apr 2018 08:40:05 -0700 (PDT) In-Reply-To: <20180405171009-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> From: Linus Torvalds Date: Thu, 5 Apr 2018 08:40:05 -0700 X-Google-Sender-Auth: kPY2nTktOeYOwjUGH7RrS07UZbk Message-ID: Subject: Re: [PATCH] gup: return -EFAULT on access_ok failure To: "Michael S. Tsirkin" , Al Viro Cc: 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 7:17 AM, Michael S. Tsirkin wrote: > > I wonder however whether all the following should be changed then: > > static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, > > ... > > if (!vma || check_vma_flags(vma, gup_flags)) > return i ? : -EFAULT; > > is this a bug in __get_user_pages? Note the difference between "get_user_pages()", and "get_user_pages_fast()". It's the *fast* versions that just return the number of pages pinned. The non-fast ones will return an error code for various cases. Why? The non-fast cases actually *have* various error cases. They can block and get interrupted etc. The fast cases are basically "just get me the pages, dammit, and if you can't get some page, stop". At least that's one excuse for the difference in behavior. The real excuse is probably just "that's how it worked" - the fast case just walked the page tables and that was it. Linus