From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751457AbdISNcX (ORCPT ); Tue, 19 Sep 2017 09:32:23 -0400 Received: from foss.arm.com ([217.140.101.70]:50204 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750948AbdISNcW (ORCPT ); Tue, 19 Sep 2017 09:32:22 -0400 Date: Tue, 19 Sep 2017 14:30:57 +0100 From: Mark Rutland To: Andrey Ryabinin Cc: Dmitry Vyukov , akpm@linux-foundation.org, Andrey Konovalov , tchibo@google.com, syzkaller@googlegroups.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] kcov: remove #ifdef CONFIG_RANDOMIZE_BASE Message-ID: <20170919133057.GE30715@leverpostej> References: <20170919124648.28963-1-aryabinin@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170919124648.28963-1-aryabinin@virtuozzo.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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.