Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AE35C61DA4 for ; Thu, 16 Feb 2023 09:18:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbjBPJSJ (ORCPT ); Thu, 16 Feb 2023 04:18:09 -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 ); 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 ; 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 To: peterx@redhat.com, david@redhat.com, Andrew Morton Cc: Muhammad Usama Anjum , 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add VM_WARN_ONCE() to uffd_wp_range() to detect range (start, len) abuse. Signed-off-by: Muhammad Usama Anjum --- 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"); if (enable_wp) mm_cp_flags = MM_CP_UFFD_WP; else -- 2.39.1