Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp662071pxj; Wed, 2 Jun 2021 08:21:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfl+BnAUNCfpnq1eTrOJ4lvUdM/h/oXBmVt6o/tAVOOi9LMmAEeJWSL1DJ/XYL2r/p4oRI X-Received: by 2002:aa7:cd83:: with SMTP id x3mr38797476edv.373.1622647288067; Wed, 02 Jun 2021 08:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622647288; cv=none; d=google.com; s=arc-20160816; b=LISEtzAFdfgy9vnxR0asccVylr82pn12dVdx+RWUDzVHcHFAUdWDXzosDlwDYoVtR+ QMnVuQae6ogSKVfVV8yrtOc+xH485mA/CjtjouEyMOvaN0Ygm+3dcYdO+wlwfbjqsU+j XZEP6Yg7eJxW5zykXQtbfZslkGs6aCTJGRDYAzFt/kRQyfX07YHbSrxQmFrXlLqmvEKi GFt+1LB69N3ehEQsqHkAONIKFIDXP+F5JkyicxfYUL6wvYEHFCr9j7QTrQGI9qcT7+BV ExSil3OQ8P0JOIUhrz3ngal0jU808gRdRcdzhb38IokjSQUHWAMFEn8B10FSPOeiH562 PPfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=95+gVSKdXSeqrGajzQBt/N7prqq4lqW4DujdQ82G5mY=; b=T0mNWD1Q6TtiYEycYArUej1RvpLhKT0+pqFFlWOXpV2OktrqobDmQPXHW9U27J2Nqb TDTwRdbcgjTuxgJb63OCzbXo1v44fY57DqLnqwazpcqscB0/kNhbqp6Q/rMjAOhtD0B4 cnuNys5a2WbqBHXpubjR5umRbrbfgyhUtjXWO+dr0LJ5/NJZy7VG08/LsCgZpWuzPcRF VADWmPxvyevSGr2x5bFbK+E67ihP9fnvQGFGLmIjXbC1W6wtA8eiUdrK6wZVHF1y7Fp1 HwD8dh0CWp1ZVzmRtn31/ULo52Fb5X48PzaCUB2Up9tBpTXrh7cOoTUUIBagBtljkqVd uNvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qgAwrc94; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b="8bPMi/WJ"; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=OKt1PYim; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=NzKYfasR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y3si166157edr.383.2021.06.02.08.21.04; Wed, 02 Jun 2021 08:21:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qgAwrc94; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b="8bPMi/WJ"; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=OKt1PYim; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=NzKYfasR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232201AbhFBPU0 (ORCPT + 99 others); Wed, 2 Jun 2021 11:20:26 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:59320 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232209AbhFBPUM (ORCPT ); Wed, 2 Jun 2021 11:20:12 -0400 Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 79F8922C3D; Wed, 2 Jun 2021 15:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1622647107; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=95+gVSKdXSeqrGajzQBt/N7prqq4lqW4DujdQ82G5mY=; b=qgAwrc94oVdW6YtQzM+BQjrgCjd9694/CCkB+nL89OaC262rnedK5CIbu/fhujFU4z5Ltn CW3zqlemZbk+ZEtBhc9L2M0m8u5tpPZFbCAGZhxqCgKFGnuqZtYkkLE5JdZ1WJqfQHcCOz 3zo6iF8rYfLy7GuWMOVAIJh/RLnJybM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1622647107; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=95+gVSKdXSeqrGajzQBt/N7prqq4lqW4DujdQ82G5mY=; b=8bPMi/WJ1NvkQinMQVnUZ/YMq/V9OpV+x5PBw2TdKS0dupANh954pMEYK0CUs9pTlaCyW2 c/saRuszwy85wrBA== Received: by imap.suse.de (Postfix, from userid 51) id 739BC11CDC; Wed, 2 Jun 2021 16:20:03 +0000 (UTC) Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 13EB311DA5; Wed, 2 Jun 2021 10:50:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1622631004; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=95+gVSKdXSeqrGajzQBt/N7prqq4lqW4DujdQ82G5mY=; b=OKt1PYimoMkY0KDdQmL7eA3UQMDxBIoT5LyONbhZVPFqoPZxOUaXwmYs+IBce1kOWCFwBl CRNGMdKlG7A0OXuiPQ5abeXCWN1gGIvFmevh/lBFW0IdFgSsuXydYYNm0CAZTFSql5e8gL uOHQWgGN4k46gF2fAY5woda6u6Ys58c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1622631004; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=95+gVSKdXSeqrGajzQBt/N7prqq4lqW4DujdQ82G5mY=; b=NzKYfasRSjg2oWXjqmJuM3cBfnUHhByiTeN0dYBNWaxauwf8wGyKWmehlPV40+OXEWZucr FIXvDDKby+2TBsDQ== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id XFlkBFxit2BaWwAALh3uQQ (envelope-from ); Wed, 02 Jun 2021 10:50:04 +0000 Subject: Re: [PATCH v3 4/4] slub: Force on no_hash_pointers when slub_debug is enabled To: Stephen Boyd , Andrew Morton Cc: linux-kernel@vger.kernel.org, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , linux-mm@kvack.org, Petr Mladek , Joe Perches References: <20210601182202.3011020-1-swboyd@chromium.org> <20210601182202.3011020-5-swboyd@chromium.org> From: Vlastimil Babka Message-ID: <5b1e2626-1d70-26cd-bb17-f7f8f80ac377@suse.cz> Date: Wed, 2 Jun 2021 12:50:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <20210601182202.3011020-5-swboyd@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/1/21 8:22 PM, Stephen Boyd wrote: > Obscuring the pointers that slub shows when debugging makes for some > confusing slub debug messages: > > Padding overwritten. 0x0000000079f0674a-0x000000000d4dce17 > > Those addresses are hashed for kernel security reasons. If we're trying > to be secure with slub_debug on the commandline we have some big > problems given that we dump whole chunks of kernel memory to the kernel > logs. Let's force on the no_hash_pointers commandline flag when > slub_debug is on the commandline. This makes slub debug messages more > meaningful and if by chance a kernel address is in some slub debug > object dump we will have a better chance of figuring out what went > wrong. > > Note that we don't use %px in the slub code because we want to reduce > the number of places that %px is used in the kernel. This also nicely > prints a big fat warning at kernel boot if slub_debug is on the > commandline so that we know that this kernel shouldn't be used on > production systems. > > Signed-off-by: Stephen Boyd Acked-by: Vlastimil Babka > --- > include/linux/kernel.h | 2 ++ > lib/vsprintf.c | 2 +- > mm/slub.c | 4 ++++ > 3 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/include/linux/kernel.h b/include/linux/kernel.h > index 15d8bad3d2f2..bf950621febf 100644 > --- a/include/linux/kernel.h > +++ b/include/linux/kernel.h > @@ -357,6 +357,8 @@ int sscanf(const char *, const char *, ...); > extern __scanf(2, 0) > int vsscanf(const char *, const char *, va_list); > > +extern int no_hash_pointers_enable(char *str); > + > extern int get_option(char **str, int *pint); > extern char *get_options(const char *str, int nints, int *ints); > extern unsigned long long memparse(const char *ptr, char **retptr); > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > index f0c35d9b65bf..cc281f5895f9 100644 > --- a/lib/vsprintf.c > +++ b/lib/vsprintf.c > @@ -2186,7 +2186,7 @@ char *fwnode_string(char *buf, char *end, struct fwnode_handle *fwnode, > bool no_hash_pointers __ro_after_init; > EXPORT_SYMBOL_GPL(no_hash_pointers); > > -static int __init no_hash_pointers_enable(char *str) > +int __init no_hash_pointers_enable(char *str) > { > if (no_hash_pointers) > return 0; > diff --git a/mm/slub.c b/mm/slub.c > index bf4949115412..a722794f1dbd 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -4460,6 +4460,10 @@ void __init kmem_cache_init(void) > if (debug_guardpage_minorder()) > slub_max_order = 0; > > + /* Print slub debugging pointers without hashing */ > + if (static_branch_unlikely(&slub_debug_enabled)) > + no_hash_pointers_enable(NULL); > + > kmem_cache_node = &boot_kmem_cache_node; > kmem_cache = &boot_kmem_cache; > >