From patchwork Wed Dec 22 21:30:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mimi Zohar X-Patchwork-Id: 12697338 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC5E2C433FE for ; Wed, 22 Dec 2021 21:36:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236704AbhLVVgU (ORCPT ); Wed, 22 Dec 2021 16:36:20 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35684 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234222AbhLVVgU (ORCPT ); Wed, 22 Dec 2021 16:36:20 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1BMLDIls005274; Wed, 22 Dec 2021 21:36:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=XTjTf9pbhvJ4dEZtdy1dWmdIbs4FdTkVSeAQRaR7f0w=; b=izxpPwredIkOFuGykGLDxSAoagx9HcrCVE/Xzm5z0xm6rz/Gh1JyBAWRWF7QQNNmfROi LmOBR8Ac6eN9zUhmcEo4FfjdrjOz8Q9yPBIaKaW9xH5gXimL1NH5T+DCsrXZm5+PzM3M VJ3Sm6NfSnDSCYaXJrXEtQabSMP5nMhfiPTca8wNBIVS+bVxC+jQ9XO+SYjBRRKnuj3A +8lMTfZP+JVaefUzC4YJuH7OeYLmFu7TT7oflKqFnuDs1F/BEySdNH+6YlwJf+caAG03 z7xDFD+0MZJuUHjTm1/J9ugBlqUYJAC2CEqHk68+nt00nmwljLtFDHuXhWoeE/wlnj85 Fw== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 3d4bra0akc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Dec 2021 21:36:13 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1BMLNaQb004564; Wed, 22 Dec 2021 21:31:10 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 3d179a203d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Dec 2021 21:31:10 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1BMLV7af39715206 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Dec 2021 21:31:07 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5CD3811C04C; Wed, 22 Dec 2021 21:31:07 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3D3A711C050; Wed, 22 Dec 2021 21:31:06 +0000 (GMT) Received: from li-f45666cc-3089-11b2-a85c-c57d1a57929f.ibm.com.com (unknown [9.65.95.213]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 22 Dec 2021 21:31:06 +0000 (GMT) From: Mimi Zohar To: linux-integrity@vger.kernel.org Cc: Petr Vorel , Nageswara Sastry , Mimi Zohar , Takashi Iwai , Joey Lee , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/2] selftest/kexec: fix "ignored null byte in input" warning Date: Wed, 22 Dec 2021 16:30:51 -0500 Message-Id: <20211222213052.6771-2-zohar@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211222213052.6771-1-zohar@linux.ibm.com> References: <20211222213052.6771-1-zohar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: CtoJYWcNIoqE8bc4oF542JxRax7UZ7p1 X-Proofpoint-GUID: CtoJYWcNIoqE8bc4oF542JxRax7UZ7p1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-22_09,2021-12-22_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 adultscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 bulkscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112220112 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Instead of assigning the string to a variable, which might contain a null character, redirect the output and grep for the string directly. Signed-off-by: Mimi Zohar Reviewed-by: Petr Vorel --- Comment: this patch was previously posted as part of Nageswara's larger patch set. tools/testing/selftests/kexec/test_kexec_file_load.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kexec/test_kexec_file_load.sh b/tools/testing/selftests/kexec/test_kexec_file_load.sh index 2ff600388c30..99f6fc23ee31 100755 --- a/tools/testing/selftests/kexec/test_kexec_file_load.sh +++ b/tools/testing/selftests/kexec/test_kexec_file_load.sh @@ -97,10 +97,11 @@ check_for_imasig() check_for_modsig() { local module_sig_string="~Module signature appended~" - local sig="$(tail --bytes $((${#module_sig_string} + 1)) $KERNEL_IMAGE)" local ret=0 - if [ "$sig" == "$module_sig_string" ]; then + tail --bytes $((${#module_sig_string} + 1)) $KERNEL_IMAGE | \ + grep -q "$module_sig_string" + if [ $? -eq 0 ]; then ret=1 log_info "kexec kernel image modsig signed" else From patchwork Wed Dec 22 21:30:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mimi Zohar X-Patchwork-Id: 12697316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 719DCC433F5 for ; Wed, 22 Dec 2021 21:31:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239645AbhLVVbW (ORCPT ); Wed, 22 Dec 2021 16:31:22 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:46722 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239173AbhLVVbW (ORCPT ); Wed, 22 Dec 2021 16:31:22 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1BMKB4jU013930; Wed, 22 Dec 2021 21:31:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=LMCKsYDSgWU68Pq4F970el0OH2FT6dTQlCiEQzzpTOk=; b=L0jxOjMTJ25mvTUplhfFHHH6AR+g8x2nykbBr/01H1/BKT/AFnD+Nv67knMFEgkbiaCZ MRRvc1mKbS1uBO1DMvtUGtYiTI9hE/p0eC4RY2BB/Mmh6NN9DTRFVftlTKh3yeuy7ff0 uddP/PIQVLPG/h0IuOBI+Ovrb7TNWf59c8yRw0js/k8TPASbTcmO7hwcwuCm26W9efeA Mnil5ZkoHIsnk2eeUpOQJ0Jeo7R9io01PN2RqD148/FiEflZ1IQ2kin2AQGYP2rtyzjB Pqb1ElonET2Kfrcvm2X8L/oxR7fAx8GOskK75iTGgE3MbOR5TrSUuvBlusOMSaBG/lz1 HQ== Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 3d47ssmukw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Dec 2021 21:31:14 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1BMLM5JE004516; Wed, 22 Dec 2021 21:31:12 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03fra.de.ibm.com with ESMTP id 3d179a865s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Dec 2021 21:31:11 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1BMLV8Hg47448448 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Dec 2021 21:31:08 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B785811C054; Wed, 22 Dec 2021 21:31:08 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C01211C04A; Wed, 22 Dec 2021 21:31:07 +0000 (GMT) Received: from li-f45666cc-3089-11b2-a85c-c57d1a57929f.ibm.com.com (unknown [9.65.95.213]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 22 Dec 2021 21:31:07 +0000 (GMT) From: Mimi Zohar To: linux-integrity@vger.kernel.org Cc: Petr Vorel , Nageswara Sastry , Mimi Zohar , Takashi Iwai , Joey Lee , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/2] selftests/kexec: update searching for the Kconfig Date: Wed, 22 Dec 2021 16:30:52 -0500 Message-Id: <20211222213052.6771-3-zohar@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211222213052.6771-1-zohar@linux.ibm.com> References: <20211222213052.6771-1-zohar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: i3CDj2thOqffQSG8bXbv7X51QwWISv09 X-Proofpoint-ORIG-GUID: i3CDj2thOqffQSG8bXbv7X51QwWISv09 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-22_09,2021-12-22_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 adultscore=0 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=857 impostorscore=0 priorityscore=1501 clxscore=1015 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112220112 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org First check /lib/modules/`uname -r`/config, before using the IKCONFIG. In addition, the configs.ko might be compressed. Fix the configs.ko name. Signed-off-by: Mimi Zohar Reviewed-by: Petr Vorel --- Distros: is storing the Kconfig in /lib/modules/`uname -r`/config common? tools/testing/selftests/kexec/kexec_common_lib.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/kexec/kexec_common_lib.sh b/tools/testing/selftests/kexec/kexec_common_lib.sh index 43017cfe88f7..5a1b8ae04c64 100755 --- a/tools/testing/selftests/kexec/kexec_common_lib.sh +++ b/tools/testing/selftests/kexec/kexec_common_lib.sh @@ -138,15 +138,20 @@ kconfig_enabled() return 0 } -# Attempt to get the kernel config first via proc, and then by -# extracting it from the kernel image or the configs.ko using -# scripts/extract-ikconfig. +# Attempt to get the kernel config first by checking the modules directory +# then via proc, and finally by extracting it from the kernel image or the +# configs.ko using scripts/extract-ikconfig. # Return 1 for found. get_kconfig() { local proc_config="/proc/config.gz" local module_dir="/lib/modules/`uname -r`" - local configs_module="$module_dir/kernel/kernel/configs.ko" + local configs_module="$module_dir/kernel/kernel/configs.ko*" + + if [ -f $module_dir/config ]; then + IKCONFIG=$module_dir/config + return 1 + fi if [ ! -f $proc_config ]; then modprobe configs > /dev/null 2>&1