public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/tunables] elf: Do not process invalid tunable format
@ 2023-10-06 14:28 Adhemerval Zanella
0 siblings, 0 replies; 3+ messages in thread
From: Adhemerval Zanella @ 2023-10-06 14:28 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8cd6203288cfadc4408bd1aff985e48c9d71f563
commit 8cd6203288cfadc4408bd1aff985e48c9d71f563
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed Oct 4 09:29:49 2023 -0300
elf: Do not process invalid tunable format
Tunables string with with more than one '=' on its definition are
parsed and enabled, and any subsequent '=' are ignored. It means
that tunables in the form 'tunable=tunable=value' or
'tunable=value=value' are handled 'tunable=value'. This inputs are
most likely user input error, which should not be accepted.
Checked on x86_64-linux-gnu.
Diff:
---
elf/dl-tunables.c | 6 ++++--
elf/tst-tunables.c | 22 +++++++++++++++++-----
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
index a83bd2b8bc..59bee61124 100644
--- a/elf/dl-tunables.c
+++ b/elf/dl-tunables.c
@@ -192,10 +192,12 @@ parse_tunables (char *valstring)
const char *value = p;
- while (*p != ':' && *p != '\0')
+ while (*p != '=' && *p != ':' && *p != '\0')
p++;
- if (*p == '\0')
+ if (*p == '=')
+ break;
+ else if (*p == '\0')
done = true;
else
*p++ = '\0';
diff --git a/elf/tst-tunables.c b/elf/tst-tunables.c
index 0a9381ba1f..8e9df38564 100644
--- a/elf/tst-tunables.c
+++ b/elf/tst-tunables.c
@@ -159,24 +159,36 @@ static const struct test_t
0,
0,
},
- /* The ill-formatted tunable is also skipped. */
+ /* If there is a ill-formatted key=value, everything after is also ignored. */
{
"glibc.malloc.mmap_threshold=glibc.malloc.mmap_threshold=4096:glibc.malloc.check=2",
- 2,
+ 0,
0,
0,
},
- /* For an integer tunable, parse will stop on non number character. */
{
"glibc.malloc.check=2=2",
- 2,
+ 0,
0,
0,
},
{
"glibc.malloc.check=2=2:glibc.malloc.mmap_threshold=4096",
+ 0,
+ 0,
+ 0,
+ },
+ {
+ "glibc.malloc.check=2=2:glibc.malloc.check=2",
+ 0,
+ 0,
+ 0,
+ },
+ /* Valid tunables set before ill-formatted ones are set. */
+ {
+ "glibc.malloc.check=2:glibc.malloc.mmap_threshold=4096=4096",
2,
- 4096,
+ 0,
0,
}
};
^ permalink raw reply [flat|nested] 3+ messages in thread
* [glibc/azanella/tunables] elf: Do not process invalid tunable format
@ 2023-10-05 13:13 Adhemerval Zanella
0 siblings, 0 replies; 3+ messages in thread
From: Adhemerval Zanella @ 2023-10-05 13:13 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8cd6203288cfadc4408bd1aff985e48c9d71f563
commit 8cd6203288cfadc4408bd1aff985e48c9d71f563
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed Oct 4 09:29:49 2023 -0300
elf: Do not process invalid tunable format
Tunables string with with more than one '=' on its definition are
parsed and enabled, and any subsequent '=' are ignored. It means
that tunables in the form 'tunable=tunable=value' or
'tunable=value=value' are handled 'tunable=value'. This inputs are
most likely user input error, which should not be accepted.
Checked on x86_64-linux-gnu.
Diff:
---
elf/dl-tunables.c | 6 ++++--
elf/tst-tunables.c | 22 +++++++++++++++++-----
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
index a83bd2b8bc..59bee61124 100644
--- a/elf/dl-tunables.c
+++ b/elf/dl-tunables.c
@@ -192,10 +192,12 @@ parse_tunables (char *valstring)
const char *value = p;
- while (*p != ':' && *p != '\0')
+ while (*p != '=' && *p != ':' && *p != '\0')
p++;
- if (*p == '\0')
+ if (*p == '=')
+ break;
+ else if (*p == '\0')
done = true;
else
*p++ = '\0';
diff --git a/elf/tst-tunables.c b/elf/tst-tunables.c
index 0a9381ba1f..8e9df38564 100644
--- a/elf/tst-tunables.c
+++ b/elf/tst-tunables.c
@@ -159,24 +159,36 @@ static const struct test_t
0,
0,
},
- /* The ill-formatted tunable is also skipped. */
+ /* If there is a ill-formatted key=value, everything after is also ignored. */
{
"glibc.malloc.mmap_threshold=glibc.malloc.mmap_threshold=4096:glibc.malloc.check=2",
- 2,
+ 0,
0,
0,
},
- /* For an integer tunable, parse will stop on non number character. */
{
"glibc.malloc.check=2=2",
- 2,
+ 0,
0,
0,
},
{
"glibc.malloc.check=2=2:glibc.malloc.mmap_threshold=4096",
+ 0,
+ 0,
+ 0,
+ },
+ {
+ "glibc.malloc.check=2=2:glibc.malloc.check=2",
+ 0,
+ 0,
+ 0,
+ },
+ /* Valid tunables set before ill-formatted ones are set. */
+ {
+ "glibc.malloc.check=2:glibc.malloc.mmap_threshold=4096=4096",
2,
- 4096,
+ 0,
0,
}
};
^ permalink raw reply [flat|nested] 3+ messages in thread
* [glibc/azanella/tunables] elf: Do not process invalid tunable format
@ 2023-10-04 19:28 Adhemerval Zanella
0 siblings, 0 replies; 3+ messages in thread
From: Adhemerval Zanella @ 2023-10-04 19:28 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=dde95b6c66dc99c82bccd7db31fad095cd2b31d5
commit dde95b6c66dc99c82bccd7db31fad095cd2b31d5
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed Oct 4 09:29:49 2023 -0300
elf: Do not process invalid tunable format
Tunables string with with more than one '=' on its definition are
parsed and enabled, and any subsequent '=' are ignored. It means
that tunables in the form 'tunable=tunable=value' or
'tunable=value=value' are handled 'tunable=value'. This inputs are
most likely user input error, which should not be accepted.
Checked on x86_64-linux-gnu.
Diff:
---
elf/dl-tunables.c | 6 ++++--
elf/tst-tunables.c | 21 +++++++++++++++++++++
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
index 18ce0c0b27..9cd4c52568 100644
--- a/elf/dl-tunables.c
+++ b/elf/dl-tunables.c
@@ -194,10 +194,12 @@ parse_tunables (char *valstring)
const char *value = p;
- while (*p != ':' && *p != '\0')
+ while (*p != '=' && *p != ':' && *p != '\0')
p++;
- if (*p == '\0')
+ if (*p == '=')
+ break;
+ else if (*p == '\0')
done = true;
else
*p++ = '\0';
diff --git a/elf/tst-tunables.c b/elf/tst-tunables.c
index ec1ec8462c..006ba965c0 100644
--- a/elf/tst-tunables.c
+++ b/elf/tst-tunables.c
@@ -136,12 +136,33 @@ static const struct test_t
0,
0,
},
+ /* Ill-formatted tunables are ignored. */
+ {
+ "glibc.malloc.check=2=2",
+ 0,
+ 0,
+ 0,
+ },
{
"glibc.malloc.mmap_threshold=glibc.malloc.mmap_threshold=4096",
0,
0,
0,
},
+ /* If there is a ill-formatted key=value, everything after is also ignored. */
+ {
+ "glibc.malloc.check=2=2:glibc.malloc.check=2",
+ 0,
+ 0,
+ 0,
+ },
+ /* Valid tunables set before ill-formatted ones are set. */
+ {
+ "glibc.malloc.check=2:glibc.malloc.mmap_threshold=4096=4096",
+ 2,
+ 0,
+ 0,
+ }
};
static int
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-06 14:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-06 14:28 [glibc/azanella/tunables] elf: Do not process invalid tunable format Adhemerval Zanella
-- strict thread matches above, loose matches on Subject: below --
2023-10-05 13:13 Adhemerval Zanella
2023-10-04 19:28 Adhemerval Zanella
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 read-only IMAP folder(s) and NNTP newsgroup(s).