linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Alistair Popple <apopple@nvidia.com>,
	x86@kernel.org, Dan Williams <dan.j.williams@intel.com>,
	dave.hansen@linux.intel.com, luto@kernel.org,
	peterz@infradead.org, max8rr8@gmail.com,
	linux-kernel@vger.kernel.org, jhubbard@nvidia.com,
	Kees Cook <keescook@chromium.org>,
	Andrew Morton <akpm@linuxfoundation.org>,
	David Hildenbrand <david@redhat.com>,
	Oscar Salvador <osalvador@suse.de>,
	linux-mm@kvack.org
Subject: Re: x86/kaslr: Expose and use the end of the physical memory address space
Date: Sun, 22 Sep 2024 15:31:38 -0700	[thread overview]
Message-ID: <ee205448-5fdd-495e-9d7c-c8a2b59f9c9e@roeck-us.net> (raw)
In-Reply-To: <87ed6soy3z.ffs@tglx>

On Wed, Aug 14, 2024 at 12:29:36AM +0200, Thomas Gleixner wrote:
> iounmap() on x86 occasionally fails to unmap because the provided valid
> ioremap address is not below high_memory. It turned out that this
> happens due to KASLR.
> 
[ ... ]
>  
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -1826,8 +1826,7 @@ static resource_size_t gfr_start(struct
>  	if (flags & GFR_DESCENDING) {
>  		resource_size_t end;
>  
> -		end = min_t(resource_size_t, base->end,
> -			    (1ULL << MAX_PHYSMEM_BITS) - 1);
> +		end = min_t(resource_size_t, base->end, PHYSMEM_END);
>  		return end - size + 1;
>  	}

When trying to build arm:allmodconfig or mips:allmodconfig (and probably
others):

Building arm:allmodconfig ... failed
--------------
Error log:
In file included from include/linux/ioport.h:15,
                 from kernel/resource.c:15:
kernel/resource.c: In function 'gfr_start':
include/linux/minmax.h:93:37: error: conversion from 'long long unsigned int' to 'resource_size_t' {aka 'unsigned int'} changes value from '18446744073709551615' to '4294967295' [-Werror=overflow]
   93 |         ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
      |                                     ^
include/linux/minmax.h:96:9: note: in expansion of macro '__cmp_once_unique'
   96 |         __cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
      |         ^~~~~~~~~~~~~~~~~
include/linux/minmax.h:213:27: note: in expansion of macro '__cmp_once'
  213 | #define min_t(type, x, y) __cmp_once(min, type, x, y)
      |                           ^~~~~~~~~~
kernel/resource.c:1874:23: note: in expansion of macro 'min_t'
 1874 |                 end = min_t(resource_size_t, base->end, PHYSMEM_END);
      |                       ^~~~~
kernel/resource.c: In function 'gfr_continue':
include/linux/minmax.h:93:37: error: conversion from 'long long unsigned int' to 'resource_size_t' {aka 'unsigned int'} changes value from '18446744073709551615' to '4294967295' [-Werror=overflow]
   93 |         ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
      |                                     ^
include/linux/minmax.h:96:9: note: in expansion of macro '__cmp_once_unique'
   96 |         __cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
      |         ^~~~~~~~~~~~~~~~~
include/linux/minmax.h:213:27: note: in expansion of macro '__cmp_once'
  213 | #define min_t(type, x, y) __cmp_once(min, type, x, y)
      |                           ^~~~~~~~~~
kernel/resource.c:1891:24: note: in expansion of macro 'min_t'
 1891 |                addr <= min_t(resource_size_t, base->end, PHYSMEM_END);
      |                        ^~~~~

Guenter


      parent reply	other threads:[~2024-09-22 22:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230810100011.14552-1-max8rr8@gmail.com>
     [not found] ` <87wmkr4jgj.fsf@nvdebian.thelocal>
2024-08-12  6:15   ` [PATCH 1/1] x86/ioremap: Use is_vmalloc_addr in iounmap Christoph Hellwig
     [not found] ` <87le17yu5y.ffs@tglx>
     [not found]   ` <66b4eb2a62f6_c1448294b0@dwillia2-xfh.jf.intel.com.notmuch>
     [not found]     ` <877ccryor7.ffs@tglx>
     [not found]       ` <66b4f305eb227_c144829443@dwillia2-xfh.jf.intel.com.notmuch>
     [not found]         ` <66b4f4a522508_c1448294f2@dwillia2-xfh.jf.intel.com.notmuch>
     [not found]           ` <87zfpmyhvr.ffs@tglx>
     [not found]             ` <66b523ac448e2_c1448294ec@dwillia2-xfh.jf.intel.com.notmuch>
     [not found]               ` <87seve4e37.fsf@nvdebian.thelocal>
     [not found]                 ` <66b59314b3d4_c1448294d3@dwillia2-xfh.jf.intel.com.notmuch>
     [not found]                   ` <87zfpks23v.ffs@tglx>
     [not found]                     ` <87o75y428z.fsf@nvdebian.thelocal>
     [not found]                       ` <87ikw6rrau.ffs@tglx>
     [not found]                         ` <87frr9swmw.ffs@tglx>
     [not found]                           ` <87bk1x42vk.fsf@nvdebian.thelocal>
     [not found]                             ` <87sev8rfyx.ffs@tglx>
     [not found]                               ` <87le10p3ak.ffs@tglx>
2024-08-13 22:29                                 ` x86/kaslr: Expose and use the end of the physical memory address space Thomas Gleixner
2024-08-14  0:26                                   ` Alistair Popple
2024-08-14 14:33                                   ` Dan Williams
2024-08-15 16:11                                   ` Kees Cook
2024-08-15 22:48                                   ` Max R
2024-08-16  9:42                                   ` David Hildenbrand
2024-09-22 22:31                                   ` Guenter Roeck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee205448-5fdd-495e-9d7c-c8a2b59f9c9e@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=akpm@linuxfoundation.org \
    --cc=apopple@nvidia.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=david@redhat.com \
    --cc=jhubbard@nvidia.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=max8rr8@gmail.com \
    --cc=osalvador@suse.de \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox