In the Linux kernel, the following vulnerability has been resolved:
exec: Force single empty string when argv is empty
Quoting[1] Ariadne Conill:
"In several other operating systems, it is a hard requirement that the second argument to execve(2) be the name of a program, thus prohibiting a scenario where argc < 1. POSIX 2017 also recommends this behaviour, but it is not an explicit requirement[2]:
The argument arg0 should point to a filename string that is
associated with the process being started by one of the exec
functions.
... Interestingly, Michael Kerrisk opened an issue about this in 2008[3], but there was no consensus to support fixing this issue then. Hopefully now that CVE-2021-4034 shows practical exploitative use[4] of this bug in a shellcode, we can reconsider.
This issue is being tracked in the KSPP issue tracker[5]."
While the initial code searches[6][7] turned up what appeared to be mostly corner case tests, trying to that just reject argv == NULL (or an immediately terminated pointer list) quickly started tripping[8] existing userspace programs.
The next best approach is forcing a single empty string into argv and adjusting argc to match. The number of programs depending on argc == 0 seems a smaller set than those calling execve with a NULL argv.
Account for the additional stack space in bprmstacklimits(). Inject an empty string when argc == 0 (and set argc = 1). Warn about the case so userspace has some notice about the change:
process './argc0' launched './argc0' with NULL argv: empty string added
Additionally WARN() and reject NULL argv usage for kernel threads.
[1] https://lore.kernel.org/lkml/20220127000724.15106-1-ariadne@dereferenced.org/ [2] https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html [3] https://bugzilla.kernel.org/show_bug.cgi?id=8408 [4] https://www.qualys.com/2022/01/25/cve-2021-4034/pwnkit.txt [5] https://github.com/KSPP/linux/issues/176 [6] https://codesearch.debian.net/search?q=execve%5C+%5C%28%5B%5E%2C%5D%2B%2C+NULL&literal=0 [7] https://codesearch.debian.net/search?q=execlp%3F%5Cs%5C%28%5B%5E%2C%5D%2B%2C%5CsNULL&literal=0 [8] https://lore.kernel.org/lkml/20220131144352.GE16385@xsang-OptiPlex-9020/
[
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a8054d3fa5deb84b215d6be1b910a978f3cb840d",
"target": {
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-09d1ecc7",
"signature_version": "v1",
"digest": {
"threshold": 0.9,
"line_hashes": [
"149585033398831400056510740723709629990",
"116507319040836275948452528606882119282",
"200003845959847734677441107097359817240",
"240225666233168989021916174393843882667",
"90000305304567309979234528275624843374",
"40727549307131118986873127945961072225",
"105006241140540671525221559028793240711",
"36302044547842476783305442197558731138",
"65140118242259547204238959180323718989",
"233396571893578526928699949247433279062",
"237233058322788884223338943644771486661",
"83189572416529480679989921417708536594",
"217756643247200265716953219525012884801",
"232736958747936570505994587478207202999",
"186627872250366237444912452958044844350"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@cfbfff8ce5e3d674947581f1eb9af0a1b1807950",
"target": {
"function": "do_execveat_common",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-0e59e47d",
"signature_version": "v1",
"digest": {
"length": 1109.0,
"function_hash": "317963370853499667058999826131150035259"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@27a6f495b63a1804cc71be45911065db7757a98c",
"target": {
"function": "bprm_stack_limits",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-19753fb1",
"signature_version": "v1",
"digest": {
"length": 365.0,
"function_hash": "125745522472244434873836170345031294329"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a8054d3fa5deb84b215d6be1b910a978f3cb840d",
"target": {
"function": "do_execveat_common",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-2b39eb49",
"signature_version": "v1",
"digest": {
"length": 1109.0,
"function_hash": "317963370853499667058999826131150035259"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@27a6f495b63a1804cc71be45911065db7757a98c",
"target": {
"function": "do_execveat_common",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-335b9f48",
"signature_version": "v1",
"digest": {
"length": 1102.0,
"function_hash": "294935100423044551983568584315185418901"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1290eb4412aa0f0e9f3434b406dc8e255da85f9e",
"target": {
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-39441967",
"signature_version": "v1",
"digest": {
"threshold": 0.9,
"line_hashes": [
"149585033398831400056510740723709629990",
"116507319040836275948452528606882119282",
"200003845959847734677441107097359817240",
"240225666233168989021916174393843882667",
"90000305304567309979234528275624843374",
"40727549307131118986873127945961072225",
"105006241140540671525221559028793240711",
"36302044547842476783305442197558731138",
"65140118242259547204238959180323718989",
"233396571893578526928699949247433279062",
"237233058322788884223338943644771486661",
"83189572416529480679989921417708536594",
"217756643247200265716953219525012884801",
"232736958747936570505994587478207202999",
"186627872250366237444912452958044844350"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@dcd46d897adb70d63e025f175a00a89797d31a43",
"target": {
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-43f03924",
"signature_version": "v1",
"digest": {
"threshold": 0.9,
"line_hashes": [
"149585033398831400056510740723709629990",
"116507319040836275948452528606882119282",
"200003845959847734677441107097359817240",
"240225666233168989021916174393843882667",
"90000305304567309979234528275624843374",
"40727549307131118986873127945961072225",
"105006241140540671525221559028793240711",
"36302044547842476783305442197558731138",
"65140118242259547204238959180323718989",
"233396571893578526928699949247433279062",
"237233058322788884223338943644771486661",
"83189572416529480679989921417708536594",
"217756643247200265716953219525012884801",
"232736958747936570505994587478207202999",
"186627872250366237444912452958044844350"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@98e0c7c702894987732776736c99b85ade6fba45",
"target": {
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-53ec8369",
"signature_version": "v1",
"digest": {
"threshold": 0.9,
"line_hashes": [
"64135671558171740196371228753540157622",
"325849491154393520256247990793204510312",
"286250705110704187664770562448961267199",
"229332349178422085564209044152679633129",
"5553345741985737526018441403818772482",
"56465899484906420285292780676788665605",
"229502568296678378325973596074217370718"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@cfbfff8ce5e3d674947581f1eb9af0a1b1807950",
"target": {
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-66d79bd2",
"signature_version": "v1",
"digest": {
"threshold": 0.9,
"line_hashes": [
"149585033398831400056510740723709629990",
"116507319040836275948452528606882119282",
"200003845959847734677441107097359817240",
"240225666233168989021916174393843882667",
"90000305304567309979234528275624843374",
"40727549307131118986873127945961072225",
"105006241140540671525221559028793240711",
"36302044547842476783305442197558731138",
"65140118242259547204238959180323718989",
"233396571893578526928699949247433279062",
"237233058322788884223338943644771486661",
"83189572416529480679989921417708536594",
"217756643247200265716953219525012884801",
"232736958747936570505994587478207202999",
"186627872250366237444912452958044844350"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@27a6f495b63a1804cc71be45911065db7757a98c",
"target": {
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-6b592e92",
"signature_version": "v1",
"digest": {
"threshold": 0.9,
"line_hashes": [
"149585033398831400056510740723709629990",
"116507319040836275948452528606882119282",
"200003845959847734677441107097359817240",
"240225666233168989021916174393843882667",
"90000305304567309979234528275624843374",
"40727549307131118986873127945961072225",
"105006241140540671525221559028793240711",
"36302044547842476783305442197558731138",
"65140118242259547204238959180323718989",
"233396571893578526928699949247433279062",
"237233058322788884223338943644771486661",
"83189572416529480679989921417708536594",
"217756643247200265716953219525012884801",
"232736958747936570505994587478207202999",
"186627872250366237444912452958044844350"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a8054d3fa5deb84b215d6be1b910a978f3cb840d",
"target": {
"function": "bprm_stack_limits",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-7e03f93f",
"signature_version": "v1",
"digest": {
"length": 365.0,
"function_hash": "125745522472244434873836170345031294329"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@cfbfff8ce5e3d674947581f1eb9af0a1b1807950",
"target": {
"function": "bprm_stack_limits",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-89663c5d",
"signature_version": "v1",
"digest": {
"length": 365.0,
"function_hash": "125745522472244434873836170345031294329"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1290eb4412aa0f0e9f3434b406dc8e255da85f9e",
"target": {
"function": "bprm_stack_limits",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-8ddb7851",
"signature_version": "v1",
"digest": {
"length": 365.0,
"function_hash": "125745522472244434873836170345031294329"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@41f6ea5b9aaa28b740d47ffe995a5013211fdbb0",
"target": {
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-92b7710c",
"signature_version": "v1",
"digest": {
"threshold": 0.9,
"line_hashes": [
"64135671558171740196371228753540157622",
"325849491154393520256247990793204510312",
"286250705110704187664770562448961267199",
"229332349178422085564209044152679633129",
"5553345741985737526018441403818772482",
"56465899484906420285292780676788665605",
"229502568296678378325973596074217370718"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@98e0c7c702894987732776736c99b85ade6fba45",
"target": {
"function": "do_execveat_common",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-95a11cf0",
"signature_version": "v1",
"digest": {
"length": 2422.0,
"function_hash": "72671013195339022122683532170611581525"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@dcd46d897adb70d63e025f175a00a89797d31a43",
"target": {
"function": "kernel_execve",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-988e6876",
"signature_version": "v1",
"digest": {
"length": 916.0,
"function_hash": "35002746750082743761537501932968068484"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@cfbfff8ce5e3d674947581f1eb9af0a1b1807950",
"target": {
"function": "kernel_execve",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-995fcb7d",
"signature_version": "v1",
"digest": {
"length": 916.0,
"function_hash": "35002746750082743761537501932968068484"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b50fb8dbc8b81aaa126387de428f4c42a7c72a73",
"target": {
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-aae0c676",
"signature_version": "v1",
"digest": {
"threshold": 0.9,
"line_hashes": [
"64135671558171740196371228753540157622",
"325849491154393520256247990793204510312",
"286250705110704187664770562448961267199",
"229332349178422085564209044152679633129",
"5553345741985737526018441403818772482",
"56465899484906420285292780676788665605",
"229502568296678378325973596074217370718"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1fe82bfd9e4ce93399d815ca458b58505191c3e8",
"target": {
"function": "__do_execve_file",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-ac81b9c5",
"signature_version": "v1",
"digest": {
"length": 2396.0,
"function_hash": "187247774609180162593539244307055692223"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a8054d3fa5deb84b215d6be1b910a978f3cb840d",
"target": {
"function": "kernel_execve",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-b4137f4b",
"signature_version": "v1",
"digest": {
"length": 916.0,
"function_hash": "35002746750082743761537501932968068484"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b50fb8dbc8b81aaa126387de428f4c42a7c72a73",
"target": {
"function": "__do_execve_file",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-beca9866",
"signature_version": "v1",
"digest": {
"length": 2546.0,
"function_hash": "87877990375467773379048640019888066027"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1290eb4412aa0f0e9f3434b406dc8e255da85f9e",
"target": {
"function": "kernel_execve",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-c0932b29",
"signature_version": "v1",
"digest": {
"length": 916.0,
"function_hash": "35002746750082743761537501932968068484"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1fe82bfd9e4ce93399d815ca458b58505191c3e8",
"target": {
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-c5b1c50a",
"signature_version": "v1",
"digest": {
"threshold": 0.9,
"line_hashes": [
"166497978040504460130142260032314296903",
"18744310435035315091545189594994941277",
"310079439079001165729482259713372623317",
"101165600185570731524478573758860889352",
"149585033398831400056510740723709629990",
"116507319040836275948452528606882119282",
"200003845959847734677441107097359817240",
"240225666233168989021916174393843882667",
"5553345741985737526018441403818772482",
"56465899484906420285292780676788665605",
"229502568296678378325973596074217370718"
]
},
"signature_type": "Line"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@dcd46d897adb70d63e025f175a00a89797d31a43",
"target": {
"function": "do_execveat_common",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-c72a834f",
"signature_version": "v1",
"digest": {
"length": 1109.0,
"function_hash": "317963370853499667058999826131150035259"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1fe82bfd9e4ce93399d815ca458b58505191c3e8",
"target": {
"function": "prepare_arg_pages",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-cbc7e333",
"signature_version": "v1",
"digest": {
"length": 599.0,
"function_hash": "170044925890909211240479696723304471259"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@dcd46d897adb70d63e025f175a00a89797d31a43",
"target": {
"function": "bprm_stack_limits",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-cfe75e14",
"signature_version": "v1",
"digest": {
"length": 365.0,
"function_hash": "125745522472244434873836170345031294329"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1290eb4412aa0f0e9f3434b406dc8e255da85f9e",
"target": {
"function": "do_execveat_common",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-eb44b5b2",
"signature_version": "v1",
"digest": {
"length": 1109.0,
"function_hash": "317963370853499667058999826131150035259"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@27a6f495b63a1804cc71be45911065db7757a98c",
"target": {
"function": "kernel_execve",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-f867248e",
"signature_version": "v1",
"digest": {
"length": 916.0,
"function_hash": "35002746750082743761537501932968068484"
},
"signature_type": "Function"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@41f6ea5b9aaa28b740d47ffe995a5013211fdbb0",
"target": {
"function": "do_execveat_common",
"file": "fs/exec.c"
},
"deprecated": false,
"id": "CVE-2022-49264-fde96b13",
"signature_version": "v1",
"digest": {
"length": 2405.0,
"function_hash": "109806944696378717571006679845537540478"
},
"signature_type": "Function"
}
]