From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22DB9C76186 for ; Wed, 17 Jul 2019 11:09:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E95F52173B for ; Wed, 17 Jul 2019 11:09:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726831AbfGQLJe (ORCPT ); Wed, 17 Jul 2019 07:09:34 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:47864 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726189AbfGQLJe (ORCPT ); Wed, 17 Jul 2019 07:09:34 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6HB6DLo144968 for ; Wed, 17 Jul 2019 07:09:32 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tsytgfuwq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 17 Jul 2019 07:09:32 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 17 Jul 2019 12:09:29 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 17 Jul 2019 12:09:19 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6HB9I7C39190742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2019 11:09:18 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C29152063; Wed, 17 Jul 2019 11:09:18 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.8.168]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 366B052050; Wed, 17 Jul 2019 11:09:15 +0000 (GMT) Date: Wed, 17 Jul 2019 14:09:13 +0300 From: Mike Rapoport To: Catalin Marinas Cc: Andrey Konovalov , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, Vincenzo Frascino , Will Deacon , Mark Rutland , Andrew Morton , Greg Kroah-Hartman , Kees Cook , Yishai Hadas , Felix Kuehling , Alexander Deucher , Christian Koenig , Mauro Carvalho Chehab , Jens Wiklander , Alex Williamson , Leon Romanovsky , Luc Van Oostenryck , Dave Martin , Khalid Aziz , enh , Jason Gunthorpe , Christoph Hellwig , Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Robin Murphy , Kevin Brodsky , Szabolcs Nagy , Al Viro Subject: Re: [PATCH v18 08/15] userfaultfd: untag user pointers References: <20190624175120.GN29120@arrakis.emea.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190624175120.GN29120@arrakis.emea.arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 19071711-0020-0000-0000-00000354AA32 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19071711-0021-0000-0000-000021A87C56 Message-Id: <20190717110910.GA12017@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-17_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907170135 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org On Mon, Jun 24, 2019 at 06:51:21PM +0100, Catalin Marinas wrote: > On Mon, Jun 24, 2019 at 04:32:53PM +0200, Andrey Konovalov wrote: > > This patch is a part of a series that extends kernel ABI to allow to pass > > tagged user pointers (with the top byte set to something else other than > > 0x00) as syscall arguments. > > > > userfaultfd code use provided user pointers for vma lookups, which can > > only by done with untagged pointers. > > > > Untag user pointers in validate_range(). > > > > Reviewed-by: Vincenzo Frascino > > Reviewed-by: Catalin Marinas > > Reviewed-by: Kees Cook > > Signed-off-by: Andrey Konovalov > > --- > > fs/userfaultfd.c | 22 ++++++++++++---------- > > 1 file changed, 12 insertions(+), 10 deletions(-) > > Same here, it needs an ack from Al Viro. The userfault patches usually go via -mm tree, not sure if Al looks at them :) FWIW, you can add Reviewed-by: Mike Rapoport > > diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c > > index ae0b8b5f69e6..c2be36a168ca 100644 > > --- a/fs/userfaultfd.c > > +++ b/fs/userfaultfd.c > > @@ -1261,21 +1261,23 @@ static __always_inline void wake_userfault(struct userfaultfd_ctx *ctx, > > } > > > > static __always_inline int validate_range(struct mm_struct *mm, > > - __u64 start, __u64 len) > > + __u64 *start, __u64 len) > > { > > __u64 task_size = mm->task_size; > > > > - if (start & ~PAGE_MASK) > > + *start = untagged_addr(*start); > > + > > + if (*start & ~PAGE_MASK) > > return -EINVAL; > > if (len & ~PAGE_MASK) > > return -EINVAL; > > if (!len) > > return -EINVAL; > > - if (start < mmap_min_addr) > > + if (*start < mmap_min_addr) > > return -EINVAL; > > - if (start >= task_size) > > + if (*start >= task_size) > > return -EINVAL; > > - if (len > task_size - start) > > + if (len > task_size - *start) > > return -EINVAL; > > return 0; > > } > > @@ -1325,7 +1327,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx, > > goto out; > > } > > > > - ret = validate_range(mm, uffdio_register.range.start, > > + ret = validate_range(mm, &uffdio_register.range.start, > > uffdio_register.range.len); > > if (ret) > > goto out; > > @@ -1514,7 +1516,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx, > > if (copy_from_user(&uffdio_unregister, buf, sizeof(uffdio_unregister))) > > goto out; > > > > - ret = validate_range(mm, uffdio_unregister.start, > > + ret = validate_range(mm, &uffdio_unregister.start, > > uffdio_unregister.len); > > if (ret) > > goto out; > > @@ -1665,7 +1667,7 @@ static int userfaultfd_wake(struct userfaultfd_ctx *ctx, > > if (copy_from_user(&uffdio_wake, buf, sizeof(uffdio_wake))) > > goto out; > > > > - ret = validate_range(ctx->mm, uffdio_wake.start, uffdio_wake.len); > > + ret = validate_range(ctx->mm, &uffdio_wake.start, uffdio_wake.len); > > if (ret) > > goto out; > > > > @@ -1705,7 +1707,7 @@ static int userfaultfd_copy(struct userfaultfd_ctx *ctx, > > sizeof(uffdio_copy)-sizeof(__s64))) > > goto out; > > > > - ret = validate_range(ctx->mm, uffdio_copy.dst, uffdio_copy.len); > > + ret = validate_range(ctx->mm, &uffdio_copy.dst, uffdio_copy.len); > > if (ret) > > goto out; > > /* > > @@ -1761,7 +1763,7 @@ static int userfaultfd_zeropage(struct userfaultfd_ctx *ctx, > > sizeof(uffdio_zeropage)-sizeof(__s64))) > > goto out; > > > > - ret = validate_range(ctx->mm, uffdio_zeropage.range.start, > > + ret = validate_range(ctx->mm, &uffdio_zeropage.range.start, > > uffdio_zeropage.range.len); > > if (ret) > > goto out; > > -- > > 2.22.0.410.gd8fdbe21b5-goog -- Sincerely yours, Mike.