Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp45220lqc; Thu, 7 Mar 2024 09:50:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWmOB5gnlVj8YIflIBsHZz+DUHlkN4gjuj6OK/nSsYU4kwUO9kNihvZ9WXTjMlrSyhR5QaWIlOefvnCGxvoaET5F2lcd7dsizFMcfzI4w== X-Google-Smtp-Source: AGHT+IEifcj+1VSrGsCRTu+3TKZ0cGVAxsA96Hvb6LPoWTz+tGxhRRxTqDZaBqgMI/abMU7TRHkN X-Received: by 2002:a05:6a21:183:b0:1a1:3708:59ec with SMTP id le3-20020a056a21018300b001a1370859ecmr8843886pzb.39.1709833859155; Thu, 07 Mar 2024 09:50:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709833859; cv=pass; d=google.com; s=arc-20160816; b=Hwe5v4aAsdNEQQOth0pRjL5jDzgGjO8/qXyTYer/xKi34EbEpLCAjvKU6Gj4Xvsuqr cIojJNqEzCoTHaowvyejMCOq3hQOW9h5cZSeI8vSk/EMngT5ytn/F7eQV5b104Iiw3Qe LQ4hqyMEL748QKPt4hb3Zd3vhz2aGEJWyrRQiMPmGpZsz5aNPD6692c66MiYJk0vvFzL OhMILwSZyGL4lNqThmE6xB8FQGwAgWAuPiEQeLHOxi2KPEzqnWA4TNbiv9OvEa5csTcX iCwHhF83GJP0tpSStrsPYo5Wi5bbpFRackd5/Mgsj6+I+bo+32/nK9CYRoisWd64s4xC azRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=nud+ektoz1i5+ZtYiRnd5giJ9AEuUsNnJvPUlZgCtfQ=; fh=hiCfrtgc2YVIstdSynRYlrSop45w0IL11QuQj2THRoY=; b=fQUlr6A88CLjxv8pxU0+RTE62XQ2z6kv7SjC8HiIWgn3SYykIH03vq4pL84NiRfrOZ 4ad86H2fnmsDujGhrQoQF/rgtUbr1fmmiCpodvHXGkek9UUXOdjUJ2qYeolF7ZdckMpb x5r4l5NBVMvIEKuEcI29tS5oFt7FPOSG0yY94CJc2swIhqI/YL31dvm8LpkU7d+3KTaW mYzIeU78dzcA0zWGa13WmIX7OyTOpyuBzoeJhIdYDvWRdpQIgIubFBS1vfthThMl7Eta Iy/4KFxeSF1HNBMIcL4sT3iZJYbCkKXubFMI4ARD4TuJOXoofTkkZ220KOGoH+/LM/o+ +m9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QSwh0OUa; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-95975-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95975-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f13-20020a170902ce8d00b001dc5cf7ab7bsi14710133plg.336.2024.03.07.09.50.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 09:50:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95975-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QSwh0OUa; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-95975-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95975-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C9FDA28675A for ; Thu, 7 Mar 2024 17:50:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77397130E4F; Thu, 7 Mar 2024 17:50:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QSwh0OUa" Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CAA9130E46 for ; Thu, 7 Mar 2024 17:50:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709833853; cv=none; b=sNeRB6DDMfc+cDIXTByLwVKIQ5TSxcgmmcqemRkeI5OcXKP67KfmXeOx3GKbt77110qS1ENnm9xdCviGYLVLq9luEshOPp3wI+nuu3Padlx0bH/GJEUmb7CpeEt1avFYN83YZ4J4th0eDHJuxINb0lS2ygCW/jwWXvZYyH2syxU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709833853; c=relaxed/simple; bh=yVR9gOO591PhdWNViVKaVO3Dc6HRM0Gnaf6jh1DBhVk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=HC4jP5b+ARAvzU6EBEAXB/1oOMc1AVfHwSKXsSvS8Nvm6zVSjNAj2qDA0GYtAOoTsIAi8EzXaW/5/fOuB0iyJtWwX4GXK5CEGPnujcYYCtSr9w4JqsYAlb/Qc6FyeYxzaL6+wNsVm4N/jEKHMvGryIJ9H/lo+2UYaL+AzASL/NE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QSwh0OUa; arc=none smtp.client-ip=209.85.215.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-5d4a1e66750so747023a12.0 for ; Thu, 07 Mar 2024 09:50:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709833851; x=1710438651; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nud+ektoz1i5+ZtYiRnd5giJ9AEuUsNnJvPUlZgCtfQ=; b=QSwh0OUaz3F/caLmBiRHZEM2n/J5MKBeWfED7pHvKDqbyxoAdrgFM2oRUvP56pdcKZ MWjSIHRrmZTYUKSQSt7xu53TptDfjwYo3LQjS/vQ7rreTaH6+ZCCi8gL2vKElAFvsISw dxqxGSrmxx7ekU2xgvk4mteFICIXpNM1KE7bPg7IAWcDlmhbr2QR/G5HA6ZvFZSeM/+u mX3p0t7UWrbPQm0QlB9xYSvF0TBXYmga//A7S4C76iHs6JyuZUsTWN8wE0pXIgFEQ06S SLapaeRXwONnb6YPcxf+WyI3ZbLU6avAWEmM6REcBvEbIQYEUBsTrIOBX8j8Cv94B/5F qQbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709833851; x=1710438651; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nud+ektoz1i5+ZtYiRnd5giJ9AEuUsNnJvPUlZgCtfQ=; b=alZD/nrRW3MO61MTlNLiaXIlZScL1bYZqxV0Um1M44RYuVvA4k/4DxFUlXcfBAQpUR oYilVPAJ9Fpj2Y7SmsDwMqF3z4m8Gjaq9qdVZGK5xQTmhnz7rsZIabX+NYjWzTx+p1yg oUwh/Eal1IIQjv5g7UkGfoCvN6DJpwn3AyPUNy/sV+PWWo0OKXMIn3IngbkNIJsK9YgS tIMQEgXJ8CEV8KRdDmEaImL3PVSiaSZ+HDj0XtVAgujLrDHPwb07X4pZKeuJrWf0Qa2J zeYWwpY6I57b5l6WQavM20G7T+xTfApXYq3IvVo7y2N24YNPVypTuNHE3PL42/Zjqlzh NWtw== X-Forwarded-Encrypted: i=1; AJvYcCU8Y3K95ByYQct9bGS0fx7Rfy2SgJSvjOnbHi4agTMzVelwBapu2MMrzuYzYMi79cmzlcWzaB8+w18P4BHs0A7eVe8anvU4ejfH/ePM X-Gm-Message-State: AOJu0YyA2lRAmd74CtYBvwlcDQD7NHnYYyY0F1suMY5NF6amVPYM+bOh V4EvyO2XP2bIrX68SDMvH4zqpPgUAxZF0VEPfdnzJ1eE/DUUiw+GolP5r/egR+XIt7HaYLvQjTg R97327sDbCr0PqkXiJy/iTAdymHY= X-Received: by 2002:a17:90a:d58a:b0:29a:2860:28b9 with SMTP id v10-20020a17090ad58a00b0029a286028b9mr15805875pju.48.1709833851221; Thu, 07 Mar 2024 09:50:51 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <2024030645-CVE-2023-52592-4693@gregkh> <2024030706-unscathed-wilt-e310@gregkh> In-Reply-To: <2024030706-unscathed-wilt-e310@gregkh> From: Andrii Nakryiko Date: Thu, 7 Mar 2024 09:50:38 -0800 Message-ID: Subject: Re: CVE-2023-52592: libbpf: Fix NULL pointer dereference in bpf_object__collect_prog_relos To: Greg Kroah-Hartman Cc: Michal Hocko , cve@kernel.org, linux-kernel@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 7, 2024 at 5:16=E2=80=AFAM Greg Kroah-Hartman wrote: > > On Thu, Mar 07, 2024 at 10:58:19AM +0100, Michal Hocko wrote: > > On Wed 06-03-24 06:45:50, Greg KH wrote: > > > Description > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > > > In the Linux kernel, the following vulnerability has been resolved: > > > > > > libbpf: Fix NULL pointer dereference in bpf_object__collect_prog_relo= s > > > > > > An issue occurred while reading an ELF file in libbpf.c during fuzzin= g: > > > > > > Program received signal SIGSEGV, Segmentation fault. > > > 0x0000000000958e97 in bpf_object.collect_prog_relos () at libbpf.= c:4206 > > > 4206 in libbpf.c > > > (gdb) bt > > > #0 0x0000000000958e97 in bpf_object.collect_prog_relos () at libb= pf.c:4206 > > > #1 0x000000000094f9d6 in bpf_object.collect_relos () at libbpf.c:= 6706 > > > #2 0x000000000092bef3 in bpf_object_open () at libbpf.c:7437 > > > #3 0x000000000092c046 in bpf_object.open_mem () at libbpf.c:7497 > > > #4 0x0000000000924afa in LLVMFuzzerTestOneInput () at fuzz/bpf-ob= ject-fuzzer.c:16 > > > #5 0x000000000060be11 in testblitz_engine::fuzzer::Fuzzer::run_on= e () > > > #6 0x000000000087ad92 in tracing::span::Span::in_scope () > > > #7 0x00000000006078aa in testblitz_engine::fuzzer::util::walkdir = () > > > #8 0x00000000005f3217 in testblitz_engine::entrypoint::main::{{cl= osure}} () > > > #9 0x00000000005f2601 in main () > > > (gdb) > > > > > > scn_data was null at this code(tools/lib/bpf/src/libbpf.c): > > > > > > if (rel->r_offset % BPF_INSN_SZ || rel->r_offset >=3D scn_data->d= _size) { > > > > > > The scn_data is derived from the code above: > > > > > > scn =3D elf_sec_by_idx(obj, sec_idx); > > > scn_data =3D elf_sec_data(obj, scn); > > > > > > relo_sec_name =3D elf_sec_str(obj, shdr->sh_name); > > > sec_name =3D elf_sec_name(obj, scn); > > > if (!relo_sec_name || !sec_name)// don't check whether scn_data i= s NULL > > > return -EINVAL; > > > > > > In certain special scenarios, such as reading a malformed ELF file, > > > it is possible that scn_data may be a null pointer > > > > > > The Linux kernel CVE team has assigned CVE-2023-52592 to this issue. > > > > OK, so this one is quite interesting. This is a userspace tooling > > gaining a kernel CVE. Is this just an omission or is this really > > expected. > > "omission"? I don't understand the question. > > We are responsible for assigning CVEs to stuff that is in the "Linux > kernel source tree" (some have tried to get us to assign CVEs to > programs like git that are just hosted on kernel.org), so for now, yes, > this includes libbpf as well as stuff like perf. > > > Also what is the security threat model here? If a malformed ELF file is > > loaded then the process gets SEGV which is perfectly reasonable thing t= o > > do. > > Again, we do not do "threat modeling", we do "does this fix a weakness", > and I think this does as causing SEGV might not be a good thing, right? > > But we'll defer to the libbpf maintainers on this, if they feel this is > just a "normal bugfix" then we can revoke this (added them to the cc: > here.) Libbpf isn't meant to be fed untrusted ELF files, as it's normally used under root to perform BPF operations. So we generally treat these issues of malformed ELF crashing libbpf as just normal bugs, not as a security vulnerability. We even had issues where libelf crashed before libbpf could do anything at all. But this happens only for fuzzer-generated artificial test cases. In practice compilers produce valid ELFs and that's what real world applications are ever going to use. Also note, in-kernel libbpf sources are only used for kernel build-time tooling (resolve_btfids) and for running BPF selftests. In both cases incoming ELF files are valid and created in a controlled environment. All the out-of-kernel users are supposed to use Github mirror of libbpf ([0]), which is used for packing libbpf in distros. tl;dr: I wouldn't assign CVE for such issues, thanks. [0] https://github.com/libbpf/libbpf > > thanks, > > greg k-h