lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <be9523c7-d06e-4c5a-b040-94109420cfed@suse.cz>
Date: Tue, 17 Jun 2025 20:57:58 +0200
From: Vlastimil Babka <vbabka@...e.cz>
To: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
 Andrew Morton <akpm@...ux-foundation.org>
Cc: "Liam R . Howlett" <Liam.Howlett@...cle.com>, Jens Axboe
 <axboe@...nel.dk>, Jani Nikula <jani.nikula@...ux.intel.com>,
 Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
 Rodrigo Vivi <rodrigo.vivi@...el.com>, Tvrtko Ursulin
 <tursulin@...ulin.net>, David Airlie <airlied@...il.com>,
 Simona Vetter <simona@...ll.ch>, Eric Van Hensbergen <ericvh@...nel.org>,
 Latchesar Ionkov <lucho@...kov.net>,
 Dominique Martinet <asmadeus@...ewreck.org>,
 Christian Schoenebeck <linux_oss@...debyte.com>,
 David Sterba <dsterba@...e.com>, David Howells <dhowells@...hat.com>,
 Marc Dionne <marc.dionne@...istor.com>,
 Alexander Viro <viro@...iv.linux.org.uk>,
 Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
 Benjamin LaHaise <bcrl@...ck.org>, Miklos Szeredi <miklos@...redi.hu>,
 Amir Goldstein <amir73il@...il.com>,
 Kent Overstreet <kent.overstreet@...ux.dev>,
 "Tigran A . Aivazian" <aivazian.tigran@...il.com>,
 Kees Cook <kees@...nel.org>, Chris Mason <clm@...com>,
 Josef Bacik <josef@...icpanda.com>, Xiubo Li <xiubli@...hat.com>,
 Ilya Dryomov <idryomov@...il.com>, Jan Harkes <jaharkes@...cmu.edu>,
 coda@...cmu.edu, Tyler Hicks <code@...icks.com>, Gao Xiang
 <xiang@...nel.org>, Chao Yu <chao@...nel.org>, Yue Hu <zbestahu@...il.com>,
 Jeffle Xu <jefflexu@...ux.alibaba.com>, Sandeep Dhavale
 <dhavale@...gle.com>, Hongbo Li <lihongbo22@...wei.com>,
 Namjae Jeon <linkinjeon@...nel.org>, Sungjong Seo <sj1557.seo@...sung.com>,
 Yuezhang Mo <yuezhang.mo@...y.com>, Theodore Ts'o <tytso@....edu>,
 Andreas Dilger <adilger.kernel@...ger.ca>, Jaegeuk Kim <jaegeuk@...nel.org>,
 OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>,
 Viacheslav Dubeyko <slava@...eyko.com>,
 John Paul Adrian Glaubitz <glaubitz@...sik.fu-berlin.de>,
 Yangtao Li <frank.li@...o.com>, Richard Weinberger <richard@....at>,
 Anton Ivanov <anton.ivanov@...bridgegreys.com>,
 Johannes Berg <johannes@...solutions.net>,
 Mikulas Patocka <mikulas@...ax.karlin.mff.cuni.cz>,
 David Woodhouse <dwmw2@...radead.org>, Dave Kleikamp <shaggy@...nel.org>,
 Trond Myklebust <trondmy@...nel.org>, Anna Schumaker <anna@...nel.org>,
 Ryusuke Konishi <konishi.ryusuke@...il.com>,
 Konstantin Komarov <almaz.alexandrovich@...agon-software.com>,
 Mark Fasheh <mark@...heh.com>, Joel Becker <jlbec@...lplan.org>,
 Joseph Qi <joseph.qi@...ux.alibaba.com>, Bob Copeland <me@...copeland.com>,
 Mike Marshall <hubcap@...ibond.com>, Martin Brandenburg
 <martin@...ibond.com>, Steve French <sfrench@...ba.org>,
 Paulo Alcantara <pc@...guebit.org>,
 Ronnie Sahlberg <ronniesahlberg@...il.com>,
 Shyam Prasad N <sprasad@...rosoft.com>, Tom Talpey <tom@...pey.com>,
 Bharath SM <bharathsm@...rosoft.com>, Zhihao Cheng
 <chengzhihao1@...wei.com>, Hans de Goede <hdegoede@...hat.com>,
 Carlos Maiolino <cem@...nel.org>, Damien Le Moal <dlemoal@...nel.org>,
 Naohiro Aota <naohiro.aota@....com>, Johannes Thumshirn <jth@...nel.org>,
 Dan Williams <dan.j.williams@...el.com>, Matthew Wilcox
 <willy@...radead.org>, Jann Horn <jannh@...gle.com>,
 Pedro Falcato <pfalcato@...e.de>, linux-block@...r.kernel.org,
 linux-kernel@...r.kernel.org, intel-gfx@...ts.freedesktop.org,
 dri-devel@...ts.freedesktop.org, v9fs@...ts.linux.dev,
 linux-fsdevel@...r.kernel.org, linux-afs@...ts.infradead.org,
 linux-aio@...ck.org, linux-unionfs@...r.kernel.org,
 linux-bcachefs@...r.kernel.org, linux-mm@...ck.org,
 linux-btrfs@...r.kernel.org, ceph-devel@...r.kernel.org,
 codalist@...a.cs.cmu.edu, ecryptfs@...r.kernel.org,
 linux-erofs@...ts.ozlabs.org, linux-ext4@...r.kernel.org,
 linux-f2fs-devel@...ts.sourceforge.net, linux-um@...ts.infradead.org,
 linux-mtd@...ts.infradead.org, jfs-discussion@...ts.sourceforge.net,
 linux-nfs@...r.kernel.org, linux-nilfs@...r.kernel.org,
 ntfs3@...ts.linux.dev, ocfs2-devel@...ts.linux.dev,
 linux-karma-devel@...ts.sourceforge.net, devel@...ts.orangefs.org,
 linux-cifs@...r.kernel.org, samba-technical@...ts.samba.org,
 linux-xfs@...r.kernel.org, nvdimm@...ts.linux.dev
Subject: Re: [PATCH 01/10] mm: rename call_mmap/mmap_prepare to
 vfs_mmap/mmap_prepare

On 6/16/25 21:33, Lorenzo Stoakes wrote:
> The call_mmap() function violates the existing convention in
> include/linux/fs.h whereby invocations of virtual file system hooks is
> performed by functions prefixed with vfs_xxx().
> 
> Correct this by renaming call_mmap() to vfs_mmap(). This also avoids
> confusion as to the fact that f_op->mmap_prepare may be invoked here.
> 
> Also rename __call_mmap_prepare() function to vfs_mmap_prepare() and adjust
> to accept a file parameter, this is useful later for nested file systems.
> 
> Finally, fix up the VMA userland tests and ensure the mmap_prepare -> mmap
> shim is implemented there.
> 
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>

Acked-by: Vlastimil Babka <vbabka@...e.cz>

> ---
>  drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c |  2 +-
>  fs/backing-file.c                          |  2 +-
>  fs/coda/file.c                             |  4 +--
>  include/linux/fs.h                         |  5 ++--
>  ipc/shm.c                                  |  2 +-
>  mm/internal.h                              |  2 +-
>  mm/vma.c                                   |  2 +-
>  tools/testing/vma/vma_internal.h           | 32 ++++++++++++++++++----
>  8 files changed, 35 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
> index 05e440643aa2..f4f1c979d1b9 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
> @@ -105,7 +105,7 @@ static int i915_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct *
>  	if (!obj->base.filp)
>  		return -ENODEV;
>  
> -	ret = call_mmap(obj->base.filp, vma);
> +	ret = vfs_mmap(obj->base.filp, vma);
>  	if (ret)
>  		return ret;
>  
> diff --git a/fs/backing-file.c b/fs/backing-file.c
> index 763fbe9b72b2..04018679bf69 100644
> --- a/fs/backing-file.c
> +++ b/fs/backing-file.c
> @@ -339,7 +339,7 @@ int backing_file_mmap(struct file *file, struct vm_area_struct *vma,
>  	vma_set_file(vma, file);
>  
>  	old_cred = override_creds(ctx->cred);
> -	ret = call_mmap(vma->vm_file, vma);
> +	ret = vfs_mmap(vma->vm_file, vma);
>  	revert_creds(old_cred);
>  
>  	if (ctx->accessed)
> diff --git a/fs/coda/file.c b/fs/coda/file.c
> index 148856a582a9..2e6ea9319b35 100644
> --- a/fs/coda/file.c
> +++ b/fs/coda/file.c
> @@ -199,10 +199,10 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma)
>  	spin_unlock(&cii->c_lock);
>  
>  	vma->vm_file = get_file(host_file);
> -	ret = call_mmap(vma->vm_file, vma);
> +	ret = vfs_mmap(vma->vm_file, vma);
>  
>  	if (ret) {
> -		/* if call_mmap fails, our caller will put host_file so we
> +		/* if vfs_mmap fails, our caller will put host_file so we
>  		 * should drop the reference to the coda_file that we got.
>  		 */
>  		fput(coda_file);
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 93ee0d2d6f1a..7120f80255b3 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2278,7 +2278,7 @@ static inline bool file_has_valid_mmap_hooks(struct file *file)
>  
>  int compat_vma_mmap_prepare(struct file *file, struct vm_area_struct *vma);
>  
> -static inline int call_mmap(struct file *file, struct vm_area_struct *vma)
> +static inline int vfs_mmap(struct file *file, struct vm_area_struct *vma)
>  {
>  	if (file->f_op->mmap_prepare)
>  		return compat_vma_mmap_prepare(file, vma);
> @@ -2286,8 +2286,7 @@ static inline int call_mmap(struct file *file, struct vm_area_struct *vma)
>  	return file->f_op->mmap(file, vma);
>  }
>  
> -static inline int __call_mmap_prepare(struct file *file,
> -		struct vm_area_desc *desc)
> +static inline int vfs_mmap_prepare(struct file *file, struct vm_area_desc *desc)
>  {
>  	return file->f_op->mmap_prepare(desc);
>  }
> diff --git a/ipc/shm.c b/ipc/shm.c
> index 492fcc699985..a9310b6dbbc3 100644
> --- a/ipc/shm.c
> +++ b/ipc/shm.c
> @@ -602,7 +602,7 @@ static int shm_mmap(struct file *file, struct vm_area_struct *vma)
>  	if (ret)
>  		return ret;
>  
> -	ret = call_mmap(sfd->file, vma);
> +	ret = vfs_mmap(sfd->file, vma);
>  	if (ret) {
>  		__shm_close(sfd);
>  		return ret;
> diff --git a/mm/internal.h b/mm/internal.h
> index 3823fb356d3b..a55c88afff6d 100644
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -165,7 +165,7 @@ static inline void *folio_raw_mapping(const struct folio *folio)
>   */
>  static inline int mmap_file(struct file *file, struct vm_area_struct *vma)
>  {
> -	int err = call_mmap(file, vma);
> +	int err = vfs_mmap(file, vma);
>  
>  	if (likely(!err))
>  		return 0;
> diff --git a/mm/vma.c b/mm/vma.c
> index 5d35adadf2b5..f548bede3bbe 100644
> --- a/mm/vma.c
> +++ b/mm/vma.c
> @@ -2582,7 +2582,7 @@ static int call_mmap_prepare(struct mmap_state *map)
>  	};
>  
>  	/* Invoke the hook. */
> -	err = __call_mmap_prepare(map->file, &desc);
> +	err = vfs_mmap_prepare(map->file, &desc);
>  	if (err)
>  		return err;
>  
> diff --git a/tools/testing/vma/vma_internal.h b/tools/testing/vma/vma_internal.h
> index d7fea56e3bb3..51dd122b8d50 100644
> --- a/tools/testing/vma/vma_internal.h
> +++ b/tools/testing/vma/vma_internal.h
> @@ -1458,6 +1458,27 @@ static inline void free_anon_vma_name(struct vm_area_struct *vma)
>  	(void)vma;
>  }
>  
> +/* Declared in vma.h. */
> +static inline void set_vma_from_desc(struct vm_area_struct *vma,
> +		struct vm_area_desc *desc);
> +
> +static inline struct vm_area_desc *vma_to_desc(struct vm_area_struct *vma,
> +		struct vm_area_desc *desc);
> +
> +static int compat_vma_mmap_prepare(struct file *file,
> +		struct vm_area_struct *vma)
> +{
> +	struct vm_area_desc desc;
> +	int err;
> +
> +	err = file->f_op->mmap_prepare(vma_to_desc(vma, &desc));
> +	if (err)
> +		return err;
> +	set_vma_from_desc(vma, &desc);
> +
> +	return 0;
> +}
> +
>  /* Did the driver provide valid mmap hook configuration? */
>  static inline bool file_has_valid_mmap_hooks(struct file *file)
>  {
> @@ -1467,22 +1488,21 @@ static inline bool file_has_valid_mmap_hooks(struct file *file)
>  	/* Hooks are mutually exclusive. */
>  	if (WARN_ON_ONCE(has_mmap && has_mmap_prepare))
>  		return false;
> -	if (WARN_ON_ONCE(!has_mmap && !has_mmap_prepare))
> +	if (!has_mmap && !has_mmap_prepare)
>  		return false;
>  
>  	return true;
>  }
>  
> -static inline int call_mmap(struct file *file, struct vm_area_struct *vma)
> +static inline int vfs_mmap(struct file *file, struct vm_area_struct *vma)
>  {
> -	if (WARN_ON_ONCE(file->f_op->mmap_prepare))
> -		return -EINVAL;
> +	if (file->f_op->mmap_prepare)
> +		return compat_vma_mmap_prepare(file, vma);
>  
>  	return file->f_op->mmap(file, vma);
>  }
>  
> -static inline int __call_mmap_prepare(struct file *file,
> -		struct vm_area_desc *desc)
> +static inline int vfs_mmap_prepare(struct file *file, struct vm_area_desc *desc)
>  {
>  	return file->f_op->mmap_prepare(desc);
>  }


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ