Message ID | 20230216091656.2045471-2-usama.anjum@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp199309wrn; Thu, 16 Feb 2023 01:28:17 -0800 (PST) X-Google-Smtp-Source: AK7set+MspBmiOGPHY42vdKTd2+7vqDxIzpsYq4aD3Qum9hR+KKEdlJktVOD0EU0WURBk93v+0uH X-Received: by 2002:a17:907:2ce4:b0:877:a3c4:807b with SMTP id hz4-20020a1709072ce400b00877a3c4807bmr7702519ejc.68.1676539697807; Thu, 16 Feb 2023 01:28:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676539697; cv=none; d=google.com; s=arc-20160816; b=cKIG0AGxQ1hcUttq5dfoVrk65uz5G4zWWc6RmwmGK5ZVWy8/GYq4ATgjmXZSzEXsNG 17u8e5a7hykcPtihemY7LKhV/TAEu10H9YQAuUU/PToHuHkG1piYKTfzTgO77calOJ+3 V1jRqVoReoihOOG9xu018u5a6On4g8VO1Diiv+s/VaWrgvh6JD4jR90llrfVNWnGEit5 THYc97fSKwOlsfL+DFBc+4uLtfZ7oBM3PlQ6tDrxJN/v7NuJESLpbxcvxoA6Lr+WtTnw 3OqmaE2irm7v9jWBwXgCvY9TLkO5snE2oO83TIGx41/wMN5FddLjoVp1U0mniqx8e7cX dMxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=K3lFMhak3aYOcGIprm04ZPQEkc3xI1jgYekJJdax6BQ=; b=Bff+PtK8UyxczYs+Qpm5MO4GvCiq880KS5WYLnVCPvPBvcpYBD0WZFqdwCo16vKZ8Z wpC+ElGjwvKQjlSrEjcKp0OfRdT3umoYOa35VvH91oqa64twdb4gbA8zfngUmRIAS7/o sGAVJD4LyLpJb3/ip4aHxp7NRP5Bv9a7iHmDODeUjM6C/DzKi7mYJZG1Uy7cGgWq+aki lf8XeYZZEazFqwBxBzNRuDtXslojy7/N5oMR9WTNCgITJLxPmW+vjMh303wgD/bSDSOp 95FKeBcrE3SZSi/5AeDwAuOpNMJkuBR3hfar5yZRqhKwTUT/dad54Nw9NBJhoeeE84U3 PwpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hXppeNF6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cm7-20020a170907938700b008b14042fa1bsi1418702ejc.255.2023.02.16.01.27.54; Thu, 16 Feb 2023 01:28:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hXppeNF6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229882AbjBPJSI (ORCPT <rfc822;hadasmailinglist@gmail.com> + 99 others); Thu, 16 Feb 2023 04:18:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229800AbjBPJSD (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 16 Feb 2023 04:18:03 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A59F82068A for <linux-kernel@vger.kernel.org>; Thu, 16 Feb 2023 01:18:01 -0800 (PST) Received: from localhost.localdomain (unknown [39.45.217.110]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madras.collabora.co.uk (Postfix) with ESMTPSA id B6820660219B; Thu, 16 Feb 2023 09:17:58 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1676539080; bh=eN35qv1LQnqiL94LOpdwsRPxsfQxNRRB3+34BVt+3/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hXppeNF6RgBlcVGgaFAGBHmpAy9Zonunn8zH1SUsH0SbgvHwyDQ6xVh8Q/nxGdKFs 495IqxX+srlyIzYUvEvCyQortt7XmNpJJD/9gIdbyZ9xQi17ioi30ymeUajEeWYC83 4NxxHC/EeJnyJ4XK54d7AW+2IbrnTU/NcELTXRrHUQhgFQDztv+lMzZJTkp6yUQXhI vhoIewxGXKTkkD1izP+GxMFpAbSmMDPfm3RIoIdfZEQDsAFclK60r940C6p4XqQx8T cVTO2CKICrClksWOIx5b2asP1noUwXIORO3Y9rYczrtt8n9apz+wXM8QatF6yS+gI3 AIGihfHZqYJfg== From: Muhammad Usama Anjum <usama.anjum@collabora.com> To: peterx@redhat.com, david@redhat.com, Andrew Morton <akpm@linux-foundation.org> Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>, kernel@collabora.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/2] mm/userfaultfd: add VM_WARN_ONCE() Date: Thu, 16 Feb 2023 14:16:56 +0500 Message-Id: <20230216091656.2045471-2-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216091656.2045471-1-usama.anjum@collabora.com> References: <20230216091656.2045471-1-usama.anjum@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757979290465422269?= X-GMAIL-MSGID: =?utf-8?q?1757979290465422269?= |
Series |
[v4,1/2] mm/userfaultfd: Support WP on multiple VMAs
|
|
Commit Message
Muhammad Usama Anjum
Feb. 16, 2023, 9:16 a.m. UTC
Add VM_WARN_ONCE() to uffd_wp_range() to detect range (start, len) abuse.
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
mm/userfaultfd.c | 2 ++
1 file changed, 2 insertions(+)
Comments
On 16.02.23 10:16, Muhammad Usama Anjum wrote: > Add VM_WARN_ONCE() to uffd_wp_range() to detect range (start, len) abuse. > > Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com> > --- > mm/userfaultfd.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c > index 77c5839e591c..d89ed44d2668 100644 > --- a/mm/userfaultfd.c > +++ b/mm/userfaultfd.c > @@ -717,6 +717,8 @@ long uffd_wp_range(struct mm_struct *dst_mm, struct vm_area_struct *dst_vma, > struct mmu_gather tlb; > long ret; > > + VM_WARN_ONCE(start < dst_vma->vm_start || start + len > dst_vma->vm_end, > + "The address range exceeds VMA boundary.\n"); VM_WARN_ON_ONCE is sufficient (sorry for spelling out the wrong variant earlier). These kinds of bugs are expected to be found early during testing, still it might make sense to implement a backup path if (WARN_ON_ONCE(...)) return -EINVAL; But we can't use VM_WARN_ON_ONCE here, so we can't compile it out anymore ... so I guess a simple VM_WARN_ON_ONCE() is sufficient.
On 2/16/23 2:24 PM, David Hildenbrand wrote: > On 16.02.23 10:16, Muhammad Usama Anjum wrote: >> Add VM_WARN_ONCE() to uffd_wp_range() to detect range (start, len) abuse. >> >> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com> >> --- >> mm/userfaultfd.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c >> index 77c5839e591c..d89ed44d2668 100644 >> --- a/mm/userfaultfd.c >> +++ b/mm/userfaultfd.c >> @@ -717,6 +717,8 @@ long uffd_wp_range(struct mm_struct *dst_mm, struct >> vm_area_struct *dst_vma, >> struct mmu_gather tlb; >> long ret; >> + VM_WARN_ONCE(start < dst_vma->vm_start || start + len > >> dst_vma->vm_end, >> + "The address range exceeds VMA boundary.\n"); > > VM_WARN_ON_ONCE is sufficient (sorry for spelling out the wrong variant > earlier). Will do in the next version. Thanks. > > These kinds of bugs are expected to be found early during testing, still it > might make sense to implement a backup path > > if (WARN_ON_ONCE(...)) > return -EINVAL; > > But we can't use VM_WARN_ON_ONCE here, so we can't compile it out anymore > ... so I guess a simple VM_WARN_ON_ONCE() is sufficient. >
On Thu, Feb 16, 2023 at 02:48:51PM +0500, Muhammad Usama Anjum wrote: > On 2/16/23 2:24 PM, David Hildenbrand wrote: > > On 16.02.23 10:16, Muhammad Usama Anjum wrote: > >> Add VM_WARN_ONCE() to uffd_wp_range() to detect range (start, len) abuse. > >> > >> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com> > >> --- > >> mm/userfaultfd.c | 2 ++ > >> 1 file changed, 2 insertions(+) > >> > >> diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c > >> index 77c5839e591c..d89ed44d2668 100644 > >> --- a/mm/userfaultfd.c > >> +++ b/mm/userfaultfd.c > >> @@ -717,6 +717,8 @@ long uffd_wp_range(struct mm_struct *dst_mm, struct > >> vm_area_struct *dst_vma, > >> struct mmu_gather tlb; > >> long ret; > >> + VM_WARN_ONCE(start < dst_vma->vm_start || start + len > > >> dst_vma->vm_end, > >> + "The address range exceeds VMA boundary.\n"); > > > > VM_WARN_ON_ONCE is sufficient (sorry for spelling out the wrong variant > > earlier). > Will do in the next version. Thanks. Shall we just squash the two patches?
On 2/17/23 1:26 AM, Peter Xu wrote: > On Thu, Feb 16, 2023 at 02:48:51PM +0500, Muhammad Usama Anjum wrote: >> On 2/16/23 2:24 PM, David Hildenbrand wrote: >>> On 16.02.23 10:16, Muhammad Usama Anjum wrote: >>>> Add VM_WARN_ONCE() to uffd_wp_range() to detect range (start, len) abuse. >>>> >>>> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com> >>>> --- >>>> mm/userfaultfd.c | 2 ++ >>>> 1 file changed, 2 insertions(+) >>>> >>>> diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c >>>> index 77c5839e591c..d89ed44d2668 100644 >>>> --- a/mm/userfaultfd.c >>>> +++ b/mm/userfaultfd.c >>>> @@ -717,6 +717,8 @@ long uffd_wp_range(struct mm_struct *dst_mm, struct >>>> vm_area_struct *dst_vma, >>>> struct mmu_gather tlb; >>>> long ret; >>>> + VM_WARN_ONCE(start < dst_vma->vm_start || start + len > >>>> dst_vma->vm_end, >>>> + "The address range exceeds VMA boundary.\n"); >>> >>> VM_WARN_ON_ONCE is sufficient (sorry for spelling out the wrong variant >>> earlier). >> Will do in the next version. Thanks. > > Shall we just squash the two patches? Will squash in next version. >
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 77c5839e591c..d89ed44d2668 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -717,6 +717,8 @@ long uffd_wp_range(struct mm_struct *dst_mm, struct vm_area_struct *dst_vma, struct mmu_gather tlb; long ret; + VM_WARN_ONCE(start < dst_vma->vm_start || start + len > dst_vma->vm_end, + "The address range exceeds VMA boundary.\n"); if (enable_wp) mm_cp_flags = MM_CP_UFFD_WP; else