From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f197.google.com (mail-wr0-f197.google.com [209.85.128.197]) by kanga.kvack.org (Postfix) with ESMTP id 1381F6B0003 for ; Fri, 6 Apr 2018 07:36:07 -0400 (EDT) Received: by mail-wr0-f197.google.com with SMTP id u13so635766wre.1 for ; Fri, 06 Apr 2018 04:36:07 -0700 (PDT) Received: from fuzix.org (www.llwyncelyn.cymru. [82.70.14.225]) by mx.google.com with ESMTPS id t15si7475507wrb.190.2018.04.06.04.36.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Apr 2018 04:36:05 -0700 (PDT) Date: Fri, 6 Apr 2018 12:35:45 +0100 From: Alan Cox Subject: Re: [PATCH] gup: return -EFAULT on access_ok failure Message-ID: <20180406123545.24953eb4@alans-desktop> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: "Michael S. Tsirkin" Cc: Linus Torvalds , 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 > so an error on the 1st page gets propagated to the caller, > and that get_user_pages_unlocked eventually calls __get_user_pages > so it does return an error sometimes. > > Would it be correct to apply the second part of the patch then > (pasted below for reference) or should get_user_pages_fast > and all its callers be changed to return 0 on error instead? 0 isn't an error. As SuS sees it (ie from the userspace end of the pile) returning the number you asked for means it worked returning a smaller number means it worked partially and that much was consumed (or in some cases more and the rest if so was lost - depends what you are reading/writing) returning 0 means you read nothing as you were at the end of file returning an error code means it broke, or you should try again (EAGAIN/EWOULDBLOCK) The ugly bit there is the try-again semantics needs to exactly match the attached poll() behaviour or you get busy loops. Alan