Received: by 10.223.185.116 with SMTP id b49csp1136112wrg; Fri, 16 Feb 2018 13:09:03 -0800 (PST) X-Google-Smtp-Source: AH8x224+AmNjGNDN6S6jfHseMTSZdg//mfnmfmFVN5CAOYyqkB2pFg5ol06MHRDwekoNCkefL/U1 X-Received: by 2002:a17:902:50e:: with SMTP id 14-v6mr6943916plf.360.1518815343542; Fri, 16 Feb 2018 13:09:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518815343; cv=none; d=google.com; s=arc-20160816; b=jx4zIohA5ICF4BvTYEI2a/5iplUlYM+NyhjlKH5DBokvVfWwMVV1713CS97XXhpQ6F bA8cLV2ziybYCq3zg02386Qv1GvZNLBW5oAMOUw8A+OWPGn6tclou3cHZae//+maZIvt i6p5z6utsMZIH9w2mVqlqOFZv2SthCDcuErgfJR/d3KjZS8I7m5sKFnjboVQ4Ive7g9N YvArjfYVKtlXwqdqJolMMIgOdbbMfKsKywqly6RIG5dEiTHGmo54Ro0FWGUJNcXxMvE3 VdOUe5YEqJmE39JmazKVS5fZ5LYUNVu+NB/U571OM+iSY3jo09roAYzqDRvW+ZoMgtWA jBGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=AO9jx9dQfWm/4H6l7zH8fep6UqI6M6AAbTvE8ClvS5g=; b=A4bmnub1GxafUyCuTGTkbhT5gCp4Sarucs14c2j80WtEifqasor9NqQyBjOK1IS8xk yko2gjEaCpMrX9E2+LNKpL6WxYVVimH6BWtT+hIEqlJtklBezx4Y58gYV1nf7QS6RuFf /xTqcKLTxRIGq3mq6y9CHolabrsXQY6ZX6pmbvzp7mgLVIY2hchuDti2UY2k/+U8QaNT gaDXOjZ3ivE95Fxmyl1LHzA+na2WVxRispexBBQVH0pWHriCMMvZnR4RT6uwTLYzJKLJ nqSqgxSxC/pm+/SKd5ROUnXLSAy28EfKt+orzm0Xjd4eS0ELLI+afZgvu8iai41rWNoY W9MA== 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 1-v6si6937658plw.164.2018.02.16.13.08.49; Fri, 16 Feb 2018 13:09:03 -0800 (PST) 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 S1751091AbeBPVHx (ORCPT + 99 others); Fri, 16 Feb 2018 16:07:53 -0500 Received: from mga12.intel.com ([192.55.52.136]:28372 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750899AbeBPVHT (ORCPT ); Fri, 16 Feb 2018 16:07:19 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Feb 2018 13:07:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,520,1511856000"; d="scan'208";a="35372234" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 16 Feb 2018 13:07:16 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 451D130A; Fri, 16 Feb 2018 23:07:13 +0200 (EET) From: Andy Shevchenko To: "Tobin C . Harding" , linux@rasmusvillemoes.dk, Petr Mladek , Joe Perches , linux-kernel@vger.kernel.org, Andrew Morton Cc: Shunyong Yang , Joey Zheng , Andy Shevchenko Subject: [PATCH v2 7/9] lib/vsprintf: Replace space with '_' before crng is ready Date: Fri, 16 Feb 2018 23:07:09 +0200 Message-Id: <20180216210711.79901-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180216210711.79901-1-andriy.shevchenko@linux.intel.com> References: <20180216210711.79901-1-andriy.shevchenko@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shunyong Yang Before crng is ready, output of "%p" composes of "(ptrval)" and left padding spaces for alignment as no random address can be generated. This seems a little strange when default string width is larger than strlen("(ptrval)"). For example, when irq domain names are built with "%p", the nodes under /sys/kernel/debug/irq/domains like this on AArch64 system, [root@y irq]# ls domains/ default irqchip@ (ptrval)-2 irqchip@ (ptrval)-4 \_SB_.TCS0.QIC1 \_SB_.TCS0.QIC3 irqchip@ (ptrval) irqchip@ (ptrval)-3 \_SB_.TCS0.QIC0 \_SB_.TCS0.QIC2 The name "irqchip@ (ptrval)-2" is not so readable in console output. This patch replaces space with readable "_" when output needs padding. Following is the output after applying the patch, [root@y domains]# ls default irqchip@(____ptrval____)-2 irqchip@(____ptrval____)-4 \_SB_.TCS0.QIC1 \_SB_.TCS0.QIC3 irqchip@(____ptrval____) irqchip@(____ptrval____)-3 \_SB_.TCS0.QIC0 \_SB_.TCS0.QIC2 There is same problem in some subsystem's dmesg output. Moreover, someone may call "%p" in a similar case. In addition, the timing of crng initialization done may vary on different system. So, the change is made in vsprintf.c. Cc: Joey Zheng Suggested-by: Rasmus Villemoes Signed-off-by: Shunyong Yang Signed-off-by: Andy Shevchenko --- lib/vsprintf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 9004bbb3d84d..97be2d07297a 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1681,12 +1681,13 @@ early_initcall(initialize_ptr_random); /* Maps a pointer to a 32 bit unique identifier. */ static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec) { + const char *str = sizeof(ptr) == 8 ? "(____ptrval____)" : "(ptrval)"; unsigned long hashval; if (unlikely(!have_filled_random_ptr_key)) { spec.field_width = 2 * sizeof(ptr); /* string length must be less than default_width */ - return string(buf, end, "(ptrval)", spec); + return string(buf, end, str, spec); } #ifdef CONFIG_64BIT -- 2.15.1