Skip to contentSkip to conversation

Documentation: added order requirement for ima_hash=

PATCH RESEND In review GUO Zihua 4 participants 18 messages Jan 25, 2022 – Jan 28, 2022

Subsystems (2)
lore
Share & tools
lore

GUO Zihua

author
#0 lore raw

PATCH RESEND 1/1 Documentation: added order requirement for ima_hash=

From: Guo Zihua <[email protected]>

Commandline parameter ima_hash= and ima_template= has order requirement for them to work correctly together. Namely ima_hash= must be specified after ima_template=, otherwise ima_template= will be ignored.

The reason is that when handling ima_hash=, ima template would be set to the default value if it has not been initialized already, and that value cannot be changed afterwards by ima_template=.

This patch adds this limitation to the documentation.

---
 Documentation/admin-guide/kernel-parameters.txt | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +7 -0
index f5a27f067db9..1b5aa6ca65f8 100644
@@ -1843,6 +1843,10 @@
 			The list of supported hash algorithms is defined
 			in crypto/hash_info.h.
 
+			This parameter must be specified after ima_template=,
+			as it would set the default template and that cannot be
+			changed by ima_template= afterwards.
+
 	ima_policy=	[IMA]
 			The builtin policies to load during IMA setup.
 			Format: "tcb | appraise_tcb | secure_boot |
@@ -1879,6 +1883,9 @@
 			Formats: { "ima" | "ima-ng" | "ima-sig" }
 			Default: "ima-ng"
 
+			This parameter must be specified before ima_hash=.
+			Please refer to ima_hash= for further explanation.
+
 	ima_template_fmt=
 			[IMA] Define a custom template format.
 			Format: { "field1|...|fieldN" }
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 6 lines · GUO Zihua

From: Guo Zihua <[email protected]>

Commandline parameter ima_hash= and ima_template= has order requirement for them to work correctly together. Namely ima_hash= must be specified after ima_template=, otherwise ima_template= will be ignored.

Quoted 8 lines

The reason is that when handling ima_hash=, ima template would be set to the default value if it has not been initialized already, and that value cannot be changed afterwards by ima_template=.

This patch adds this limitation to the documentation.

I've applied this, but I'm wondering: where did this review take place? I can't find it on the lists...

Thanks,

jon

#2 lore raw
Quoted 17 lines · Jonathan Corbet
Quoted 6 lines · GUO Zihua

From: Guo Zihua <[email protected]>

Commandline parameter ima_hash= and ima_template= has order requirement for them to work correctly together. Namely ima_hash= must be specified after ima_template=, otherwise ima_template= will be ignored.

Quoted 8 lines

The reason is that when handling ima_hash=, ima template would be set to the default value if it has not been initialized already, and that value cannot be changed afterwards by ima_template=.

This patch adds this limitation to the documentation.

Quoted 7 lines

I've applied this, but I'm wondering: where did this review take place? I can't find it on the lists...

Thanks,

jon
.

Hi Jonathan,

Thank you very much and sorry for the confusion here. The reviewed by is more like a face-to-face peer review and I would like to mention that in the patch. If this is problematic I would stop doing that from now on.

Signature · 2 lines
Best
GUO Zihua
maintainer
#3 lore raw
In reply to GUO Zihua
Quoted 6 lines · GUO Zihua

From: Guo Zihua <[email protected]>

Commandline parameter ima_hash= and ima_template= has order requirement for them to work correctly together. Namely ima_hash= must be specified after ima_template=, otherwise ima_template= will be ignored.

Quoted 8 lines

The reason is that when handling ima_hash=, ima template would be set to the default value if it has not been initialized already, and that value cannot be changed afterwards by ima_template=.

This patch adds this limitation to the documentation.

This issue should be limited to the original "ima" template format, which only supports hash algorithms of 20 bytes or less. The "ima_ng" template has been the default since larger digests and templates were upstreamed back in Linux 3.13[1]. Do you really still have kernels built with the original "ima" template?

[1] Refer to commit 4286587dccd4 ("ima: add Kconfig default measurement list template").

thanks,

Mimi

Quoted 29 lines
---
 Documentation/admin-guide/kernel-parameters.txt | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +7 -0
index f5a27f067db9..1b5aa6ca65f8 100644
@@ -1843,6 +1843,10 @@
 			The list of supported hash algorithms is defined
 			in crypto/hash_info.h.
 
+			This parameter must be specified after ima_template=,
+			as it would set the default template and that cannot be
+			changed by ima_template= afterwards.
+
 	ima_policy=	[IMA]
 			The builtin policies to load during IMA setup.
 			Format: "tcb | appraise_tcb | secure_boot |
@@ -1879,6 +1883,9 @@
 			Formats: { "ima" | "ima-ng" | "ima-sig" }
 			Default: "ima-ng"
 
+			This parameter must be specified before ima_hash=.
+			Please refer to ima_hash= for further explanation.
+
 	ima_template_fmt=
 			[IMA] Define a custom template format.
 			Format: { "field1|...|fieldN" }
#4 lore raw
Quoted 22 lines · Mimi Zohar
Quoted 6 lines · GUO Zihua

From: Guo Zihua <[email protected]>

Commandline parameter ima_hash= and ima_template= has order requirement for them to work correctly together. Namely ima_hash= must be specified after ima_template=, otherwise ima_template= will be ignored.

Quoted 8 lines

The reason is that when handling ima_hash=, ima template would be set to the default value if it has not been initialized already, and that value cannot be changed afterwards by ima_template=.

This patch adds this limitation to the documentation.

This issue should be limited to the original "ima" template format, which only supports hash algorithms of 20 bytes or less. The "ima_ng" template has been the default since larger digests and templates were upstreamed back in Linux 3.13[1]. Do you really still have kernels built with the original "ima" template?

Quoted 6 lines

[1] Refer to commit 4286587dccd4 ("ima: add Kconfig default measurement list template").

thanks,

Mimi

Hi Mimi,

The issue is that if ima_hash is specified before ima_template, ima_template will not work. Built-in default only affects which template will be loaded eventually.

For example, if the built-in default template is ima-ng and user would like to change it to ima-sig with sha512 by specifying "ima_hash=sha512 ima_template=ima-sig" in command line, the result will be ima-ng with sha512, not ima-sig with sha512.

Signature · 2 lines
Best
GUO Zihua
Quoted 33 lines
Quoted 21 lines
---
  Documentation/admin-guide/kernel-parameters.txt | 7 +++++++
  1 file changed, 7 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +4 -0
index f5a27f067db9..1b5aa6ca65f8 100644
@@ -1843,6 +1843,10 @@
  			The list of supported hash algorithms is defined
  			in crypto/hash_info.h.
 
+			This parameter must be specified after ima_template=,
+			as it would set the default template and that cannot be
+			changed by ima_template= afterwards.
+
  	ima_policy=	[IMA]
  			The builtin policies to load during IMA setup.
  			Format: "tcb | appraise_tcb | secure_boot |

Documentation/admin-guide/kernel-parameters.txt line 1891

Quoted 9 lines
Documentation/admin-guide/kernel-parameters.txt +3 -0
@@ -1879,6 +1883,9 @@
  			Formats: { "ima" | "ima-ng" | "ima-sig" }
  			Default: "ima-ng"
 
+			This parameter must be specified before ima_hash=.
+			Please refer to ima_hash= for further explanation.
+
  	ima_template_fmt=
  			[IMA] Define a custom template format.
  			Format: { "field1|...|fieldN" }

.

maintainer
#5 lore raw
Quoted 29 lines · Guozihua (Scott)
Quoted 16 lines · Mimi Zohar
Quoted 6 lines · GUO Zihua

From: Guo Zihua <[email protected]>

Commandline parameter ima_hash= and ima_template= has order requirement for them to work correctly together. Namely ima_hash= must be specified after ima_template=, otherwise ima_template= will be ignored.

Quoted 8 lines

The reason is that when handling ima_hash=, ima template would be set to the default value if it has not been initialized already, and that value cannot be changed afterwards by ima_template=.

This patch adds this limitation to the documentation.

Quoted 8 lines

This issue should be limited to the original "ima" template format, which only supports hash algorithms of 20 bytes or less. The "ima_ng" template has been the default since larger digests and templates were upstreamed back in Linux 3.13[1]. Do you really still have kernels built with the original "ima" template?

[1] Refer to commit 4286587dccd4 ("ima: add Kconfig default measurement list template").

Hi Mimi,

Quoted 8 lines

The issue is that if ima_hash is specified before ima_template, ima_template will not work. Built-in default only affects which template will be loaded eventually.

For example, if the built-in default template is ima-ng and user would like to change it to ima-sig with sha512 by specifying "ima_hash=sha512 ima_template=ima-sig" in command line, the result will be ima-ng with sha512, not ima-sig with sha512.

Ok. Once the template name is set, ima_template_setup() doesn't allow it to be reset. This was probably done to set the template name to the first occurance of "ima_template=" on the boot command line. This concern could be addressed by defining a static local variable in ima_template_setup().

So either documenting the ordering requirement, as you've done, or allowing the template_name to be reset are fine.

thanks,

Mimi

#6 lore raw
Quoted 45 lines · Mimi Zohar
Quoted 29 lines · Guozihua (Scott)
Quoted 16 lines · Mimi Zohar
Quoted 6 lines · GUO Zihua

From: Guo Zihua <[email protected]>

Commandline parameter ima_hash= and ima_template= has order requirement for them to work correctly together. Namely ima_hash= must be specified after ima_template=, otherwise ima_template= will be ignored.

Quoted 8 lines

The reason is that when handling ima_hash=, ima template would be set to the default value if it has not been initialized already, and that value cannot be changed afterwards by ima_template=.

This patch adds this limitation to the documentation.

Quoted 8 lines

This issue should be limited to the original "ima" template format, which only supports hash algorithms of 20 bytes or less. The "ima_ng" template has been the default since larger digests and templates were upstreamed back in Linux 3.13[1]. Do you really still have kernels built with the original "ima" template?

[1] Refer to commit 4286587dccd4 ("ima: add Kconfig default measurement list template").

Hi Mimi,

Quoted 8 lines

The issue is that if ima_hash is specified before ima_template, ima_template will not work. Built-in default only affects which template will be loaded eventually.

For example, if the built-in default template is ima-ng and user would like to change it to ima-sig with sha512 by specifying "ima_hash=sha512 ima_template=ima-sig" in command line, the result will be ima-ng with sha512, not ima-sig with sha512.

Ok. Once the template name is set, ima_template_setup() doesn't allow it to be reset. This was probably done to set the template name to the first occurance of "ima_template=" on the boot command line. This concern could be addressed by defining a static local variable in ima_template_setup().

Quoted 8 lines

So either documenting the ordering requirement, as you've done, or allowing the template_name to be reset are fine.

thanks,

Mimi

.

The main issue lies in ima_template_desc_current called by hash_setup, which does not just read ima_template global variable, but also tries to set it if that hasn't been done already. Causing ima_template_setup to quit.

Signature · 2 lines
Best
GUO Zihua
maintainer
#7 lore raw
Quoted 5 lines · Guozihua (Scott)

The main issue lies in ima_template_desc_current called by hash_setup, which does not just read ima_template global variable, but also tries to set it if that hasn't been done already. Causing ima_template_setup to quit.

Right, which calls ima_init_template_list(). So part of the solution could be to conditionally call ima_init_template_list()
in ima_template_setup().

- if (ima_template)
- return 1;
-
- ima_init_template_list();
+ if (!ima_template
+ ima_init_template_list();

Roberto, what do you think?

thanks,

Mimi

#8 lore raw
Quoted 20 lines

From: Mimi Zohar [mailto:[email protected]]
Sent: Wednesday, January 26, 2022 1:48 PM

Quoted 5 lines · Guozihua (Scott)

The main issue lies in ima_template_desc_current called by hash_setup, which does not just read ima_template global variable, but also tries to set it if that hasn't been done already. Causing ima_template_setup to quit.

Right, which calls ima_init_template_list(). So part of the solution could be to conditionally call ima_init_template_list()
in ima_template_setup().

(quoted diff) +2 -4
-       if (ima_template)
-               return 1;
-
-       ima_init_template_list();
+       if (!ima_template
+               ima_init_template_list();
Quoted 1 line

Roberto, what do you think?

Hi Mimi

I think we wanted to prevent to set a digest algorithm incompatible with the chosen template.

If we have in the kernel command line:

ima_template=ima ima_hash=sha256

ima_hash_algo would be set to HASH_ALGO_SHA1 despite the user choice and the template would be set to 'ima'.

In the opposite case:

ima_hash=sha256 ima_template=ima

if the default template is 'ima', then ima_hash_algo would be set to HASH_ALGO_SHA1. Otherwise, it would be HASH_ALGO_SHA256. If we allow the template to be set after the digest algorithm is evaluated, the template selection will be rejected if the algorithm is incompatible with the template.

I'm trying to remember why we still have the digest recalculation in ima_eventdigest_init(). Maybe the only possibility is if we set the template from the policy?

Thanks

Roberto

HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Li Peng, Zhong Ronghua

Quoted 3 lines

thanks,

Mimi

maintainer
#9 lore raw
Quoted 36 lines · Roberto Sassu
Quoted 20 lines

From: Mimi Zohar [mailto:[email protected]]
Sent: Wednesday, January 26, 2022 1:48 PM

Quoted 5 lines · Guozihua (Scott)

The main issue lies in ima_template_desc_current called by hash_setup, which does not just read ima_template global variable, but also tries to set it if that hasn't been done already. Causing ima_template_setup to quit.

Right, which calls ima_init_template_list(). So part of the solution could be to conditionally call ima_init_template_list()
in ima_template_setup().

(quoted diff) +2 -4
-       if (ima_template)
-               return 1;
-
-       ima_init_template_list();
+       if (!ima_template
+               ima_init_template_list();
Quoted 1 line

Roberto, what do you think?

Hi Mimi

I think we wanted to prevent to set a digest algorithm incompatible with the chosen template.

If we have in the kernel command line:

ima_template=ima ima_hash=sha256

ima_hash_algo would be set to HASH_ALGO_SHA1 despite the user choice and the template would be set to 'ima'.

In the opposite case:

Quoted 7 lines

ima_hash=sha256 ima_template=ima

if the default template is 'ima', then ima_hash_algo would be set to HASH_ALGO_SHA1. Otherwise, it would be HASH_ALGO_SHA256. If we allow the template to be set after the digest algorithm is evaluated, the template selection will be rejected if the algorithm is incompatible with the template.

The only time that would occur is in the unlikely case that the
template is being set to "ima". That sounds reasonable. In fact we
should consider preventing the template format being set to "ima".

Quoted 4 lines

I'm trying to remember why we still have the digest recalculation in ima_eventdigest_init(). Maybe the only possibility is if we set the template from the policy?

The recalculation was relatively recently added in commit 6cc7c266e5b4 ("ima: Call ima_calc_boot_aggregate() in ima_eventdigest_init()").

thanks,

Mimi

#10 lore raw
Quoted 47 lines

From: Mimi Zohar [mailto:[email protected]]
Sent: Wednesday, January 26, 2022 3:35 PM

Quoted 36 lines · Roberto Sassu
Quoted 20 lines

From: Mimi Zohar [mailto:[email protected]]
Sent: Wednesday, January 26, 2022 1:48 PM

Quoted 5 lines · Guozihua (Scott)

The main issue lies in ima_template_desc_current called by hash_setup, which does not just read ima_template global variable, but also tries to set it if that hasn't been done already. Causing ima_template_setup to quit.

Right, which calls ima_init_template_list(). So part of the solution could be to conditionally call ima_init_template_list()
in ima_template_setup().

(quoted diff) +2 -4
-       if (ima_template)
-               return 1;
-
-       ima_init_template_list();
+       if (!ima_template
+               ima_init_template_list();
Quoted 1 line

Roberto, what do you think?

Hi Mimi

I think we wanted to prevent to set a digest algorithm incompatible with the chosen template.

If we have in the kernel command line:

ima_template=ima ima_hash=sha256

ima_hash_algo would be set to HASH_ALGO_SHA1 despite the user choice and the template would be set to 'ima'.

In the opposite case:

Quoted 7 lines

ima_hash=sha256 ima_template=ima

if the default template is 'ima', then ima_hash_algo would be set to HASH_ALGO_SHA1. Otherwise, it would be HASH_ALGO_SHA256. If we allow the template to be set after the digest algorithm is evaluated, the template selection will be rejected if the algorithm is incompatible with the template.

Quoted 3 lines

The only time that would occur is in the unlikely case that the
template is being set to "ima". That sounds reasonable. In fact we
should consider preventing the template format being set to "ima".

Ok.

Quoted 6 lines
Quoted 3 lines

I'm trying to remember why we still have the digest recalculation in ima_eventdigest_init(). Maybe the only possibility is if we set the template from the policy?

The recalculation was relatively recently added in commit 6cc7c266e5b4 ("ima: Call ima_calc_boot_aggregate() in ima_eventdigest_init()").

There is also recalculation for the file digest:

        hash.hdr.algo = ima_template_hash_algo_allowed(ima_hash_algo) ?
            ima_hash_algo : HASH_ALGO_SHA1;
        result = ima_calc_file_hash(event_data->file, &hash.hdr);

I understood that Jonathan already applied the patch. If it is possible to make a new patch according to your suggestion, I would ask Zihua to do that.

Jonathan, would it be fine for you to discard this patch?

Thanks

Roberto

HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Li Peng, Zhong Ronghua

Quoted 3 lines

thanks,

Mimi

maintainer
#11 lore raw
Quoted 5 lines · Roberto Sassu

I understood that Jonathan already applied the patch. If it is possible to make a new patch according to your suggestion, I would ask Zihua to do that.

Jonathan, would it be fine for you to discard this patch?

OK, I will drop it.

jon

#12 lore raw
In reply to Roberto Sassu
Quoted 62 lines · Roberto Sassu
Quoted 47 lines

From: Mimi Zohar [mailto:[email protected]]
Sent: Wednesday, January 26, 2022 3:35 PM

Quoted 36 lines · Roberto Sassu
Quoted 20 lines

From: Mimi Zohar [mailto:[email protected]]
Sent: Wednesday, January 26, 2022 1:48 PM

Quoted 5 lines · Guozihua (Scott)

The main issue lies in ima_template_desc_current called by hash_setup, which does not just read ima_template global variable, but also tries to set it if that hasn't been done already. Causing ima_template_setup to quit.

Right, which calls ima_init_template_list(). So part of the solution could be to conditionally call ima_init_template_list()
in ima_template_setup().

(quoted diff) +2 -4
-       if (ima_template)
-               return 1;
-
-       ima_init_template_list();
+       if (!ima_template
+               ima_init_template_list();
Quoted 1 line

Roberto, what do you think?

Hi Mimi

I think we wanted to prevent to set a digest algorithm incompatible with the chosen template.

If we have in the kernel command line:

ima_template=ima ima_hash=sha256

ima_hash_algo would be set to HASH_ALGO_SHA1 despite the user choice and the template would be set to 'ima'.

In the opposite case:

Quoted 7 lines

ima_hash=sha256 ima_template=ima

if the default template is 'ima', then ima_hash_algo would be set to HASH_ALGO_SHA1. Otherwise, it would be HASH_ALGO_SHA256. If we allow the template to be set after the digest algorithm is evaluated, the template selection will be rejected if the algorithm is incompatible with the template.

Quoted 3 lines

The only time that would occur is in the unlikely case that the
template is being set to "ima". That sounds reasonable. In fact we
should consider preventing the template format being set to "ima".

Ok.

Quoted 6 lines
Quoted 3 lines

I'm trying to remember why we still have the digest recalculation in ima_eventdigest_init(). Maybe the only possibility is if we set the template from the policy?

The recalculation was relatively recently added in commit 6cc7c266e5b4 ("ima: Call ima_calc_boot_aggregate() in ima_eventdigest_init()").

There is also recalculation for the file digest:

Quoted 7 lines
         hash.hdr.algo = ima_template_hash_algo_allowed(ima_hash_algo) ?
             ima_hash_algo : HASH_ALGO_SHA1;
         result = ima_calc_file_hash(event_data->file, &hash.hdr);

I understood that Jonathan already applied the patch. If it is possible to make a new patch according to your suggestion, I would ask Zihua to do that.

Hi Mimi and Roberto,

I understand that the solution proposed here is to decommission template "ima" and potentially removing related algo checks altogether?

Signature · 2 lines
Best
GUO Zihua
maintainer
#13 lore raw
Quoted 54 lines · Guozihua (Scott)
Quoted 52 lines · Roberto Sassu
Quoted 47 lines

From: Mimi Zohar [mailto:[email protected]]
Sent: Wednesday, January 26, 2022 3:35 PM

Quoted 36 lines · Roberto Sassu
Quoted 20 lines

From: Mimi Zohar [mailto:[email protected]]
Sent: Wednesday, January 26, 2022 1:48 PM

Quoted 5 lines · Guozihua (Scott)

The main issue lies in ima_template_desc_current called by hash_setup, which does not just read ima_template global variable, but also tries to set it if that hasn't been done already. Causing ima_template_setup to quit.

Right, which calls ima_init_template_list(). So part of the solution could be to conditionally call ima_init_template_list()
in ima_template_setup().

(quoted diff) +2 -4
-       if (ima_template)
-               return 1;
-
-       ima_init_template_list();
+       if (!ima_template
+               ima_init_template_list();
Quoted 1 line

Roberto, what do you think?

Hi Mimi

I think we wanted to prevent to set a digest algorithm incompatible with the chosen template.

If we have in the kernel command line:

ima_template=ima ima_hash=sha256

ima_hash_algo would be set to HASH_ALGO_SHA1 despite the user choice and the template would be set to 'ima'.

In the opposite case:

Quoted 7 lines

ima_hash=sha256 ima_template=ima

if the default template is 'ima', then ima_hash_algo would be set to HASH_ALGO_SHA1. Otherwise, it would be HASH_ALGO_SHA256. If we allow the template to be set after the digest algorithm is evaluated, the template selection will be rejected if the algorithm is incompatible with the template.

Quoted 3 lines

The only time that would occur is in the unlikely case that the
template is being set to "ima". That sounds reasonable. In fact we
should consider preventing the template format being set to "ima".

Ok.

< snip >

Quoted 3 lines

I understand that the solution proposed here is to decommission template "ima" and potentially removing related algo checks altogether?

Eventually we might decide to do that, but right now we just want to address not being able to set "ima_template" after setting "ima_hash".

thanks,

Mimi

#14 lore raw
Quoted 9 lines · Mimi Zohar
Quoted 3 lines · Guozihua (Scott)

I understand that the solution proposed here is to decommission template "ima" and potentially removing related algo checks altogether?

Eventually we might decide to do that, but right now we just want to address not being able to set "ima_template" after setting "ima_hash".

Quoted 6 lines

thanks,

Mimi

.

Sure! I would come up with a solution.

Signature · 2 lines
Best
GUO Zihua
#15 lore raw
In reply to Mimi Zohar
Quoted 13 lines

From: Mimi Zohar [mailto:[email protected]]
Sent: Wednesday, January 26, 2022 1:48 PM

Quoted 5 lines · Guozihua (Scott)

The main issue lies in ima_template_desc_current called by hash_setup, which does not just read ima_template global variable, but also tries to set it if that hasn't been done already. Causing ima_template_setup to quit.

Right, which calls ima_init_template_list(). So part of the solution could be to conditionally call ima_init_template_list()
in ima_template_setup().

Review

Quoted 6 lines
(quoted diff) +2 -4
-       if (ima_template)
-               return 1;
-
-       ima_init_template_list();
+       if (!ima_template
+               ima_init_template_list();

Hi Mimi

is it still necessary to call ima_init_template_list() in template_setup()? I saw it is called in init_ima().

Thanks

Roberto

HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Li Peng, Zhong Ronghua

Quoted 5 lines

Roberto, what do you think?

thanks,

Mimi

maintainer
#16 lore raw
Quoted 21 lines · Roberto Sassu
Quoted 13 lines

From: Mimi Zohar [mailto:[email protected]]
Sent: Wednesday, January 26, 2022 1:48 PM

Quoted 5 lines · Guozihua (Scott)

The main issue lies in ima_template_desc_current called by hash_setup, which does not just read ima_template global variable, but also tries to set it if that hasn't been done already. Causing ima_template_setup to quit.

Right, which calls ima_init_template_list(). So part of the solution could be to conditionally call ima_init_template_list()
in ima_template_setup().

Review

Quoted 6 lines
(quoted diff) +2 -4
-       if (ima_template)
-               return 1;
-
-       ima_init_template_list();
+       if (!ima_template
+               ima_init_template_list();
Quoted 2 lines

is it still necessary to call ima_init_template_list() in template_setup()? I saw it is called in init_ima().

All of these options are at __setup().

thanks,

Mimi

#17 lore raw
Quoted 24 lines

From: Mimi Zohar [mailto:[email protected]]
Sent: Friday, January 28, 2022 3:34 PM

Quoted 21 lines · Roberto Sassu
Quoted 19 lines

From: Mimi Zohar [mailto:[email protected]]
Sent: Wednesday, January 26, 2022 1:48 PM

Quoted 5 lines · Guozihua (Scott)

The main issue lies in ima_template_desc_current called by hash_setup, which does not just read ima_template global variable, but also tries to set it if that hasn't been done already. Causing ima_template_setup to quit.

Right, which calls ima_init_template_list(). So part of the solution could be to conditionally call ima_init_template_list()
in ima_template_setup().

(quoted diff) +2 -4
-       if (ima_template)
-               return 1;
-
-       ima_init_template_list();
+       if (!ima_template
+               ima_init_template_list();
Quoted 4 lines
Quoted 2 lines

is it still necessary to call ima_init_template_list() in template_setup()? I saw it is called in init_ima().

All of these options are at __setup().

Yes. ima_init_template_list() should be called before lookup_template_desc().

Thanks

Roberto

HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Li Peng, Zhong Ronghua

Quoted 3 lines

thanks,

Mimi