Skip to contentSkip to conversation

lib: tst_taint: Ignore WARN taint flag if already set

PATCH New Cyril Hrubis 4 participants 8 messages Oct 16, 2019 – Apr 13, 2020 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: tst_taint: Ignore WARN taint flag if already set

This commit changes the library so that it ignores the taint warn flag if it was set prior to the test run. It turns out that the warn taint flag is not well defined and could be easily set on a freshly booted kernel for example when buggy BIOS is detected.

CC Jan Stancek <[email protected]>
CC Chang Yin <[email protected]>

---

I haven't tested this, since I don't have a system where the flag is set at hand, but it's simple enough so that it should work as expected.

 lib/tst_taint.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/tst_taint.c +6 -1
index a5dbf77d2..3de6d72f4 100644
@@ -82,8 +82,13 @@ void tst_taint_init(unsigned int mask)
 		tst_res(TCONF, "Kernel is too old for requested mask");
 
 	taint_mask = mask;
-
 	taint = tst_taint_read();
+
+	if (mask & TST_TAINT_W && taint & TST_TAINT_W) {
+		tst_res(TCONF, "Ignoring already set kernel warning taint");
+		mask &= ~TST_TAINT_W;
+	}
+
 	if ((taint & mask) != 0)
 		tst_brk(TBROK, "Kernel is already tainted: %u", taint);
 }
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/1 lib: tst_taint: Ignore WARN taint flag if already set

----- Original Message -----

Quoted 21 lines

This commit changes the library so that it ignores the taint warn flag if it was set prior to the test run. It turns out that the warn taint flag is not well defined and could be easily set on a freshly booted kernel for example when buggy BIOS is detected.

CC Jan Stancek <[email protected]>
CC Chang Yin <[email protected]>

---

I haven't tested this, since I don't have a system where the flag is set at hand, but it's simple enough so that it should work as expected.

 lib/tst_taint.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/tst_taint.c +0 -0
index a5dbf77d2..3de6d72f4 100644

lib/tst_taint.c void tst_taint_init(unsigned int mask) · line 89

Quoted 9 lines
lib/tst_taint.c +4 -1
@@ -82,8 +82,13 @@ void tst_taint_init(unsigned int mask)
 		tst_res(TCONF, "Kernel is too old for requested mask");
 
 	taint_mask = mask;
-
 	taint = tst_taint_read();
+
+	if (mask & TST_TAINT_W && taint & TST_TAINT_W) {
+		tst_res(TCONF, "Ignoring already set kernel warning taint");
+		mask &= ~TST_TAINT_W;

Shouldn't this rather mask it from taint_mask? Otherwise, won't you still get an error in tst_taint_check()?

Quoted 9 lines
lib/tst_taint.c +2 -1
+	}
+
 	if ((taint & mask) != 0)
 		tst_brk(TBROK, "Kernel is already tainted: %u", taint);
 }
--

2.21.0

#2 lore raw

PATCH 1/1 lib: tst_taint: Ignore WARN taint flag if already set

Hi!

Quoted 7 lines

lib/tst_taint.c void tst_taint_init(unsigned int mask) · line 89

Quoted 4 lines
lib/tst_taint.c +4 -0
+
+	if (mask & TST_TAINT_W && taint & TST_TAINT_W) {
+		tst_res(TCONF, "Ignoring already set kernel warning taint");
+		mask &= ~TST_TAINT_W;

Shouldn't this rather mask it from taint_mask? Otherwise, won't you still get an error in tst_taint_check()?

Of course.

Quoted 3 lines

lib/tst_taint.c void tst_taint_init(unsigned int mask) · line 92

Quoted 3 lines
lib/tst_taint.c +2 -0
+	}
+
 	if ((taint & mask) != 0)

And this has to be changed so that we check the taint againts the taint_mask .

Quoted 6 lines
Quoted 6 lines

tst_brk(TBROK, "Kernel is already tainted: %u", taint);
}
--
2.21.0

Signature · 2 lines
Cyril Hrubis
[email protected]
#3 lore raw

PATCH 1/1 lib: tst_taint: Ignore WARN taint flag if already set

Hi Cyril,

Per the discussion in history, I'm asking do you plan to draft patch v2 for it?
Or, do we have new thoughts on this?

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200413/ff112266/attachment.htm>
#4 lore raw

PATCH 1/1 lib: tst_taint: Ignore WARN taint flag if already set

In reply to Cyril Hrubis

Hi,

Quoted 25 lines · Cyril Hrubis

This commit changes the library so that it ignores the taint warn flag if it was set prior to the test run. It turns out that the warn taint flag is not well defined and could be easily set on a freshly booted kernel for example when buggy BIOS is detected.>

CC Jan Stancek <[email protected]>
CC Chang Yin <[email protected]>

---

I haven't tested this, since I don't have a system where the flag is set at hand, but it's simple enough so that it should work as expected.

 lib/tst_taint.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/tst_taint.c +0 -1
index a5dbf77d2..3de6d72f4 100644
@@ -82,8 +82,13 @@ void tst_taint_init(unsigned int mask)
 		tst_res(TCONF, "Kernel is too old for requested mask");
 
 	taint_mask = mask;
-

lib/tst_taint.c void tst_taint_init(unsigned int mask) · line 94

Quoted 10 lines
lib/tst_taint.c +6 -0
 	taint = tst_taint_read();
+
+	if (mask & TST_TAINT_W && taint & TST_TAINT_W) {
+		tst_res(TCONF, "Ignoring already set kernel warning taint");
+		mask &= ~TST_TAINT_W;
+	}
+
 	if ((taint & mask) != 0)
 		tst_brk(TBROK, "Kernel is already tainted: %u", taint);
 }

Tests may rely on TAINT_W to decide the result. If we need TAINT_W, we can only run the test when it was not set before. For example, testcases/cve/cve-2017-17053.c relies on this.
This may render this testcase unusable, or do I get this wrong?

Signature · 11 lines
Michael Moese <[email protected]>
QA Engineer
PGP Fingerprint: 4CCE 3896 F873 2CA5 2382  3C6F 6021 375C 8635 7E74

SUSE Software Solutions Germany GmbH
Maxfeldstr. 5
90409 N?rnberg
Germany

(HRB 36809, AG N?rnberg)
Gesch?ftsf?hrer: Felix Imend?rffer
#5 lore raw

PATCH 1/1 lib: tst_taint: Ignore WARN taint flag if already set

----- Original Message -----

Quoted 35 lines

Hi,

Quoted 32 lines · Cyril Hrubis

This commit changes the library so that it ignores the taint warn flag if it was set prior to the test run. It turns out that the warn taint flag is not well defined and could be easily set on a freshly booted kernel for example when buggy BIOS is detected.>

CC Jan Stancek <[email protected]>
CC Chang Yin <[email protected]>

---

I haven't tested this, since I don't have a system where the flag is set at hand, but it's simple enough so that it should work as expected.

 lib/tst_taint.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/tst_taint.c +6 -1
index a5dbf77d2..3de6d72f4 100644
@@ -82,8 +82,13 @@ void tst_taint_init(unsigned int mask)
 		tst_res(TCONF, "Kernel is too old for requested mask");
 
 	taint_mask = mask;
-
 	taint = tst_taint_read();
+
+	if (mask & TST_TAINT_W && taint & TST_TAINT_W) {
+		tst_res(TCONF, "Ignoring already set kernel warning taint");
+		mask &= ~TST_TAINT_W;
+	}
+
 	if ((taint & mask) != 0)
Quoted 8 lines

lib/tst_taint.c void tst_taint_init(unsigned int mask) · line 94

Quoted 3 lines
lib/tst_taint.c +0 -0
 		tst_brk(TBROK, "Kernel is already tainted: %u", taint);
 }

Tests may rely on TAINT_W to decide the result.
If we need TAINT_W, we can only run the test when it was not set before. For example, testcases/cve/cve-2017-17053.c relies on this.
This may render this testcase unusable, or do I get this wrong?

Patch masks TAINT_W if that taint flag was set before test started. In such case, test can't determine result accurately anyway.

I wonder if there is more specific way for cve-2017-17053 to determine error condition. For example by inspecting new messages in dmesg.

#6 lore raw

PATCH 1/1 lib: tst_taint: Ignore WARN taint flag if already set

Hi!

Quoted 2 lines

I wonder if there is more specific way for cve-2017-17053 to determine error condition. For example by inspecting new messages in dmesg.

We wanted to avoid that because the taint flags looked like a nice and simple solution...

Signature · 2 lines
Cyril Hrubis
[email protected]
#7 lore raw

PATCH 1/1 lib: tst_taint: Ignore WARN taint flag if already set

In reply to Michael Moese

Hi!

Quoted 17 lines
Quoted 17 lines
lib/tst_taint.c +6 -1
index a5dbf77d2..3de6d72f4 100644
@@ -82,8 +82,13 @@ void tst_taint_init(unsigned int mask)
 		tst_res(TCONF, "Kernel is too old for requested mask");
 
 	taint_mask = mask;
-
 	taint = tst_taint_read();
+
+	if (mask & TST_TAINT_W && taint & TST_TAINT_W) {
+		tst_res(TCONF, "Ignoring already set kernel warning taint");
+		mask &= ~TST_TAINT_W;
+	}
+
 	if ((taint & mask) != 0)
Quoted 8 lines

lib/tst_taint.c void tst_taint_init(unsigned int mask) · line 94

Quoted 3 lines
lib/tst_taint.c +0 -0
 		tst_brk(TBROK, "Kernel is already tainted: %u", taint);
 }

Tests may rely on TAINT_W to decide the result. If we need TAINT_W, we can only run the test when it was not set before. For example, testcases/cve/cve-2017-17053.c relies on this.
This may render this testcase unusable, or do I get this wrong?

Only on systems where something set the flag already. Ideally that will not happen on many systems.

Signature · 2 lines
Cyril Hrubis
[email protected]