From: Mimi Zohar <zohar@linux.ibm.com>
To: linux-integrity@vger.kernel.org, ltp@lists.linux.it
Cc: Mimi Zohar <zohar@linux.ibm.com>,
Stefan Berger <stefanb@linux.ibm.com>,
Petr Vorel <pvorel@suse.cz>
Subject: [RFC PATCH 2/3] ima: additional open-writer violation tests
Date: Thu, 20 Feb 2025 11:00:53 -0500 [thread overview]
Message-ID: <20250220160054.12149-2-zohar@linux.ibm.com> (raw)
In-Reply-To: <20250220160054.12149-1-zohar@linux.ibm.com>
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 <zohar@linux.ibm.com>
---
.../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
--
2.48.1
WARNING: multiple messages have this Message-ID (diff)
From: Mimi Zohar <zohar@linux.ibm.com>
To: linux-integrity@vger.kernel.org, ltp@lists.linux.it
Cc: Stefan Berger <stefanb@linux.ibm.com>
Subject: [LTP] [RFC PATCH 2/3] ima: additional open-writer violation tests
Date: Thu, 20 Feb 2025 11:00:53 -0500 [thread overview]
Message-ID: <20250220160054.12149-2-zohar@linux.ibm.com> (raw)
In-Reply-To: <20250220160054.12149-1-zohar@linux.ibm.com>
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 <zohar@linux.ibm.com>
---
.../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
--
2.48.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-02-20 16:01 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 16:00 [RFC PATCH 1/3] Update validate() to support multiple violations Mimi Zohar
2025-02-20 16:00 ` [LTP] " Mimi Zohar
2025-02-20 16:00 ` Mimi Zohar [this message]
2025-02-20 16:00 ` [LTP] [RFC PATCH 2/3] ima: additional open-writer violation tests Mimi Zohar
2025-02-20 19:02 ` Petr Vorel
2025-02-20 19:02 ` [LTP] " Petr Vorel
2025-02-20 16:00 ` [RFC PATCH 3/3] ima: additional ToMToU " Mimi Zohar
2025-02-20 16:00 ` [LTP] " Mimi Zohar
2025-02-20 18:16 ` Petr Vorel
2025-02-20 18:16 ` [LTP] " Petr Vorel
2025-02-20 18:46 ` Petr Vorel
2025-02-20 18:46 ` [LTP] " Petr Vorel
2025-02-20 21:15 ` Mimi Zohar
2025-02-20 21:15 ` [LTP] " Mimi Zohar
2025-02-20 18:59 ` Mimi Zohar
2025-02-20 18:59 ` [LTP] " Mimi Zohar
2025-02-20 19:13 ` Petr Vorel
2025-02-20 19:13 ` [LTP] " Petr Vorel
2025-02-20 20:22 ` Mimi Zohar
2025-02-20 20:22 ` [LTP] " Mimi Zohar
2025-02-20 21:18 ` Mimi Zohar
2025-02-20 21:18 ` [LTP] " Mimi Zohar
2025-02-20 21:43 ` Petr Vorel
2025-02-20 21:43 ` [LTP] " Petr Vorel
2025-02-21 2:07 ` Mimi Zohar
2025-02-21 2:07 ` [LTP] " Mimi Zohar
2025-02-21 8:16 ` Petr Vorel
2025-02-21 8:16 ` [LTP] " Petr Vorel
2025-02-24 18:48 ` Mimi Zohar
2025-02-24 18:48 ` [LTP] " Mimi Zohar
2025-02-25 7:45 ` Petr Vorel
2025-02-25 7:45 ` [LTP] " Petr Vorel
2025-02-20 18:50 ` [RFC PATCH 1/3] Update validate() to support multiple violations Petr Vorel
2025-02-20 18:50 ` [LTP] " Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250220160054.12149-2-zohar@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=linux-integrity@vger.kernel.org \
--cc=ltp@lists.linux.it \
--cc=pvorel@suse.cz \
--cc=stefanb@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.