* [PATCH] ima: Replace two seq_printf() calls by seq_puts() in ima_show_template_data_ascii()
@ 2019-07-02 19:00 Markus Elfring
2019-07-02 19:00 ` Markus Elfring
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Markus Elfring @ 2019-07-02 19:00 UTC (permalink / raw)
To: linux-integrity, linux-security-module, Dmitry Kasatkin,
James Morris, Mimi Zohar, Serge E. Hallyn
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 2 Jul 2019 20:52:21 +0200
Two strings which did not contain a data format specification should be put
into a sequence. Thus use the corresponding function “seq_puts”.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
security/integrity/ima/ima_template_lib.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/integrity/ima/ima_template_lib.c b/security/integrity/ima/ima_template_lib.c
index 9fe0ef7f91e2..05636e9b19b1 100644
--- a/security/integrity/ima/ima_template_lib.c
+++ b/security/integrity/ima/ima_template_lib.c
@@ -74,7 +74,7 @@ static void ima_show_template_data_ascii(struct seq_file *m,
case DATA_FMT_DIGEST_WITH_ALGO:
buf_ptr = strnchr(field_data->data, buflen, ':');
if (buf_ptr != field_data->data)
- seq_printf(m, "%s", field_data->data);
+ seq_puts(m, field_data->data);
/* skip ':' and '\0' */
buf_ptr += 2;
@@ -87,7 +87,7 @@ static void ima_show_template_data_ascii(struct seq_file *m,
ima_print_digest(m, buf_ptr, buflen);
break;
case DATA_FMT_STRING:
- seq_printf(m, "%s", buf_ptr);
+ seq_puts(m, buf_ptr);
break;
default:
break;
--
2.22.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] ima: Replace two seq_printf() calls by seq_puts() in ima_show_template_data_ascii()
2019-07-02 19:00 [PATCH] ima: Replace two seq_printf() calls by seq_puts() in ima_show_template_data_ascii() Markus Elfring
2019-07-02 19:00 ` Markus Elfring
2019-07-02 19:00 ` Markus Elfring
@ 2019-07-02 19:00 ` Markus Elfring
2019-07-03 9:16 ` David Laight
3 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2019-07-02 19:00 UTC (permalink / raw)
To: linux-integrity, linux-security-module, Dmitry Kasatkin,
James Morris, Mimi Zohar, Serge E. Hallyn
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 2 Jul 2019 20:52:21 +0200
Two strings which did not contain a data format specification should be put
into a sequence. Thus use the corresponding function “seq_puts”.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
security/integrity/ima/ima_template_lib.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/integrity/ima/ima_template_lib.c b/security/integrity/ima/ima_template_lib.c
index 9fe0ef7f91e2..05636e9b19b1 100644
--- a/security/integrity/ima/ima_template_lib.c
+++ b/security/integrity/ima/ima_template_lib.c
@@ -74,7 +74,7 @@ static void ima_show_template_data_ascii(struct seq_file *m,
case DATA_FMT_DIGEST_WITH_ALGO:
buf_ptr = strnchr(field_data->data, buflen, ':');
if (buf_ptr != field_data->data)
- seq_printf(m, "%s", field_data->data);
+ seq_puts(m, field_data->data);
/* skip ':' and '\0' */
buf_ptr += 2;
@@ -87,7 +87,7 @@ static void ima_show_template_data_ascii(struct seq_file *m,
ima_print_digest(m, buf_ptr, buflen);
break;
case DATA_FMT_STRING:
- seq_printf(m, "%s", buf_ptr);
+ seq_puts(m, buf_ptr);
break;
default:
break;
--
2.22.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] ima: Replace two seq_printf() calls by seq_puts() in ima_show_template_data_ascii()
2019-07-02 19:00 [PATCH] ima: Replace two seq_printf() calls by seq_puts() in ima_show_template_data_ascii() Markus Elfring
@ 2019-07-02 19:00 ` Markus Elfring
2019-07-02 19:00 ` Markus Elfring
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2019-07-02 19:00 UTC (permalink / raw)
To: linux-integrity, linux-security-module, Dmitry Kasatkin,
James Morris, Mimi Zohar, Serge E. Hallyn
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 2 Jul 2019 20:52:21 +0200
Two strings which did not contain a data format specification should be put
into a sequence. Thus use the corresponding function “seq_puts”.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
security/integrity/ima/ima_template_lib.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/integrity/ima/ima_template_lib.c b/security/integrity/ima/ima_template_lib.c
index 9fe0ef7f91e2..05636e9b19b1 100644
--- a/security/integrity/ima/ima_template_lib.c
+++ b/security/integrity/ima/ima_template_lib.c
@@ -74,7 +74,7 @@ static void ima_show_template_data_ascii(struct seq_file *m,
case DATA_FMT_DIGEST_WITH_ALGO:
buf_ptr = strnchr(field_data->data, buflen, ':');
if (buf_ptr != field_data->data)
- seq_printf(m, "%s", field_data->data);
+ seq_puts(m, field_data->data);
/* skip ':' and '\0' */
buf_ptr += 2;
@@ -87,7 +87,7 @@ static void ima_show_template_data_ascii(struct seq_file *m,
ima_print_digest(m, buf_ptr, buflen);
break;
case DATA_FMT_STRING:
- seq_printf(m, "%s", buf_ptr);
+ seq_puts(m, buf_ptr);
break;
default:
break;
--
2.22.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] ima: Replace two seq_printf() calls by seq_puts() in ima_show_template_data_ascii()
2019-07-02 19:00 [PATCH] ima: Replace two seq_printf() calls by seq_puts() in ima_show_template_data_ascii() Markus Elfring
2019-07-02 19:00 ` Markus Elfring
@ 2019-07-02 19:00 ` Markus Elfring
2019-07-02 19:00 ` Markus Elfring
2019-07-03 9:16 ` David Laight
3 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2019-07-02 19:00 UTC (permalink / raw)
To: linux-integrity, linux-security-module, Dmitry Kasatkin,
James Morris, Mimi Zohar, Serge E. Hallyn
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 2 Jul 2019 20:52:21 +0200
Two strings which did not contain a data format specification should be put
into a sequence. Thus use the corresponding function “seq_puts”.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
security/integrity/ima/ima_template_lib.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/integrity/ima/ima_template_lib.c b/security/integrity/ima/ima_template_lib.c
index 9fe0ef7f91e2..05636e9b19b1 100644
--- a/security/integrity/ima/ima_template_lib.c
+++ b/security/integrity/ima/ima_template_lib.c
@@ -74,7 +74,7 @@ static void ima_show_template_data_ascii(struct seq_file *m,
case DATA_FMT_DIGEST_WITH_ALGO:
buf_ptr = strnchr(field_data->data, buflen, ':');
if (buf_ptr != field_data->data)
- seq_printf(m, "%s", field_data->data);
+ seq_puts(m, field_data->data);
/* skip ':' and '\0' */
buf_ptr += 2;
@@ -87,7 +87,7 @@ static void ima_show_template_data_ascii(struct seq_file *m,
ima_print_digest(m, buf_ptr, buflen);
break;
case DATA_FMT_STRING:
- seq_printf(m, "%s", buf_ptr);
+ seq_puts(m, buf_ptr);
break;
default:
break;
--
2.22.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* RE: [PATCH] ima: Replace two seq_printf() calls by seq_puts() in ima_show_template_data_ascii()
2019-07-02 19:00 [PATCH] ima: Replace two seq_printf() calls by seq_puts() in ima_show_template_data_ascii() Markus Elfring
` (2 preceding siblings ...)
2019-07-02 19:00 ` Markus Elfring
@ 2019-07-03 9:16 ` David Laight
2019-07-03 9:33 ` Markus Elfring
2019-07-03 11:14 ` [PATCH] " Mimi Zohar
3 siblings, 2 replies; 7+ messages in thread
From: David Laight @ 2019-07-03 9:16 UTC (permalink / raw)
To: 'Markus Elfring',
linux-integrity, linux-security-module, Dmitry Kasatkin,
James Morris, Mimi Zohar, Serge E. Hallyn
Cc: LKML, kernel-janitors
RnJvbTogIE1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sIEJyYW1sZXkgUm9hZCwgTW91bnQgRmFybSwgTWlsdG9uIEtleW5lcywgTUsx
IDFQVCwgVUsNClJlZ2lzdHJhdGlvbiBObzogMTM5NzM4NiAoV2FsZXMpDQo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: ima: Replace two seq_printf() calls by seq_puts() in ima_show_template_data_ascii()
2019-07-03 9:16 ` David Laight
@ 2019-07-03 9:33 ` Markus Elfring
2019-07-03 11:14 ` [PATCH] " Mimi Zohar
1 sibling, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2019-07-03 9:33 UTC (permalink / raw)
To: David Laight, linux-integrity, linux-security-module
Cc: Dmitry Kasatkin, James Morris, Mimi Zohar, Serge E. Hallyn, LKML,
kernel-janitors
> So this is probably just a minor performance improvement in a code
> path where it really doesn't matter.
I imagine that another small software adjustment can help a bit
to get nicer run time characteristics also at this place.
>> +++ b/security/integrity/ima/ima_template_lib.c
>> @@ -74,7 +74,7 @@ static void ima_show_template_data_ascii(struct seq_file *m,
>> case DATA_FMT_DIGEST_WITH_ALGO:
>> buf_ptr = strnchr(field_data->data, buflen, ':');
>> if (buf_ptr != field_data->data)
>> - seq_printf(m, "%s", field_data->data);
>> + seq_puts(m, field_data->data);
>>
>> /* skip ':' and '\0' */
>> buf_ptr += 2;
>
> That code looks highly suspect!
Would you like to change this implementation detail any more?
Regards,
Markus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ima: Replace two seq_printf() calls by seq_puts() in ima_show_template_data_ascii()
2019-07-03 9:16 ` David Laight
2019-07-03 9:33 ` Markus Elfring
@ 2019-07-03 11:14 ` Mimi Zohar
1 sibling, 0 replies; 7+ messages in thread
From: Mimi Zohar @ 2019-07-03 11:14 UTC (permalink / raw)
To: David Laight, 'Markus Elfring',
linux-integrity, linux-security-module, Dmitry Kasatkin,
James Morris, Serge E. Hallyn
Cc: LKML, kernel-janitors
On Wed, 2019-07-03 at 09:16 +0000, David Laight wrote:
> > diff --git a/security/integrity/ima/ima_template_lib.c b/security/integrity/ima/ima_template_lib.c
> > index 9fe0ef7f91e2..05636e9b19b1 100644
> > --- a/security/integrity/ima/ima_template_lib.c
> > +++ b/security/integrity/ima/ima_template_lib.c
> > @@ -74,7 +74,7 @@ static void ima_show_template_data_ascii(struct seq_file *m,
> > case DATA_FMT_DIGEST_WITH_ALGO:
> > buf_ptr = strnchr(field_data->data, buflen, ':');
> > if (buf_ptr != field_data->data)
> > - seq_printf(m, "%s", field_data->data);
> > + seq_puts(m, field_data->data);
> >
> > /* skip ':' and '\0' */
> > buf_ptr += 2;
>
> That code looks highly suspect!
> It uses a bounded scan then assumes a '\0' terminated string.
> It then adds 2 to a potentially NULL pointer.
The code here is used for displaying the IMA measurement list, that
the kernel itself created. Protecting the in kernel memory from
attack is a different problem. Refer to Igor Stoppa's write once
memory pools.
Mimi
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-07-03 11:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-02 19:00 [PATCH] ima: Replace two seq_printf() calls by seq_puts() in ima_show_template_data_ascii() Markus Elfring
2019-07-02 19:00 ` Markus Elfring
2019-07-02 19:00 ` Markus Elfring
2019-07-02 19:00 ` Markus Elfring
2019-07-03 9:16 ` David Laight
2019-07-03 9:33 ` Markus Elfring
2019-07-03 11:14 ` [PATCH] " Mimi Zohar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).