From patchwork Wed Jun 13 17:18:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Escande X-Patchwork-Id: 138509 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1004994lji; Wed, 13 Jun 2018 10:18:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKR8GyPlUF3BxU1zIbzPUo+i3APtoy+XqCYi/9YYq2v5IT4C9J68pxRK5JduHEK7rhv88px X-Received: by 2002:a65:5b4c:: with SMTP id y12-v6mr4902562pgr.442.1528910339029; Wed, 13 Jun 2018 10:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528910339; cv=none; d=google.com; s=arc-20160816; b=rhAQQJmIsSNLa5erFQ/CetOX/yWtHc4SI7HJ6TPKisOgfHJyl1qJrJKKQUovObXQwR 5CyYXVdn8BIKbYXOk0w5Aty4V1IOwg1xfiZqK5wV0Q/oKjOuC8Enhekeg+R309u+w88E BXMf4I7ZxVSlCog+pmra9U3N0hA1GKjNoYcSni+oUrQC0Hig0MM4EhVjjvqigd8wf8xf LVJRhZJC7q9j4WbrHIrm/caBRJlv3ffVVGABs00ewQ2itwgE6ipq4XAAzlSoMibRBBT1 tZF0Pe5sFWEoHXHUCUXgGrwHAhVu7tSeJYh5s4WMp8DmKe5px5CXnuZkyKoU5osNSRqV ovxA== 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 g6-v6si2669362pgq.662.2018.06.13.10.18.58; Wed, 13 Jun 2018 10:18: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 S935434AbeFMRSz (ORCPT + 30 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-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(-) -- 2.14.1 Reviewed-by: Andy Shevchenko 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;