Revision a57b70519d1f7c53be98478623652738e5ac70d5 authored by Liam Howlett on 18 October 2022, 19:17:12 UTC, committed by Andrew Morton on 21 October 2022, 04:27:23 UTC
mmap should return the start address of newly mapped area when successful.
On a successful merge of a VMA, the return address was changed and thus
was violating that expectation from userspace.

This is a restoration of functionality provided by 309d08d9b3a3
(mm/mmap.c: fix mmap return value when vma is merged after call_mmap()). 
For completeness of fixing MAP_FIXED, implement the comments from the
previous discussion to never update the address and fail if the address
changes.  Leaving the error as a WARN_ON() to avoid crashing the kernel.

Link: https://lkml.kernel.org/r/20221018191613.4133459-1-Liam.Howlett@oracle.com
Link: https://lore.kernel.org/all/Y06yk66SKxlrwwfb@lakrids/
Link: https://lore.kernel.org/all/20201203085350.22624-1-liuzixian4@huawei.com/
Fixes: 4dd1b84140c1 ("mm/mmap: use advanced maple tree API for mmap_region()")
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Reported-by: Mark Rutland <mark.rutland@arm.com>
Cc: Liu Zixian <liuzixian4@huawei.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 1cd916d
Raw File
timer-goldfish.h
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * goldfish-timer clocksource
 * Registers definition for the goldfish-timer device
 */

#ifndef _CLOCKSOURCE_TIMER_GOLDFISH_H
#define _CLOCKSOURCE_TIMER_GOLDFISH_H

/*
 * TIMER_TIME_LOW	 get low bits of current time and update TIMER_TIME_HIGH
 * TIMER_TIME_HIGH	 get high bits of time at last TIMER_TIME_LOW read
 * TIMER_ALARM_LOW	 set low bits of alarm and activate it
 * TIMER_ALARM_HIGH	 set high bits of next alarm
 * TIMER_IRQ_ENABLED	 enable alarm interrupt
 * TIMER_CLEAR_ALARM	 disarm an existing alarm
 * TIMER_ALARM_STATUS	 alarm status (running or not)
 * TIMER_CLEAR_INTERRUPT clear interrupt
 */
#define TIMER_TIME_LOW		0x00
#define TIMER_TIME_HIGH		0x04
#define TIMER_ALARM_LOW		0x08
#define TIMER_ALARM_HIGH	0x0c
#define TIMER_IRQ_ENABLED	0x10
#define TIMER_CLEAR_ALARM	0x14
#define TIMER_ALARM_STATUS	0x18
#define TIMER_CLEAR_INTERRUPT	0x1c

extern int goldfish_timer_init(int irq, void __iomem *base);

#endif /* _CLOCKSOURCE_TIMER_GOLDFISH_H */
back to top