mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrey Ryabinin <aryabinin@virtuozzo.com>
To: Dmitry Vyukov <dvyukov@google.com>, Mark Rutland <mark.rutland@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Andrey Konovalov <andreyknvl@google.com>,
	syzkaller <syzkaller@googlegroups.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] kcov: remove #ifdef CONFIG_RANDOMIZE_BASE
Date: Fri, 29 Sep 2017 19:20:46 +0300	[thread overview]
Message-ID: <f094c6c2-640b-73e4-95cb-19fd74d4fdd7@virtuozzo.com> (raw)
In-Reply-To: <CACT4Y+a4g4s_3ULdseYG3WvrKUaXU4x_eDQZYAj-8GmNrTJ5SA@mail.gmail.com>

On 09/19/2017 04:47 PM, Dmitry Vyukov wrote:
> 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.
> 

As kbuilt robot pointed out, we would also need to introduce generic kaslr_offset() for arches
that don't have it. I seem like too much trouble for very little gain, so I'll keep current code as is.

  reply	other threads:[~2017-09-29 16:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-19 12:46 Andrey Ryabinin
2017-09-19 12:46 ` [PATCH 2/3] kcov: remove pointless current != NULL check Andrey Ryabinin
2017-09-19 12:57   ` Dmitry Vyukov
2017-09-19 13:32   ` Mark Rutland
2017-09-19 12:46 ` [PATCH 3/3] kcov: remove useless barrier()s Andrey Ryabinin
2017-09-19 12:57   ` Dmitry Vyukov
2017-09-19 13:52     ` Andrey Ryabinin
2017-09-19 13:54       ` Dmitry Vyukov
2017-09-19 14:29         ` Andrey Ryabinin
2017-09-19 14:42           ` Dmitry Vyukov
2017-09-19 13:03 ` [PATCH 1/3] kcov: remove #ifdef CONFIG_RANDOMIZE_BASE Dmitry Vyukov
2017-09-19 13:30 ` Mark Rutland
2017-09-19 13:47   ` Dmitry Vyukov
2017-09-29 16:20     ` Andrey Ryabinin [this message]
2017-09-21 22:16 ` kbuild test robot

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=f094c6c2-640b-73e4-95cb-19fd74d4fdd7@virtuozzo.com \
    --to=aryabinin@virtuozzo.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@google.com \
    --cc=dvyukov@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=syzkaller@googlegroups.com \
    /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

all inboxes | Powered by JetHome®