[PATCH] mm/mmap: Fix MAP_FIXED address return on VMA merge

Matthew Wilcox willy at infradead.org
Tue Oct 18 12:58:28 PDT 2022


On Tue, Oct 18, 2022 at 09:27:11PM +0200, David Hildenbrand wrote:
> > +		if (WARN_ON((addr != vma->vm_start))) {
> > +			error = -EINVAL;
> > +			goto close_and_free_vma;
> > +		}
> 
> If this is something that user space can trigger, WARN_* is the wrong
> choice. But what I understand from the comment change is that this must not
> happen at that point unless there is a real issue.

It's something that a device driver can trigger.  So if userspace calls
mmap(MAP_FIXED) and the driver decides to overwrite the vma->vm_start,
it'll trigger.  I think WARN_ON() is the right choice.

> Why not "if (WARN_ON_ONCE)" ?

Because by it's nature it's not going to trigger a bajillion times in
quick succession.



More information about the maple-tree mailing list