From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EE5F1F942A for ; Mon, 21 Oct 2024 18:08:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729534091; cv=none; b=hTrrm5Sh3jmVIIN8U0LOusE7f8KerqQXOdiVQ6Z8I0Ggc9U8sBsQvP51TzAkhDDYBBR0lunDyF+owinGI63Ww3F9tS1BpcD2SzuIIH1wwNleU8XzW319LE846dEPSQ5LaUEqu/ULb4xS0PFCbSnJDqd3RB06tuJBw05SKIpv5OE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729534091; c=relaxed/simple; bh=D0d5In6DCbMfFS274VgdUXbQ59mwAxnQZc+zdris6r8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UzcZnEL6dycB9+elijP/+UeVEhJnRwP29niin4UnORdFBN8SvC1Mj8FDgA8M+Amy1IGk730i7oazz2knF35Csl0pMTl18CDyAbCbGfxTO7quJ5GbRcbX2C3b962OmMs76OoPgWokrBGoBVj+XhyK0xsMPnkxiWjICCJZ7xEP/Gc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UFL1N1mJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="UFL1N1mJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C82DDC4CEC3; Mon, 21 Oct 2024 18:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1729534091; bh=D0d5In6DCbMfFS274VgdUXbQ59mwAxnQZc+zdris6r8=; h=From:To:Cc:Subject:Date:Reply-to:From; b=UFL1N1mJRoU4hOWRgufKU6azsA57AiiarqazSCdV87evJhPcolpb3QOSlXJMFcIQh wpKsXt3nUJvHr0gC64fADNIyzfQIhfBxsRe8C33vvABGDjFAbmubfGL44pAMEK/1kf CE92de+P7pKj9WnrWJy4zGzsWC2bAlJXfZ3TH7T4= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-49987: bpftool: Fix undefined behavior in qsort(NULL, 0, ...) Date: Mon, 21 Oct 2024 20:03:15 +0200 Message-ID: <2024102136-CVE-2024-49987-e897@gregkh> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=2868; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=D0d5In6DCbMfFS274VgdUXbQ59mwAxnQZc+zdris6r8=; b=owGbwMvMwCRo6H6F97bub03G02pJDOli0xkPrXGW0rISN+Tr35YzIXHzbpapkx+2bstfqVB38 dKDf+82dsSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEXLYxzE+fsVRuSfctSV1X 4ZKqNcHdypsecjIsODwzjfOQeseWd9M/68ps0O3+kMr4AQA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: bpftool: Fix undefined behavior in qsort(NULL, 0, ...) When netfilter has no entry to display, qsort is called with qsort(NULL, 0, ...). This results in undefined behavior, as UBSan reports: net.c:827:2: runtime error: null pointer passed as argument 1, which is declared to never be null Although the C standard does not explicitly state whether calling qsort with a NULL pointer when the size is 0 constitutes undefined behavior, Section 7.1.4 of the C standard (Use of library functions) mentions: "Each of the following statements applies unless explicitly stated otherwise in the detailed descriptions that follow: If an argument to a function has an invalid value (such as a value outside the domain of the function, or a pointer outside the address space of the program, or a null pointer, or a pointer to non-modifiable storage when the corresponding parameter is not const-qualified) or a type (after promotion) not expected by a function with variable number of arguments, the behavior is undefined." To avoid this, add an early return when nf_link_info is NULL to prevent calling qsort with a NULL pointer. The Linux kernel CVE team has assigned CVE-2024-49987 to this issue. Affected and fixed versions =========================== Fixed in 6.6.55 with commit c2d9f9a7837a Fixed in 6.10.14 with commit 2e0f6f33f2aa Fixed in 6.11.3 with commit c208b02827eb Fixed in 6.12-rc1 with commit f04e2ad394e2 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2024-49987 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: tools/bpf/bpftool/net.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/c2d9f9a7837ab29ccae0c42252f17d436bf0a501 https://git.kernel.org/stable/c/2e0f6f33f2aa87493b365a38a8fd87b8854b7734 https://git.kernel.org/stable/c/c208b02827eb642758cef65641995fd3f38c89af https://git.kernel.org/stable/c/f04e2ad394e2755d0bb2d858ecb5598718bf00d5