From patchwork Thu Feb 20 16:00:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mimi Zohar X-Patchwork-Id: 13984175 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2CD41CA84 for ; Thu, 20 Feb 2025 16:01:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740067271; cv=none; b=Lmb/IyuxKqDp0elj0Hu/SkNg0OQzESeiZcWcv7tPHJf5Fg2CPasX8Q6g0QvmBSEBjYVzQU8pP61KT/OOhM3Fy6dAEB1OjvzyVLY2JJ3z+MNTlxo8kcJYv5qCJnDBXaKyUarel6DnOwIBLxc6iVSPA2+MECa5J5bY/W2NuPjGkLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740067271; c=relaxed/simple; bh=x1lUNsbMx24UZVy2pAKQl+kkCz6RaD5eGaWkv7CCrTc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kUgsM6FcKzq2fSyoavHE0TxqGbI00+jkH45uaeGeKwCRlSBRyEFeiVK0DMaqxgP0rnw8Zd5vzwHeQNtqUuWfUQwLQNYYFn4pb2RQZGfx1KGK9zWuOahZiqmV1SsKN2ELltU7Cowzuw6zfalOAAAMURK6Kk7q64ew1pKgskRrspc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=DiwK+xxo; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="DiwK+xxo" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51KD5dGu002208; Thu, 20 Feb 2025 16:01:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=pp1; bh=ZBaeMWKBnDCdyczPSP1LPCqo8qHfeKkPSJaoyxEDx yA=; b=DiwK+xxofEyTygsYWneuMF9vldkaSl4dKeu1q+t/WL0RA70CLo/biYuuT EDSexpL77QEIkJT9VWPdndLl6fjLFN5g8409ahevaeNXSxaiRirjFDxCjH79ZgKo pb17sz+fl5duneWZeHMvANJXZSv96JkIRnKVcC9j0d98bNuNk+DU890y6QAu3id6 mDVMy1064EFEAuvqJJINq7OwIALNgJUA/cy+nUdtcrkqoslV0YV8F6OkY8uvgVze RwKOq2vvJF5vxw+pTTDT6V/Jy+p9lL1fizsnWpuC3LGjFNdkp+WGIsSJw4znBLz5 ENriXpYS/Rsi8uUMGr6yWLklszvAg== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 44wtfa3vx9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Feb 2025 16:01:03 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 51KFIsv9002297; Thu, 20 Feb 2025 16:01:02 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 44w03xasmh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Feb 2025 16:01:02 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 51KG0xYf35258720 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2025 16:00:59 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0E93F20040; Thu, 20 Feb 2025 16:00:59 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B3A720043; Thu, 20 Feb 2025 16:00:57 +0000 (GMT) Received: from li-43857255-d5e6-4659-90f1-fc5cee4750ad.ibm.com.com (unknown [9.61.68.26]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 20 Feb 2025 16:00:57 +0000 (GMT) From: Mimi Zohar To: linux-integrity@vger.kernel.org, ltp@lists.linux.it Cc: Mimi Zohar , Stefan Berger , Petr Vorel Subject: [RFC PATCH 1/3] Update validate() to support multiple violations Date: Thu, 20 Feb 2025 11:00:52 -0500 Message-ID: <20250220160054.12149-1-zohar@linux.ibm.com> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: linux-integrity@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: dHQh1-JARp1NtoejAZc0jPExh8WTLmfC X-Proofpoint-GUID: dHQh1-JARp1NtoejAZc0jPExh8WTLmfC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-20_06,2025-02-20_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=865 bulkscore=0 phishscore=0 malwarescore=0 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2502100000 definitions=main-2502200113 Add support for the number of expected violations. Include the expected number of violations in the output. Signed-off-by: Mimi Zohar --- .../security/integrity/ima/tests/ima_violations.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/security/integrity/ima/tests/ima_violations.sh b/testcases/kernel/security/integrity/ima/tests/ima_violations.sh index 37d8d473c..7f0382fb8 100755 --- a/testcases/kernel/security/integrity/ima/tests/ima_violations.sh +++ b/testcases/kernel/security/integrity/ima/tests/ima_violations.sh @@ -71,20 +71,26 @@ validate() local num_violations="$1" local count="$2" local search="$3" + local expected_violations=$4 local max_attempt=3 local count2 i num_violations_new + [ -z $expected_violations ] && expected_violations=1 + for i in $(seq 1 $max_attempt); do read num_violations_new < $IMA_VIOLATIONS count2="$(get_count $search)" - if [ $(($num_violations_new - $num_violations)) -gt 0 ]; then + if [ $(($num_violations_new - $num_violations)) -eq $expected_violations ]; then if [ $count2 -gt $count ]; then - tst_res TPASS "$search violation added" + tst_res TPASS "$expected_violations $search violation(s) added" return else tst_res TINFO "$search not found in $LOG ($i/$max_attempt attempt)..." tst_sleep 1s fi + elif [ $(($num_violations_new - $num_violations)) -gt 0 ]; then + tst_res $IMA_FAIL "$search too many violations added" + return else tst_res $IMA_FAIL "$search violation not added" return From patchwork Thu Feb 20 16:00:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mimi Zohar X-Patchwork-Id: 13984176 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCC681CA84 for ; Thu, 20 Feb 2025 16:01:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740067273; cv=none; b=r1ig7ZUa9Xhsr71MRWVtn67iK/anMGUAybgOUiYWt8WvmNi2qVJ9De6lhhJz1pzgy1MREhaX4TRapqsn2q8pKui/sW5WhO15qAEEdGL+OBf5zlSQ7PkDIG64CXKKxeJg85wIjXgrxCbtV1N5JsnrBe3etXzDlKhl4D1CYUZf1JQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740067273; c=relaxed/simple; bh=Hb5WEoeqD5+0JRtMRFMJkF4PrBhx81bCPCqnYfGsF7Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZTaVQVp+FbcpqoqEyNR/3DMSA0dyrxtZGzGkUFsX75veUxeU6pCwUcJ6Fvr2Vly5XEyrbYsA9Tj8ZuGaHaxNvK4sydL/kV8vrOjFn8NUkOwCA/30sD5XSu4wEdntytyZVnC58S6nZQvg14Om/iacy1TQxSOVgw+i75hZGnztB+Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=izQqHok8; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="izQqHok8" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51KChoQ1002255; Thu, 20 Feb 2025 16:01:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=rbxod9JTGJoVOfBeZ k/WaVpR0qDcIB1nEh0Q2tRv6Cg=; b=izQqHok8jSfFFlqiVVKXrazRb7VDcvmTF 2iGfg4g/YS/SVpF/qDmXSB2r7b7mwq5P5IJikLcjJq5FQwdoZAJpgsWbpUrkSvAc OFv0ciDQzR16Cc2UAe3WVQgDRhm+EQhiFEk1WfndaR97b6eXvrgX3HoDdLD/Rb1A ZXV5CqqbOPcwU0DfHgyJbIQj0XP4Xz1PzcsYIDAwJIpI3/i8T7Bj7p0HVm8TwlCU UqXGF979pxA7Frh7efbC2aIzROni7vXw8OFgOWmBz3lYNorPPY/IAxheVoCqS9BK TQCiOHzs31QMHjiMsCgLPiB6DJSDxzkPDY6r6TVCtM3hAirOYkgOQ== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 44wtfa3vxf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Feb 2025 16:01:05 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 51KEt3kl009691; Thu, 20 Feb 2025 16:01:04 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 44w03yauc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Feb 2025 16:01:04 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 51KG10A547972822 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2025 16:01:00 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C7A0E20043; Thu, 20 Feb 2025 16:01:00 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 71FE520040; Thu, 20 Feb 2025 16:00:59 +0000 (GMT) Received: from li-43857255-d5e6-4659-90f1-fc5cee4750ad.ibm.com.com (unknown [9.61.68.26]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 20 Feb 2025 16:00:59 +0000 (GMT) From: Mimi Zohar To: linux-integrity@vger.kernel.org, ltp@lists.linux.it Cc: Mimi Zohar , Stefan Berger , Petr Vorel Subject: [RFC PATCH 2/3] ima: additional open-writer violation tests Date: Thu, 20 Feb 2025 11:00:53 -0500 Message-ID: <20250220160054.12149-2-zohar@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220160054.12149-1-zohar@linux.ibm.com> References: <20250220160054.12149-1-zohar@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-integrity@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: RRJqZnyL4wCpdTttUCOXzBT53TClYZkP X-Proofpoint-GUID: RRJqZnyL4wCpdTttUCOXzBT53TClYZkP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-20_06,2025-02-20_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=905 bulkscore=0 phishscore=0 malwarescore=0 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2502100000 definitions=main-2502200113 Kernel patch "ima: limit the number of open-writers integrity violations" prevents superfluous "open-writers" violations. Add corresponding LTP tests. Link: https://lore.kernel.org/linux-integrity/20250219162131.416719-2-zohar@linux.ibm.com/ Signed-off-by: Mimi Zohar --- .../integrity/ima/tests/ima_violations.sh | 87 ++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/testcases/kernel/security/integrity/ima/tests/ima_violations.sh b/testcases/kernel/security/integrity/ima/tests/ima_violations.sh index 7f0382fb8..65c5c3a92 100755 --- a/testcases/kernel/security/integrity/ima/tests/ima_violations.sh +++ b/testcases/kernel/security/integrity/ima/tests/ima_violations.sh @@ -8,7 +8,7 @@ TST_SETUP="setup" TST_CLEANUP="cleanup" -TST_CNT=3 +TST_CNT=6 REQUIRED_BUILTIN_POLICY="tcb" REQUIRED_POLICY_CONTENT='violations.policy' @@ -60,6 +60,17 @@ close_file_write() exec 4>&- } +open_file_write2() +{ + exec 5> $FILE || exit 1 + echo 'test writing2' >&5 +} + +close_file_write2() +{ + exec 5>&- +} + get_count() { local search="$1" @@ -160,6 +171,80 @@ test3() tst_sleep 2s } +test4() +{ + tst_res TINFO "verify limiting single open writer violation" + + local search="open_writers" + local count num_violations + + read num_violations < $IMA_VIOLATIONS + count="$(get_count $search)" + + open_file_write + open_file_read + close_file_read + + open_file_read + close_file_read + + close_file_write + + validate $num_violations $count $search 1 +} + +test5() +{ + tst_res TINFO "verify limiting multiple open writers violations" + + local search="open_writers" + local count num_violations + + read num_violations < $IMA_VIOLATIONS + count="$(get_count $search)" + + open_file_write + open_file_read + close_file_read + + open_file_write2 + open_file_read + close_file_read + close_file_write2 + + open_file_read + close_file_read + + close_file_write + + validate $num_violations $count $search 1 +} + +test6() +{ + tst_res TINFO "verify new open writer causes additional violation" + + local search="open_writers" + local count num_violations + + read num_violations < $IMA_VIOLATIONS + count="$(get_count $search)" + + open_file_write + open_file_read + close_file_read + + open_file_read + close_file_read + close_file_write + + open_file_write + open_file_read + close_file_read + close_file_write + validate $num_violations $count $search 2 +} + . ima_setup.sh . daemonlib.sh tst_run From patchwork Thu Feb 20 16:00:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mimi Zohar X-Patchwork-Id: 13984177 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 725D81FF7B7 for ; Thu, 20 Feb 2025 16:01:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740067275; cv=none; b=ZcInrWLTaU2OhnbleVBtwXLxLoV4bjvqOAjySC3ydhd62M34d+RWuMKnKviwvrDFrxqxiwaf/uAb5mR5yO6KPmGibFVYQt2NazfxmOE3v/j7uCZ7WIsHz7V8zFDS+cfmNt+qQ9YVfZg4DfOnLN+yjkNvkaEIjNuaJszC+wNfguc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740067275; c=relaxed/simple; bh=cLwAVuRJv8oolEMtxUlGLIdbmqTU2Q4EO9ve85wejxM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AhlEt4EXZbHp5bvw7r7MKwEEpmA8ujErIZboBAsmLJi4YVTGiYulBRjw5ju+u4LBdHD/C9fT0VlXQ+y8EuMpsIaPOYcR8eYr5K9f5FGGETkL9VnmtVeSC9RRrGvEZ0K/s75AXwj9rzxEZaSDSkUOBamqDrMBUu9B+0MJlRy9vsQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=S6bLBx9i; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="S6bLBx9i" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51K7Wq9X008224; Thu, 20 Feb 2025 16:01:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=/UUSWhrXooLS6NXNd 9cpiIivxQgEZ21j5nQ3LsB5ejY=; b=S6bLBx9iByg2yta8dal8xykRi8w9pb3dV esJKVsZxhvJSpjBrfXrfkxqZJv9gW/mNuiKryLE3nNMqqze817nNSMWm0ILKB/Nb szq0i5b2ehzgftNbbDe3PO56Py0nsIgYwKUpAsFBsVQvcZhzXxsGr11e39DR2YGx OVMOZLtILKt5mHfPMB31Agtaxi6WTjbWkECo9rAKAhhWwG8LVseAR7xGOCMRpBgC RjLa7yKD/FpehA+w0J0nX+UtNZ3nfukWzBMEojs39y8wL+9xrqnXCEOhNIjg6Dwj 9IgBP0uUHqcmNq9qU3GQS6DNjrVxPSBi9xZQtwNfQfaV5XcnF+4Kw== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 44x03qthka-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Feb 2025 16:01:07 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 51KF7x6T005771; Thu, 20 Feb 2025 16:01:06 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 44w02xjtj8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Feb 2025 16:01:06 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 51KG125G43516188 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2025 16:01:02 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D41420043; Thu, 20 Feb 2025 16:01:02 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 337E820040; Thu, 20 Feb 2025 16:01:01 +0000 (GMT) Received: from li-43857255-d5e6-4659-90f1-fc5cee4750ad.ibm.com.com (unknown [9.61.68.26]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 20 Feb 2025 16:01:00 +0000 (GMT) From: Mimi Zohar To: linux-integrity@vger.kernel.org, ltp@lists.linux.it Cc: Mimi Zohar , Stefan Berger , Petr Vorel Subject: [RFC PATCH 3/3] ima: additional ToMToU violation tests Date: Thu, 20 Feb 2025 11:00:54 -0500 Message-ID: <20250220160054.12149-3-zohar@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250220160054.12149-1-zohar@linux.ibm.com> References: <20250220160054.12149-1-zohar@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-integrity@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: tbRq0PLQX38hTjWatrv4JsZBqxCpznMF X-Proofpoint-ORIG-GUID: tbRq0PLQX38hTjWatrv4JsZBqxCpznMF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-20_06,2025-02-20_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxscore=0 phishscore=0 mlxlogscore=581 impostorscore=0 bulkscore=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 spamscore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2502100000 definitions=main-2502200113 Kernel patch "ima: limit the number of ToMToU integrity violations" prevents superfluous ToMToU violations. Add corresponding LTP tests. Link: https://lore.kernel.org/linux-integrity/20250219162131.416719-3-zohar@linux.ibm.com/ Signed-off-by: Mimi Zohar --- .../integrity/ima/tests/ima_violations.sh | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/testcases/kernel/security/integrity/ima/tests/ima_violations.sh b/testcases/kernel/security/integrity/ima/tests/ima_violations.sh index 65c5c3a92..5b6d7e993 100755 --- a/testcases/kernel/security/integrity/ima/tests/ima_violations.sh +++ b/testcases/kernel/security/integrity/ima/tests/ima_violations.sh @@ -8,7 +8,7 @@ TST_SETUP="setup" TST_CLEANUP="cleanup" -TST_CNT=6 +TST_CNT=8 REQUIRED_BUILTIN_POLICY="tcb" REQUIRED_POLICY_CONTENT='violations.policy' @@ -245,6 +245,50 @@ test6() validate $num_violations $count $search 2 } +test7() +{ + tst_res TINFO "verify limiting single open reader ToMToU violations" + + local search="ToMToU" + local count num_violations + + read num_violations < $IMA_VIOLATIONS + count="$(get_count $search)" + + open_file_read + open_file_write + close_file_write + + open_file_write + close_file_write + close_file_read + + validate $num_violations $count $search 1 +} + +test8() +{ + tst_res TINFO "verify new open reader causes additional ToMToU violation" + + local search="ToMToU" + local count num_violations + + read num_violations < $IMA_VIOLATIONS + count="$(get_count $search)" + + open_file_read + open_file_write + close_file_write + close_file_read + + open_file_read + open_file_write + close_file_write + close_file_read + + validate $num_violations $count $search 2 +} + . ima_setup.sh . daemonlib.sh tst_run