Skip to content
Heist/ feed
Back to feed
UnratedFix available

bpf: Avoid uninitialized value in BPF_CORE_READ_BITFIELD

Type: advisorySources: OSV

In the Linux kernel, the following vulnerability has been resolved: bpf: Avoid uninitialized value in BPF_CORE_READ_BITFIELD [Changes from V1: - Use a default branch in the switch statement to initialize `val'.] GCC warns that `val' may be used uninitialized in the BPF_CRE_READ_BITFIELD macro, defined in bpf_core_read.h as: [...] unsigned long long val; \ [...] \ switch (__CORE_RELO(s, field, BYTE_SIZE)) { \ case 1: val = *(const unsigned char *)p; break; \ case 2: val = *(const unsigned short *)p; break; \ case 4: val = *(const unsigned int *)p; break; \ case 8: val = *(const unsigned long long *)p; break; \ } \ [...] val; \ } \ This patch adds a default entry in the switch statement that sets `val' to zero in order to avoid the warning, and random values to be used in case __builtin_preserve_field_info returns unexpected values for BPF_FIELD_BYTE_SIZE. Tested in bpf-next master. No regressions.

Products
Kernel
Affected versions
Not specified
Fixed versions
5.10.222, 5.15.163, 6.1.98, 6.6.39, 6.9.9
CVEs
CVE-2024-42161
Confirmed fixed CVEs
Not specified
Updated in this feed
4 Nov 2026, 13:28 UTC · Revision 1

Source evidence

bpf: Avoid uninitialized value in BPF_CORE_READ_BITFIELD

core-osv · Original source

Published 30 Jul 2024, 07:47 UTC

In the Linux kernel, the following vulnerability has been resolved: bpf: Avoid uninitialized value in BPF_CORE_READ_BITFIELD [Changes from V1: - Use a default branch in the switch statement to initialize `val'.] GCC warns that `val' may be used uninitialized in the BPF_CRE_READ_BITFIELD macro, defined in bpf_core_read.h as: [...] unsigned long long val; \ [...] \ switch (__CORE_RELO(s, field, BYTE_SIZE)) { \ case 1: val = *(const unsigned char *)p; break; \ case 2: val = *(const unsigned short *)p; break; \ case 4: val = *(const unsigned int *)p; break; \ case 8: val = *(const unsigned long long *)p; break; \ } \ [...] val; \ } \ This patch adds a default entry in the switch statement that sets `val' to zero in order to avoid the warning, and random values to be used in case __builtin_preserve_field_info returns unexpected values for BPF_FIELD_BYTE_SIZE. Tested in bpf-next master. No regressions.

osv:CVE-2024-42161

Kernel

Fixed versions: 5.10.222, 5.15.163, 6.1.98, 6.6.39, 6.9.9

Complete source record
{
  "id": "b7234ed90b713f1180548e0c8c977680f2a3bf45e823a3bc8f86eb0f3a5835f3",
  "url": "https://osv.dev/vulnerability/CVE-2024-42161",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "bpf: Avoid uninitialized value in BPF_CORE_READ_BITFIELD",
    "summary": "In the Linux kernel, the following vulnerability has been resolved: bpf: Avoid uninitialized value in BPF_CORE_READ_BITFIELD [Changes from V1: - Use a default branch in the switch statement to initialize `val'.] GCC warns that `val' may be used uninitialized in the BPF_CRE_READ_BITFIELD macro, defined in bpf_core_read.h as: [...] unsigned long long val; \\ [...] \\ switch (__CORE_RELO(s, field, BYTE_SIZE)) { \\ case 1: val = *(const unsigned char *)p; break; \\ case 2: val = *(const unsigned short *)p; break; \\ case 4: val = *(const unsigned int *)p; break; \\ case 8: val = *(const unsigned long long *)p; break; \\ } \\ [...] val; \\ } \\ This patch adds a default entry in the switch statement that sets `val' to zero in order to avoid the warning, and random values to be used in case __builtin_preserve_field_info returns unexpected values for BPF_FIELD_BYTE_SIZE. Tested in bpf-next master. No regressions.",
    "evidence": "osv:CVE-2024-42161",
    "products": [
      {
        "name": {
          "value": "Kernel",
          "evidence": "/affected/1/package/name"
        },
        "prerequisites": [],
        "fixed_versions": [
          {
            "value": "5.10.222",
            "evidence": "/affected/1/ranges"
          },
          {
            "value": "5.15.163",
            "evidence": "/affected/1/ranges"
          },
          {
            "value": "6.1.98",
            "evidence": "/affected/1/ranges"
          },
          {
            "value": "6.6.39",
            "evidence": "/affected/1/ranges"
          },
          {
            "value": "6.9.9",
            "evidence": "/affected/1/ranges"
          }
        ],
        "affected_versions": []
      }
    ],
    "severity": "unknown",
    "structured": {
      "id": "CVE-2024-42161",
      "aliases": [
        "CVE-2024-42161"
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
              "type": "GIT",
              "events": [
                {
                  "introduced": "ee26dade0e3bcd8a34ae7520e373fb69365fce7a"
                },
                {
                  "fixed": "b694989bb13ed5f166e633faa1eb0f21c6d261a6"
                },
                {
                  "fixed": "3364c2ed1c241989847f19cf83e3db903ce689e3"
                },
                {
                  "fixed": "a21d76bd0b0d39518e9a4c19f6cf7c042a974aff"
                },
                {
                  "fixed": "7e5471b5efebc30dd0bc035cda86693a5c73d45f"
                },
                {
                  "fixed": "ff941a8449e712eaf7efca1a13bfb9afd3d99fc2"
                },
                {
                  "fixed": "009367099eb61a4fc2af44d4eb06b6b4de7de6db"
                }
              ]
            }
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-42161.json"
          }
        },
        {
          "ranges": [
            {
              "type": "ECOSYSTEM",
              "events": [
                {
                  "introduced": "5.5.0"
                },
                {
                  "fixed": "5.10.222"
                }
              ]
            },
            {
              "type": "ECOSYSTEM",
              "events": [
                {
                  "introduced": "5.11.0"
                },
                {
                  "fixed": "5.15.163"
                }
              ]
            },
            {
              "type": "ECOSYSTEM",
              "events": [
                {
                  "introduced": "5.16.0"
                },
                {
                  "fixed": "6.1.98"
                }
              ]
            },
            {
              "type": "ECOSYSTEM",
              "events": [
                {
                  "introduced": "6.2.0"
                },
                {
                  "fixed": "6.6.39"
                }
              ]
            },
            {
              "type": "ECOSYSTEM",
              "events": [
                {
                  "introduced": "6.7.0"
                },
                {
                  "fixed": "6.9.9"
                }
              ]
            }
          ],
          "package": {
            "name": "Kernel",
            "ecosystem": "Linux"
          },
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-42161.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:36.296508103Z",
      "provider": "osv",
      "references": [
        "https://git.kernel.org/stable/c/009367099eb61a4fc2af44d4eb06b6b4de7de6db",
        "https://git.kernel.org/stable/c/3364c2ed1c241989847f19cf83e3db903ce689e3",
        "https://git.kernel.org/stable/c/7e5471b5efebc30dd0bc035cda86693a5c73d45f",
        "https://git.kernel.org/stable/c/a21d76bd0b0d39518e9a4c19f6cf7c042a974aff",
        "https://git.kernel.org/stable/c/b694989bb13ed5f166e633faa1eb0f21c6d261a6",
        "https://git.kernel.org/stable/c/ff941a8449e712eaf7efca1a13bfb9afd3d99fc2",
        "https://lists.debian.org/debian-lts-announce/2025/01/msg00001.html",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/42xxx/CVE-2024-42161.json",
        "https://nvd.nist.gov/vuln/detail/CVE-2024-42161",
        "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"
      ],
      "provider_metadata": {
        "cna_assigner": "Linux",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/42xxx/CVE-2024-42161.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2024-42161",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": null
  },
  "source_id": "core-osv",
  "document_id": 503133,
  "published_at": "2024-07-30T07:47:03.136+00:00"
}