From patchwork Thu Feb 16 06:41:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13142664 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C690C636CC for ; Thu, 16 Feb 2023 06:42:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F5C76B007B; Thu, 16 Feb 2023 01:42:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A6386B007D; Thu, 16 Feb 2023 01:42:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76CCA6B007E; Thu, 16 Feb 2023 01:42:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 67E3C6B007B for ; Thu, 16 Feb 2023 01:42:28 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2FDE71606C8 for ; Thu, 16 Feb 2023 06:42:28 +0000 (UTC) X-FDA: 80472211176.18.BD3830C Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by imf03.hostedemail.com (Postfix) with ESMTP id 77E1120004 for ; Thu, 16 Feb 2023 06:42:26 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=gtjiguMc; dmarc=pass (policy=reject) header.from=collabora.com; spf=pass (imf03.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.172 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676529746; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ljirQrVNPG5UDLJtYd2F8HCRXiJQ1e82Nq6Ygyb5EHw=; b=lIFBLjO6T5T+6lSAK4T4Kky/yGISf0jcHXuqad34bU3fyge/xmCfvgRfUcuADSFMGl7jmf 6VkoiGDhjNLGKth50NWoromiPTxG12fYlkFCqhrVLay2qliJdLcqUWcPqezwwn1ulN21I+ uD5+yj8HgFEgloirTpGIXlMQnDA4HJ4= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=gtjiguMc; dmarc=pass (policy=reject) header.from=collabora.com; spf=pass (imf03.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.172 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676529746; a=rsa-sha256; cv=none; b=sxFpMei5yegjsFiFTyZH7rfKvXH2icbyjxNn4coEVyOmNf27qsTsapOlck7znFcOh8R0Wf 34FefefW+T9hU1Y25CoGlu7RiA0Y2qxx/yz5mDwV4MBBrrO+8opcoAdlrJ6EqpiDDIhAoK z0Mo/TKD9KKa/2rOy80+PQDKpwpNhRE= 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 1A30A660219C; Thu, 16 Feb 2023 06:42:22 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1676529744; bh=M7QlyqeYtV2UlnIzxGzDOtk3LV88X9UD8SBF1GKpk74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gtjiguMc1ox/cRrtHwHMVCqqQKZjlivuix+mk2HPqBPG0RDTXnrodYWaI33paHuT2 MnwrFREwKzaKSWE4XnItQrhajqD7F0D157Z2RfM9dNiDbjJiDTQhmzsGQ3i2uV1894 XkGgRXEOoJkI9C2vP/GYdQWub0zjuVk9yFx+t0Otn/cMUzWpmHSUQA+0cqTHuKiZw5 SM1z4Efw1toiuoAK0+ztCcENXZKBC8sA250DbD3XN0MPZABXkwMawCyZqxyFyw1G3c YhXFry0lnJ8Q2INWo0qqRV+lFMPLF1AgrjUgUkIO9SZVG4KqRza2PNt4LRcDeceNDG O+rbk+iToXINw== 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 v3 2/2] mm/userfaultfd: add VM_WARN_ONCE() Date: Thu, 16 Feb 2023 11:41:55 +0500 Message-Id: <20230216064155.1500545-2-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216064155.1500545-1-usama.anjum@collabora.com> References: <20230216064155.1500545-1-usama.anjum@collabora.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 77E1120004 X-Stat-Signature: ozqd95gqj1phqxp1eniqz3ors8ypoigi X-HE-Tag: 1676529746-38986 X-HE-Meta: U2FsdGVkX1/A8IMhtb78ADD28ZNMmIV2+7lZ7O21yDtwMkblykqfmLP2oPlLYqXOshqG2qcJofG5CrxP/xNiMkLAnwJq+H3Y9Tpww8hW8crb0wNwOVzL2jrJ5EXLo6UKpXAmBJhS0iaDh+jFJiCKpLV3qXLgIeXXyIMkyLm+mxh4WHAz8xiID8DgH2Rjtn8jhMNifZXmzqc7E/iitzpz+Gz2ekvH0xy4iFxI/NVKjCCjA3zi2zlyiDQZBHE7VTT4/aWmxCfSQtgt0NyfVlU2YGdFIyRRVY1dAC2c8/qbEzZL+kJxEJ8iYupeGiqPsJVym92uk4azd5M2X7r+QOu8OAb4G2Cqdw4tgFWSMwaFDuwJ3LH2jM7EgHtgWVzIXxsIVxPy8enMejD54B/SCg5UQE0z/DnMXsSdjm6yQWEHpELfIvH3nh2et3IZZ72uHSDIued16Sg41PM57UbEcpomr0H45gOX0eYcjDXLYIkIIY8AAok6gVqdX//0hmJHTZ5lw0IOsWsNWYj3sCvZUmZ8yB9OMEjGfhpaN0iNcv4jDO1xxXJH6LuyWAH518UvwAZBciCAvne+uaxWebJoSrwd6uEbWJmOsFoT869dsPFTRSuSfLjCplTFEaIB2IhOl/Ry3VKXm55HnBDL3Iwvvl/FGLyTNGHwkkPKLrKlT1LBL8FD0b5hWlQHARFx/+FQpHtYy8zEF133Bn2cLQks3PNYMmOBLcIdbZk/3Yx/u3e3gWdizwrgpftnnXEETPf/Q64dqH8y8u4xwuwNHMTqe3Knz+7Ruf+92jyUlNbdfPplb5mLuHFIgY2d7gI3ejmrOVMxkorZGuugLIc1uiaG1XDy3wDmVI7hytXll9f842OjcWpBt0d8xWpyaJD+L75OXj8sQyUvea+8gImBLki/gNA/uhF4+SX0gkLXbmf6pwBPo6/zKJfMeCx7QSb+O5ynYC6QHsh3+SK+1X5CMhKR2aA uqPmwKfi WgJKySwYIXUeb6d08eFuYuFtZUHThSJseLId1GmQ4SPtVRBDo3QGx9igTLkUKntrZ5RumkTCGYKxz4T95W1SX56jEGYDtq/AMg3J88CppzLQPzdXO45k6eI7azpPlDw9qXuzNJvshIzqV1y5CwEnV91yNTI6/J0Y39erxqrinwvS1YrGgTO7uIhQ8hZ1JsPKjakIZhW/Yl6+AfpAL4Ao7Y7zngjSFHEWgXk9krKlcGJPAksv3zudiM7T/c1fLXX55ubrFFIfWQUbp2pFSAg4Ik05VdH60QXJbVtKT6VrldQKtrh/I4YUuKGHytQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000153, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 366dc097ab11..9db77c36ef18 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -716,6 +716,8 @@ void uffd_wp_range(struct mm_struct *dst_mm, struct vm_area_struct *dst_vma, unsigned int mm_cp_flags; struct mmu_gather tlb; + 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