From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C456830EF90 for ; Fri, 22 May 2026 16:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779465616; cv=none; b=D8Rf6oufnym0muednrqiAn/Pn+bwQoJav80Wk9CdLJi0FyR3ekR5pPKG+kfDAR3UtG1oUU+XfANm8neZ98c0QgJUIapPTjl5FSA2jb4UiPseIZcKWyJ9LE4OzxLSgaY3aFFUFhktu3Lj5GYmBcl/gLkeAwFQvDdMqp7uyo4B/Ks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779465616; c=relaxed/simple; bh=iIll7qotsPJjP2OpPdh1H+DZ3t8jIXss3LIeeBzefFM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NO98dN7iTUTR3lixK0AJCJaimUV+dOrelyRJdSxFOn2N6ICBY4qVfbL45v9Mgk7QIeDypfUX2j2o1hqGdUphIMQfm3onnDYmrssx7T03zaEtQc7NaYwjFAIP7oRX3w/smf/EUwOgsC8UbMPIVIerj7gTSFzXLKM6nMQus7QuKV0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CWgvjUmQ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CWgvjUmQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E39C31F000E9; Fri, 22 May 2026 16:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779465615; bh=NlJymXd+YDawqDDSaCcMPlme8lTIf2JfXZ77UMlGIjY=; h=From:To:Cc:Subject:Date; b=CWgvjUmQXF8y00NI51Ncljz+jWVO6e78hlNekn5O1d2dqhJICpOWRwpNA0IVzRHp3 of3fhm9X5k+xnkKdTgcCSxanym+pKhbHDpFDxQkAHXdTqQ1XHQLHAT/8+kEv+PLXhn 8fPMK3PxLv2s9gRDpETSAo5JRXAGEi5RpgEjaUUdzLYQErdHZf1CBIWdtWS85+z9we 2tPNfFenn3jwkoEIeM6JXvgwnOSWXqgcJ4P2wsMYIzEhZHDgwaUlkbfMHMCNYJG/Wp 8Um4B4g2bTRc0gUi1iWidBEobmVppkkVgx0TvSeQZYw2WwyXLFHQBcci0CObR/RH8L dti5bkQNZOi2A== From: Lorenzo Stoakes To: Andrew Morton Cc: Arnd Bergmann , Greg Kroah-Hartman , David Hildenbrand , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jann Horn , Pedro Falcato , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 0/3] remove mmap_action success, error hooks Date: Fri, 22 May 2026 17:00:08 +0100 Message-ID: X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The mmap_action->success_hook was a strange beast added to enable code which appeared to absolutely require access to a VMA pointer to work correctly. Primarily this was for hugetlb, however a different approach will be taken there, as clearly more work is required to figure out a sensible way of converting hugetlb to use mmap_prepare. The other user was the memory char driver, specifically /dev/zero which has the unusual property of explicitly setting file-backed VMAs anonymous. Providing the success hook was always foolish, as it allowed drivers a way to workaround the restriction that they should not access a pointer to a not-yet-correctly-initialised VMA - which defeats the purpose of the mmap_prepare work. We can achieve the same thing in memory char driver without needing the success hook, so this series removes that, then removes the success hook altogether. The error hook is also unnecessary - the motivation for this was for functions which need to filter the error code when performing an mmap action in order to avoid breaking userspace. We can achieve this by just providing a field for the error code. Doing this means we don't have to worry about the hook doing anything odd. We also add a check to ensure the error code is in fact valid. Again the memory char driver is the only current user of this, so this series updates it to use that. After this change mmap_action has no custom hooks at all, which seems rather more cromulent than before. v2: * Fold fix-patch in, defaulting the vma descriptor vm_ops field to the dummy VMA operations. * Update commit message in 1/3 to reflect this. v1: https://lore.kernel.org/all/cover.1779379804.git.ljs@kernel.org Lorenzo Stoakes (3): drivers/char/mem: eliminate unnecessary use of success_hook mm/vma: remove mmap_action->success_hook mm/vma: eliminate mmap_action->error_hook, introduce error_filter drivers/char/mem.c | 25 ++++++------------------- include/linux/mm.h | 5 +++++ include/linux/mm_types.h | 19 +++---------------- mm/util.c | 32 ++++++++++++++++++++++---------- mm/vma.c | 3 +++ tools/testing/vma/include/dup.h | 20 ++++---------------- 6 files changed, 43 insertions(+), 61 deletions(-) -- 2.54.0