From patchwork Mon Oct 7 16:09:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13824989 X-Patchwork-Delegate: bpf@iogearbox.net 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 08C961DA30F for ; Mon, 7 Oct 2024 16:10:03 +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=1728317403; cv=none; b=uXB8Koq/oCUyTIIxfQDUVo0vdxNS/niCqQMciMoRUMJM2azusT7r98p+blMFcsJWVZsSrpPhueJfM4E6wGQylui3sbMsuByN/cvVWydEV5F4MriyXAfqEF2bQSKmHz8h9xKqj6HSDYabHNIU6MhTyyiah6Rmc4xIuwkO/X4kDP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728317403; c=relaxed/simple; bh=/WpLl5BbElXpGEcoP0gQhwXNsO9hIODoejkS0F8SHlQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DISrjI/dlIcqmBSpcdgLycSA6zB9rjjc+IS0hBnhKE6x1aAnopFlPD+4mNigH747maakFhFQgKt8Bq9/p7uLjPd+Izl1XkZ0EUUeqbiYYVDyAPC8TbH82qGIlzdcxHmjjn5OfiAipdjvvASkvBmy20wF5v46VPvx/Bt0doJGooc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k3o5uw1g; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="k3o5uw1g" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 281D4C4CEC6; Mon, 7 Oct 2024 16:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728317402; bh=/WpLl5BbElXpGEcoP0gQhwXNsO9hIODoejkS0F8SHlQ=; h=From:To:Cc:Subject:Date:From; b=k3o5uw1gkHxsQ/axzKA4q0PPIibMJ9Tee35pBwcDAyLYu3NrMnKcFxd0EtbY4k8ow rzCochZQSCEGKAkIVDihnXzj/IDPZcU+FSZz7phj5K+LfeiXbmkr7ehhy5GNrX/VEd eR8Brd2LAPD97OGkOT6439kQWbzb0BHqhz34y4lU7g7meYsXkBu7MD22J21guDZvSk q0x2Ufb5nh7APwNDDDVg7Op4KuZubm2lJTUxYUzC6g+L+ZO0mThbHhadKLvT/F+gvw eFsRkvua8Ue+QuIot315ugnFznUKLHpBfcmfqfj3HcMRdRqRhtH4C1PzoKU+xhImOE 6gbuga9yUOLpQ== From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: Eduard Zingerman , bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo Subject: [PATCH bpf] bpf: Fix memory leak in bpf_core_apply Date: Mon, 7 Oct 2024 18:09:58 +0200 Message-ID: <20241007160958.607434-1-jolsa@kernel.org> X-Mailer: git-send-email 2.46.2 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net We need to free specs properly. Cc: Eduard Zingerman Fixes: 3d2786d65aaa ("bpf: correctly handle malformed BPF_CORE_TYPE_ID_LOCAL relos") Signed-off-by: Jiri Olsa Acked-by: Eduard Zingerman --- kernel/bpf/btf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 75e4fe83c509..a05da5f43547 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -8961,6 +8961,7 @@ int bpf_core_apply(struct bpf_core_ctx *ctx, const struct bpf_core_relo *relo, if (!type) { bpf_log(ctx->log, "relo #%u: bad type id %u\n", relo_idx, relo->type_id); + kfree(specs); return -EINVAL; }