Skip to content

Commit 06fc3b0

Browse files
Alexander Gordeevhcahca
authored andcommitted
s390/vmem: do not silently ignore mapping limit
The only interface that allows drivers establishing liner mappings is vmem_add_mapping(). It does check a requested range against allowed limits and a call to modify_pagetable() with an invalid mapping range is impossible. Hence, an attempt to map an address range outside of the identity mapping or vmemmap array could only be kernel bug. Reviewed-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent f59ec04 commit 06fc3b0

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

arch/s390/mm/vmem.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,9 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned long addr,
290290

291291
static void try_free_pmd_table(pud_t *pud, unsigned long start)
292292
{
293-
const unsigned long end = start + PUD_SIZE;
294293
pmd_t *pmd;
295294
int i;
296295

297-
/* Don't mess with any tables not fully in 1:1 mapping & vmemmap area */
298-
if (end > VMALLOC_START)
299-
return;
300-
301296
pmd = pmd_offset(pud, start);
302297
for (i = 0; i < PTRS_PER_PMD; i++, pmd++)
303298
if (!pmd_none(*pmd))
@@ -362,14 +357,9 @@ static int modify_pud_table(p4d_t *p4d, unsigned long addr, unsigned long end,
362357

363358
static void try_free_pud_table(p4d_t *p4d, unsigned long start)
364359
{
365-
const unsigned long end = start + P4D_SIZE;
366360
pud_t *pud;
367361
int i;
368362

369-
/* Don't mess with any tables not fully in 1:1 mapping & vmemmap area */
370-
if (end > VMALLOC_START)
371-
return;
372-
373363
pud = pud_offset(p4d, start);
374364
for (i = 0; i < PTRS_PER_PUD; i++, pud++) {
375365
if (!pud_none(*pud))
@@ -412,14 +402,9 @@ static int modify_p4d_table(pgd_t *pgd, unsigned long addr, unsigned long end,
412402

413403
static void try_free_p4d_table(pgd_t *pgd, unsigned long start)
414404
{
415-
const unsigned long end = start + PGDIR_SIZE;
416405
p4d_t *p4d;
417406
int i;
418407

419-
/* Don't mess with any tables not fully in 1:1 mapping & vmemmap area */
420-
if (end > VMALLOC_START)
421-
return;
422-
423408
p4d = p4d_offset(pgd, start);
424409
for (i = 0; i < PTRS_PER_P4D; i++, p4d++) {
425410
if (!p4d_none(*p4d))
@@ -439,6 +424,9 @@ static int modify_pagetable(unsigned long start, unsigned long end, bool add,
439424

440425
if (WARN_ON_ONCE(!PAGE_ALIGNED(start | end)))
441426
return -EINVAL;
427+
/* Don't mess with any tables not fully in 1:1 mapping & vmemmap area */
428+
if (WARN_ON_ONCE(end > VMALLOC_START))
429+
return -EINVAL;
442430
for (addr = start; addr < end; addr = next) {
443431
next = pgd_addr_end(addr, end);
444432
pgd = pgd_offset_k(addr);

0 commit comments

Comments
 (0)