tunables: Terminate if end of input is reached (CVE-2023-4911) 85/299585/2
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Tue, 19 Sep 2023 22:39:32 +0000 (18:39 -0400)
committerSlava Barinov <v.barinov@samsung.com>
Thu, 5 Oct 2023 08:45:41 +0000 (11:45 +0300)
commit249ffd77d45dca20ebc159c060b7ad661d9f0c46
treea8ec1f57905d96dfdd36095f1d972b19da82a888
parent37e5c623d30e6a7a67e6b920aca3e7aace89babe
tunables: Terminate if end of input is reached (CVE-2023-4911)

The string parsing routine may end up writing beyond bounds of tunestr
if the input tunable string is malformed, of the form name=name=val.
This gets processed twice, first as name=name=val and next as name=val,
resulting in tunestr being name=name=val:name=val, thus overflowing
tunestr.

Terminate the parsing loop at the first instance itself so that tunestr
does not overflow.

This also fixes up tst-env-setuid-tunables to actually handle failures
correct and add new tests to validate the fix for this CVE.

Change-Id: I2e6721f2f17f5079cceb5e5803a39856e483c2dd
Commit: 1056e5b4c3f2d90ed2b4a55f96add28da2f4c8fa
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
elf/dl-tunables.c
elf/tst-env-setuid-tunables.c