Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1734906 > unrolled thread

Re: [PATCH 1/3] kcov: remove #ifdef CONFIG_RANDOMIZE_BASE

Started byMark Rutland <mark.rutland@arm.com>
First post2017-09-19 15:40 +0200
Last post2017-09-19 15:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 1/3] kcov: remove #ifdef CONFIG_RANDOMIZE_BASE Mark Rutland <mark.rutland@arm.com> - 2017-09-19 15:40 +0200
    Re: [PATCH 1/3] kcov: remove #ifdef CONFIG_RANDOMIZE_BASE Dmitry Vyukov <dvyukov@google.com> - 2017-09-19 15:50 +0200

#1734906 — Re: [PATCH 1/3] kcov: remove #ifdef CONFIG_RANDOMIZE_BASE

FromMark Rutland <mark.rutland@arm.com>
Date2017-09-19 15:40 +0200
SubjectRe: [PATCH 1/3] kcov: remove #ifdef CONFIG_RANDOMIZE_BASE
Message-ID<urqUN-62D-9@gated-at.bofh.it>
Hi,

On Tue, Sep 19, 2017 at 03:46:46PM +0300, Andrey Ryabinin wrote:
> There is no need to surround kaslr_offset() with CONFIG_RANDOMIZE_BASE ifdef.
> kaslr_offset() will just return 0 if CONFIG_RANDOMIZE_BASE isn't set.
> 
> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> ---
>  kernel/kcov.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/kernel/kcov.c b/kernel/kcov.c
> index 3f693a0f6f3e..2f0e7a7c7afc 100644
> --- a/kernel/kcov.c
> +++ b/kernel/kcov.c
> @@ -69,9 +69,7 @@ void notrace __sanitizer_cov_trace_pc(void)
>  		unsigned long pos;
>  		unsigned long ip = _RET_IP_;
>  
> -#ifdef CONFIG_RANDOMIZE_BASE
>  		ip -= kaslr_offset();
> -#endif

I think this is sound, but as Dmitry points out it'll mean we do some
pointless work. For example on arm64 we have:

static inline unsigned long kaslr_offset(void)
{
	return kimage_vaddr - KIMAGE_VADDR;
}

... where kimage_vaddr is a global variable, and KIMAGE_VADDR is a
constant (and should be identical for !CONFIG_RANDOMIZE_BASE kernels).

I think it would be reasonable to make that:

static inline unsigned long kaslr_offset(void)
{
	if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE))
		return 0;

	return kimage_vaddr - KIMAGE_VADDR;
}

... and simplify callers as above.

Thanks,
Mark.

[toc] | [next] | [standalone]


#1734927

FromDmitry Vyukov <dvyukov@google.com>
Date2017-09-19 15:50 +0200
Message-ID<urr4v-66a-41@gated-at.bofh.it>
In reply to#1734906
On Tue, Sep 19, 2017 at 3:30 PM, Mark Rutland <mark.rutland@arm.com> wrote:
> Hi,
>
> On Tue, Sep 19, 2017 at 03:46:46PM +0300, Andrey Ryabinin wrote:
>> There is no need to surround kaslr_offset() with CONFIG_RANDOMIZE_BASE ifdef.
>> kaslr_offset() will just return 0 if CONFIG_RANDOMIZE_BASE isn't set.
>>
>> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
>> ---
>>  kernel/kcov.c | 2 --
>>  1 file changed, 2 deletions(-)
>>
>> diff --git a/kernel/kcov.c b/kernel/kcov.c
>> index 3f693a0f6f3e..2f0e7a7c7afc 100644
>> --- a/kernel/kcov.c
>> +++ b/kernel/kcov.c
>> @@ -69,9 +69,7 @@ void notrace __sanitizer_cov_trace_pc(void)
>>               unsigned long pos;
>>               unsigned long ip = _RET_IP_;
>>
>> -#ifdef CONFIG_RANDOMIZE_BASE
>>               ip -= kaslr_offset();
>> -#endif
>
> I think this is sound, but as Dmitry points out it'll mean we do some
> pointless work. For example on arm64 we have:
>
> static inline unsigned long kaslr_offset(void)
> {
>         return kimage_vaddr - KIMAGE_VADDR;
> }
>
> ... where kimage_vaddr is a global variable, and KIMAGE_VADDR is a
> constant (and should be identical for !CONFIG_RANDOMIZE_BASE kernels).
>
> I think it would be reasonable to make that:
>
> static inline unsigned long kaslr_offset(void)
> {
>         if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE))
>                 return 0;
>
>         return kimage_vaddr - KIMAGE_VADDR;
> }
>
> ... and simplify callers as above.

Sounds reasonable to me.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web