Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp921464imm; Wed, 13 Jun 2018 10:19:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJCmPqu5FIMwIcbwdG8CPzFCRrUcD8eybyU5rRmxnnPlMg3MMJcF4bdHHt3yNErECVTlSO2 X-Received: by 2002:a17:902:6546:: with SMTP id d6-v6mr6066973pln.196.1528910399393; Wed, 13 Jun 2018 10:19:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528910399; cv=none; d=google.com; s=arc-20160816; b=IU8fXqor2YIn2y7EeKlJ2ojLd8oVQ4FfurN/i0sMXKBtXxVPiDf/ZOziprjDU+NHUC qrPRtkgw/RlgY/M1jpBGjlkYHwqXAYGDAluT1Wk68TKB+L+NCjYdiQ83SElFt8XDQWr8 hfhEBGmF40vAqk8bhi3fsQbjVRp+8Tfwt4fauPBWGCTCvoR4pN7VfSnDo99j3bS6XyVy cjVIOurp60T0BoNGNFUvR4LTRzHZLAFs8RlTU9l2KCODQ31JSui63i0txHV4nlpCSt4g b2e65uXEsiuUoykpJeDNYNUH50oTSQ4YpUApYu2gLnon1e78Pwc+Mv9q3MYMd2LMW7gy sT8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfert-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=W8WN1gaVXifDNIN3QmSq6IzPlR5M7ezVmlYt1YIRF88=; b=A7Elc1ToJPHv9ZDkdNUXAeb5SGZjgoczZ+x94xNmnKkFAq2/aQ+w9J3wUey3DlRUNW geqN3gM/A6n7qAxL3oM0ZaBsQqLmffYs+Bw8mJHQ/936FozfXizG+iSgEGzfEwtg50tj XEdO3kfiqLGSfynHFB2F9/+eaffc+a3CVhtxVzi/ERXYQyXH2ks3s7ZUcSRiwK+pw5hH Grd8k35HIcSxAHwa12vAXO9xtygzH5qU7vfnv/KfGKZdp0OQSYwMuHqIMmyP6mJczRdK gPppw7HE+ocm3fhW7eGGb0X5CvKq2hOYoJwxbxaAfc4NJX9/mAjPopdTV8ygpeGBK8ss 6TDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S2RdlVzk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e2-v6si2663293pgr.167.2018.06.13.10.19.45; Wed, 13 Jun 2018 10:19:59 -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; dkim=pass header.i=@linaro.org header.s=google header.b=S2RdlVzk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935426AbeFMRSz (ORCPT + 99 others); Wed, 13 Jun 2018 13:18:55 -0400 Received: from mail-wr0-f175.google.com ([209.85.128.175]:46693 "EHLO mail-wr0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935349AbeFMRSy (ORCPT ); Wed, 13 Jun 2018 13:18:54 -0400 Received: by mail-wr0-f175.google.com with SMTP id v13-v6so3545300wrp.13 for ; Wed, 13 Jun 2018 10:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfert-encoding; bh=W8WN1gaVXifDNIN3QmSq6IzPlR5M7ezVmlYt1YIRF88=; b=S2RdlVzkapa08DjEcNSKq5Uy6Mp1RtfQ487pnj8h2wzGPih4IT4CPYxPbU9wSRwIYB m+8TWXmFUaPgXLVQkcFNgskLwk2ePrgp6acvSb5PWZ6/WBJdPLYrHIlqhGxNN52gVk9C yCc8Bh4mHgDtmstHHYACh9zxl8nsYAWZtVRsM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfert-encoding; bh=W8WN1gaVXifDNIN3QmSq6IzPlR5M7ezVmlYt1YIRF88=; b=Gb7ITBl84JhsOW5kMAInqF1JGd55AL4eBmafyP9a+xya/xDg97j9F+35n+Qjeo1aXx g33K9Zckap1ewohVjfOgkadAO3Av+FdiVgF516fbhYV9QBFfdDNbciifZaRHUbqWen/k riAKFYvaCG4oR6T8ueCanumTlF7+T7xACJw5Y3jIDGuiH/w4NvYAkFnvGKrQTWl8iWAz YptBZ0cWDQerZcTX2hWlrIANn8eZzMU2fCdU14OkODcKxJxa7t+PSwz3ZFhh9g5ViUWf YBDUuz7ua24XXsAGfWvwgPMxfk2ZWVV8nfFcnolevPhXaYlynz1HZLqYnfEvgDwGzNEi jdbQ== X-Gm-Message-State: APt69E3ERO4a3zDcmhlhdIwFB/VFWV/0GzkMNroEgv+OQk3keaGLs91t y+Ta7VvIq1L2HNFek8w8WZSSuQ== X-Received: by 2002:a5d:4611:: with SMTP id t17-v6mr4657126wrq.74.1528910333531; Wed, 13 Jun 2018 10:18:53 -0700 (PDT) Received: from localhost.localdomain (aig34-1-88-167-228-121.fbx.proxad.net. [88.167.228.121]) by smtp.gmail.com with ESMTPSA id j131-v6sm6392813wmg.24.2018.06.13.10.18.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 10:18:52 -0700 (PDT) From: Thierry Escande To: Andrew Morton , David Miller , Andy Shevchenko , Petr Mladek Cc: Rasmus Villemoes , "Tobin C . Harding" , linux-kernel@vger.kernel.org Subject: [PATCH v3] lib/test_printf.c: accept "ptrval" as valid result for plain 'p' tests Date: Wed, 13 Jun 2018 19:18:40 +0200 Message-Id: <20180613171840.29827-1-thierry.escande@linaro.org> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset = "utf-8" Content-Transfert-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the test_printf module is loaded before the crng is initialized, the plain 'p' tests will fail because the printed address will not be hashed and the buffer will contain "(____ptrval____)" or "(ptrval)" instead (64-bit vs 32-bit). Since we cannot wait for the crng to be initialized for an undefined time, both plain 'p' tests now accept the strings "(____ptrval____)" or "(ptrval)" as a valid result and print a warning message. Signed-off-by: Thierry Escande --- Changes in v3: - Use "(____ptrval____)" for 64-bit - Update commit message headline Changes in v2: - Remove wait_for_random_bytes() usage - Remove Acked-by from Tobin as the proposed solution is not the same anymore. lib/test_printf.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index 71ebfa43ad05..31f00b8ca657 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -206,6 +206,7 @@ test_string(void) #define PTR_WIDTH 16 #define PTR ((void *)0xffff0123456789ab) #define PTR_STR "ffff0123456789ab" +#define PTR_VAL_NO_CRNG "(____ptrval____)" #define ZEROS "00000000" /* hex 32 zero bits */ static int __init @@ -216,7 +217,16 @@ plain_format(void) nchars = snprintf(buf, PLAIN_BUF_SIZE, "%p", PTR); - if (nchars != PTR_WIDTH || strncmp(buf, ZEROS, strlen(ZEROS)) != 0) + if (nchars != PTR_WIDTH) + return -1; + + if (strncmp(buf, PTR_VAL_NO_CRNG, PTR_WIDTH) == 0) { + pr_warn("crng possibly not yet initialized. plain 'p' buffer contains \"%s\"", + PTR_VAL_NO_CRNG); + return 0; + } + + if (strncmp(buf, ZEROS, strlen(ZEROS)) != 0) return -1; return 0; @@ -227,6 +237,7 @@ plain_format(void) #define PTR_WIDTH 8 #define PTR ((void *)0x456789ab) #define PTR_STR "456789ab" +#define PTR_VAL_NO_CRNG "(ptrval)" static int __init plain_format(void) @@ -245,7 +256,16 @@ plain_hash(void) nchars = snprintf(buf, PLAIN_BUF_SIZE, "%p", PTR); - if (nchars != PTR_WIDTH || strncmp(buf, PTR_STR, PTR_WIDTH) == 0) + if (nchars != PTR_WIDTH) + return -1; + + if (strncmp(buf, PTR_VAL_NO_CRNG, PTR_WIDTH) == 0) { + pr_warn("crng possibly not yet initialized. plain 'p' buffer contains \"%s\"", + PTR_VAL_NO_CRNG); + return 0; + } + + if (strncmp(buf, PTR_STR, PTR_WIDTH) == 0) return -1; return 0; -- 2.14.1