From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 27D6545AE2 for ; Tue, 8 Oct 2024 17:43:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E35BF40E0B; Tue, 8 Oct 2024 17:43:25 +0200 (CEST) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by mails.dpdk.org (Postfix) with ESMTP id 0058A40A72 for ; Tue, 8 Oct 2024 17:43:18 +0200 (CEST) Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-71e01eff831so1746802b3a.2 for ; Tue, 08 Oct 2024 08:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1728402198; x=1729006998; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PmRTbddZLG2JxQ2OFMT3a37iU/8U3GJd/GKLMFfTKa0=; b=PNyPsUTNLy33Pr5JJt+jmHMNDddvXNYoZF2jNY9UCSXc6ZN/nJpEOxf1oDJs1gWVKD HmgHfpKVOVm41ScIbEeWXMjmRDKn1X4hAkGe9+7qnwfrC4+kBt1jssDGxxhAMcysZlHH o7gRsfPh2ltdM8weHgKXmRE7M9w4ctJLuNtUkKM+MuA0spHb557FBOJZE+E+EqqC5oH9 +RYGqF6F0S1I/DYMw38Vak0PnqQBwpd7cSchn0VL8vvF8BlHNTOuAliyJ3oUzFiH4jr3 dOLEk3JmVHvrjYDphl7k16gYkcL6BPg7YRP83IcIq47ZHLs2keb7J73lDsp3SkwldTda FDkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728402198; x=1729006998; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PmRTbddZLG2JxQ2OFMT3a37iU/8U3GJd/GKLMFfTKa0=; b=nXclm4Wx/xGbNDZObxlT5QLPTApUh8qbOo0MEa3Q6kqpUM9X+cdz9g6ZIcW3L7/mgW taq0VjnPI+ajSWLpZylavFWY/papnUz0Fg1JRWYtKSHFILI0xmw087om/bKUznbcqQb4 PuMti92jyBLeRiHhfnxoFavSUz57DgazdT6uPF6wxa4pnfKPS+Tt3yoL/bzcm7tT+Vh4 7Ge47HRxec6xvQM4CVOxphzVkzLovptkr4fTHhiCwAucABsvRXcDPfjUCXIcN3sg+zzM JiLg+BCa5Ted3RXg78Ima8lIKCWZ2CR0Tzhw/9KJeqXU32T+KxWQcWw9ArpFMGPwkAz2 naEQ== X-Forwarded-Encrypted: i=1; AJvYcCUpMuz+1JN7+BnljLlWnrIcwih5ZNqBzI/V/9PTX85vrJuSHmTrQnhiwwpqEaq84vZ9FouHo10=@dpdk.org X-Gm-Message-State: AOJu0YyFUaSfk5ft4KfLCo85PIsYpEVJSw7g6sFJCrSEM/sIMRzFy5V7 k5VYSCrEwt2AiPK+dj2g/qYoOFtWsj85UwURhJSibqNmCBOJTrZ1PIWhsjsi3ZA= X-Google-Smtp-Source: AGHT+IHSSzEu3xaYNcY31mrBFYNcEvqDQ/GZP3i4nxB9qbTQpZint+/UR9Vbm5ARV8w/OP/DMUJtog== X-Received: by 2002:a05:6a00:4885:b0:71d:eb7d:20ed with SMTP id d2e1a72fcca58-71deb7d252cmr17644617b3a.12.1728402198235; Tue, 08 Oct 2024 08:43:18 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71df0ccf01dsm6293527b3a.70.2024.10.08.08.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 08:43:17 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Konstantin Ananyev , Ray Kinsella Subject: [PATCH v8 07/17] bpf: fix free mismatch if convert fails Date: Tue, 8 Oct 2024 08:41:37 -0700 Message-ID: <20241008154301.66192-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241008154301.66192-1-stephen@networkplumber.org> References: <20240927204742.546164-1-stephen@networkplumber.org> <20241008154301.66192-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org If conversion of cBF to eBPF fails then an object allocated with rte_malloc() would be passed to free(). [908/3201] Compiling C object lib/librte_bpf.a.p/bpf_bpf_convert.c.o ../lib/bpf/bpf_convert.c: In function ‘rte_bpf_convert’: ../lib/bpf/bpf_convert.c:559:17: warning: ‘free’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc] 559 | free(prm); | ^~~~~~~~~ ../lib/bpf/bpf_convert.c:545:15: note: returned from ‘rte_zmalloc’ 545 | prm = rte_zmalloc("bpf_filter", | ^~~~~~~~~~~~~~~~~~~~~~~~~ 546 | sizeof(*prm) + ebpf_len * sizeof(*ebpf), 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixes: 2eccf6afbea9 ("bpf: add function to convert classic BPF to DPDK BPF") Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- lib/bpf/bpf_convert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bpf/bpf_convert.c b/lib/bpf/bpf_convert.c index d7ff2b4325..e7e298c9cb 100644 --- a/lib/bpf/bpf_convert.c +++ b/lib/bpf/bpf_convert.c @@ -556,7 +556,7 @@ rte_bpf_convert(const struct bpf_program *prog) ret = bpf_convert_filter(prog->bf_insns, prog->bf_len, ebpf, &ebpf_len); if (ret < 0) { RTE_BPF_LOG_LINE(ERR, "%s: cannot convert cBPF to eBPF", __func__); - free(prm); + rte_free(prm); rte_errno = -ret; return NULL; } -- 2.45.2