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=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 2CE52C76186 for ; Wed, 17 Jul 2019 11:09:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 019612173B for ; Wed, 17 Jul 2019 11:09:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Jh1BfbOX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 019612173B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Message-Id:In-Reply-To:MIME-Version: References:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vqvUcDN0zKdYWg05fq9hsnJJ5eQX2gWDDZv4dBPbu/Y=; b=Jh1BfbOXmiVLUQ mNmsejGP0sgroFOyskFHJPByJWJbeySK4yLjrIJOKmfr3HsVj6299qAi+8qSdg+OZxvi818qL0ptz toCpMwMd3u+SHxHSsR7Gz/gRVoc13ev9N1+MvFkCoMoqq1kVGx+zpvSMxZx3XlAl5m/053jJLdpOP Wa2sjKfCtjOYicuYxKqgwEokLmbx/uraHYgHIg6L4z87TiEUOt5IzrHhRZrCAQJj9VnPyrAje2xyB S3iMiTnudI6RbnxMw02a7AO7bV2KdEKy/3RmElwMAr+Ueyl44PXWmohjDJixR2ZPBNtRvZUNQkgpT C+ZquvzpBebU+1+vvpWQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hnhoa-0006Ko-FF; Wed, 17 Jul 2019 11:09:40 +0000 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hnhoX-000631-Fv for linux-arm-kernel@lists.infradead.org; Wed, 17 Jul 2019 11:09:39 +0000 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6HB12N9071339 for ; Wed, 17 Jul 2019 07:09:33 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tsy5t9bt5-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 Subject: Re: [PATCH v18 08/15] userfaultfd: untag user pointers References: <20190624175120.GN29120@arrakis.emea.arm.com> MIME-Version: 1.0 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-1907170134 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190717_040937_648030_83F0D03B X-CRM114-Status: GOOD ( 29.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , kvm@vger.kernel.org, Szabolcs Nagy , Will Deacon , dri-devel@lists.freedesktop.org, linux-mm@kvack.org, Khalid Aziz , linux-kselftest@vger.kernel.org, Felix Kuehling , Vincenzo Frascino , Jacob Bramley , Leon Romanovsky , linux-rdma@vger.kernel.org, amd-gfx@lists.freedesktop.org, Christoph Hellwig , Jason Gunthorpe , Dmitry Vyukov , Dave Martin , Evgeniy Stepanov , linux-media@vger.kernel.org, Kevin Brodsky , Kees Cook , Ruben Ayrapetyan , Andrey Konovalov , Ramana Radhakrishnan , Alex Williamson , Al Viro , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, Kostya Serebryany , Greg Kroah-Hartman , Yishai Hadas , linux-kernel@vger.kernel.org, Jens Wiklander , Lee Smith , Alexander Deucher , Andrew Morton , enh , Robin Murphy , Christian Koenig , Luc Van Oostenryck Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel