Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3794899ybl; Mon, 12 Aug 2019 06:33:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5Rbds88NtpsPsfhWnBLkoNR5VwLpQcz0Ucf2Uwo0dxDv4l+6RSB64ZTHdbOP9ypdpkfmw X-Received: by 2002:a63:1b66:: with SMTP id b38mr30337283pgm.54.1565616811576; Mon, 12 Aug 2019 06:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565616811; cv=none; d=google.com; s=arc-20160816; b=H57JcfeBXpjBb2Zic0uLX/Dr7irgQ26gfuSdnbeGqqC17OUPnkSK8RGIj0U+Em3la6 Ucq8z1HAh9KAOSojuB3vloBZdJtF0vbE0LOyPvWy4xZ81GmE2GyMj/VISDKNi5FrR7O7 IVE9ZHd+alksD3Jbouwh/qL5aiYQDsO16/p+lwR6tg625OQjmKCxXQkCjEPKKxiPqvYP y494Hb83XXVd2wkjxThZ2nNFtahDufQ5IQsExBedfFog6cyPgy07y9ZBgys73Gv7r/8B xZrzDGrUVwrAPDcqPOMs4+8ru/UWvIXDI0gSbkPyBN98fc/LIqcrZEd0Yuf4Y5O4FiIN w/7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=NcprC+evCbGN2L6YxeVZI2uUkRoNRV3ogE6fBikK1Ag=; b=zKQjuwFFPIuHm+nUokA7xW2EEan8ubx3y+aBNfFTLQBpvLJh0LgM8KY0HGgKir3z0B V72shBCKVyPnfXCxzZ+VKB2zeC1leb2scdfONRX2MsZUHu3tS2IgASwkuolry/QKyTxW 2UcQt3naoIoZsG4om9/Kt+QLHura1k2MjnlEHzilFLKWcjyHIwT7GwEF3Oz1qoMKnEUQ 7MaiFjnyA9pg6WE3AKgKfw4ZD75qK9Ix8qm1TkFTg3WeW5BaKmP+hiC4WP1fYfz+UB0a IWjah5iTSbZH7QaGYmfSev9Wr5m/+XOKyj2QwEEM4xPHZRf+nck8VOn8b/LQMu3UAqQ7 4dmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v201si11265524pgb.394.2019.08.12.06.33.13; Mon, 12 Aug 2019 06:33:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728812AbfHLNc1 (ORCPT + 99 others); Mon, 12 Aug 2019 09:32:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:53180 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726502AbfHLNc0 (ORCPT ); Mon, 12 Aug 2019 09:32:26 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0DF93AF5A; Mon, 12 Aug 2019 13:32:24 +0000 (UTC) Subject: Re: [RFC PATCH v2] mm: slub: print kernel addresses in slub debug messages To: Matthew Wilcox , miles.chen@mediatek.com Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, wsd_upstream@mediatek.com, "Tobin C . Harding" , Kees Cook References: <20190809010837.24166-1-miles.chen@mediatek.com> <20190809024644.GL5482@bombadil.infradead.org> From: Vlastimil Babka Openpgp: preference=signencrypt Autocrypt: addr=vbabka@suse.cz; prefer-encrypt=mutual; keydata= mQINBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej2qx9B75qW2plBs+7+YB 87tMFA+u+L4Z5xAzIimfLD5EKC56kJ1CsXlM8S/LHcmdD9Ctkn3trYDNnat0eoAcfPIP2OZ+ 9oe9IF/R28zmh0ifLXyJQQz5ofdj4bPf8ecEW0rhcqHfTD8k4yK0xxt3xW+6Exqp9n9bydiy tcSAw/TahjW6yrA+6JhSBv1v2tIm+itQc073zjSX8OFL51qQVzRFr7H2UQG33lw2QrvHRXqD Ot7ViKam7v0Ho9wEWiQOOZlHItOOXFphWb2yq3nzrKe45oWoSgkxKb97MVsQ+q2SYjJRBBH4 8qKhphADYxkIP6yut/eaj9ImvRUZZRi0DTc8xfnvHGTjKbJzC2xpFcY0DQbZzuwsIZ8OPJCc LM4S7mT25NE5kUTG/TKQCk922vRdGVMoLA7dIQrgXnRXtyT61sg8PG4wcfOnuWf8577aXP1x 6mzw3/jh3F+oSBHb/GcLC7mvWreJifUL2gEdssGfXhGWBo6zLS3qhgtwjay0Jl+kza1lo+Cv BB2T79D4WGdDuVa4eOrQ02TxqGN7G0Biz5ZLRSFzQSQwLn8fbwARAQABtCBWbGFzdGltaWwg QmFia2EgPHZiYWJrYUBzdXNlLmN6PokCVAQTAQoAPgIbAwULCQgHAwUVCgkICwUWAgMBAAIe AQIXgBYhBKlA1DSZLC6OmRA9UCJPp+fMgqZkBQJcbbyGBQkH8VTqAAoJECJPp+fMgqZkpGoP /1jhVihakxw1d67kFhPgjWrbzaeAYOJu7Oi79D8BL8Vr5dmNPygbpGpJaCHACWp+10KXj9yz fWABs01KMHnZsAIUytVsQv35DMMDzgwVmnoEIRBhisMYOQlH2bBn/dqBjtnhs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pdaNpSlXKpj/K6KrnyAI/joYc7 Message-ID: Date: Mon, 12 Aug 2019 15:32:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190809024644.GL5482@bombadil.infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/9/19 4:46 AM, Matthew Wilcox wrote: > On Fri, Aug 09, 2019 at 09:08:37AM +0800, miles.chen@mediatek.com wrote: >> Possible approaches are: >> 1. stop printing kernel addresses >> 2. print with %pK, >> 3. print with %px. > > No. The point of obscuring kernel addresses is that if the attacker manages to find a way to get the kernel to spit out some debug messages that we shouldn't > leak all this extra information. On the other hand, while CONFIG_SLUB_DEBUG=y is common, the actual checks and printing happens when the (relatively expensive) checks are actually enabled during boot, i.e. during a debugging session, not production defaults. I can see how knowing the exact address might be useful when e.g. a crash dump is also taken. I would say %pK would be a good fit, if kptr_restrict also had a setting that makes %pK behave like %px (looks like it doesn't), so that setting would be enabled in such a debugging session. >> 4. do nothing > > 5. Find something more useful to print. > >> INFO: Slab 0x(____ptrval____) objects=25 used=10 fp=0x(____ptrval____) > > ... you don't have any randomness on your platform? > >> INFO: Object 0x(____ptrval____) @offset=1408 fp=0x(____ptrval____) >> Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b >> Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b >> Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b >> Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b >> Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b >> Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b >> Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b >> Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5 >> Redzone (____ptrval____): bb bb bb bb bb bb bb bb >> Padding (____ptrval____): 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a >> Padding (____ptrval____): 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a >> Padding (____ptrval____): 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a >> Padding (____ptrval____): 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a >> ... >> FIX kmalloc-128: Object at 0x(____ptrval____) not freed > > But if you have randomness, at least some of these "pointers" are valuable > because you can compare them against "pointers" printed by other parts > of the kernel. > >> After this patch: >> >> INFO: Slab 0xffffffbf00f57000 objects=25 used=23 fp=0xffffffc03d5c3500 >> INFO: Object 0xffffffc03d5c3500 @offset=13568 fp=0xffffffc03d5c0800 >> Redzone 00000000: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Redzone 00000010: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Redzone 00000020: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Redzone 00000030: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Redzone 00000040: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Redzone 00000050: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Redzone 00000060: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Redzone 00000070: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb >> Object 00000000: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b >> Object 00000010: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b >> Object 00000020: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b >> Object 00000030: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b >> Object 00000040: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b >> Object 00000050: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b >> Object 00000060: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b >> Object 00000070: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5 >> Redzone 00000000: bb bb bb bb bb bb bb bb >> Padding 00000000: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a >> Padding 00000010: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a >> Padding 00000020: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a >> Padding 00000030: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a >> ... >> FIX kmalloc-128: Object at 0xffffffc03d5c3500 not freed > > It looks prettier, but I'm not convinced it's more useful. Unless your > platform lacks randomness ... >