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 5547745A48 for ; Fri, 27 Sep 2024 22:48:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2E20740687; Fri, 27 Sep 2024 22:48:11 +0200 (CEST) Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) by mails.dpdk.org (Postfix) with ESMTP id 435D140612 for ; Fri, 27 Sep 2024 22:48:04 +0200 (CEST) Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-3a342bae051so7797125ab.3 for ; Fri, 27 Sep 2024 13:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727470083; x=1728074883; 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=WH5uEBtnpx8obgm2S8qqJ9aDGEDALn73J7cj1/JU1stahTXcovEtCmnrHu+3naHuKv nw0jhHQVsI/MCpe7vG6yHilHbMqkp6MLvvI2zYaR1DktTQy4EWMvSKXHXqUV9+fFb2m+ r4ESp/Y1awDYcac6J2SjRoTP165b3dew1/PpGUI+KVKU7xy0Jfe1vgWo3fjAqssPH6rC 8mENJ9z6Ti1kJ5VlSpNZlJENpG2N40oHFG0mZvcsO5aOFJpmVyu035/sfq9OZcSC3Hqb zqKuRRfa7G3gkizkUI/Dfd3A00K4dSw75RaPhtVS2BRs8WNehapYNXW8aa9JyU/zAQXx iPDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727470083; x=1728074883; 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=O0zKY/T9Msht95kvJzIM1QEJNwac7jXm2vG6vNr8yvBln5MCaBU9lJWwQMLoUEy6pk GTRPC4tSCDC8vSGswY0aqMCuJ4lZVQOKkDb/0riBy/tNxq28mOhPvGONL/Hw7zej+uoq VQ328xZ0uLX4QCYsi7boXI5ubxYS1o4H6ikinFkd+bXkhvpoprtQMzEhTyhXv9XI+3Lt q4L/57RNnc52PfzATA4J4lVcl+m0D47VjktokV8/6xzJKEWIHsJpX85vCPpDkflJfB+d toGHDYadJI0g2y+MLVw99p6U17fHPnDEd3u7eZk5r2AI9jB+6YDvRLJBwlCT3FAy+dJD kYFA== X-Forwarded-Encrypted: i=1; AJvYcCVRpRWFRHHHoVqfZOndo70XxOqVLi1GhejAHRXqZzDAWTaOlAJ4UWKxXLytFnkAs65jmmF7754=@dpdk.org X-Gm-Message-State: AOJu0YwGqqop12D4d/vLVY+wxgxACc0tAf+0NFkU8gTXgdWR1qrHMqiO MgHYAvtU/IFJFOeE+M9mCsRrm1BNbp4Ztg+/pXS12ZJvGK2iDXWFN0gw9yuTOpo= X-Google-Smtp-Source: AGHT+IFRwrnq8hx660YlgskYqhl6FJamEfyhvd4+lYZVJrWyL/I2qs7yjqTutDr4KW4iEe5a9z1qKw== X-Received: by 2002:a05:6e02:219d:b0:3a3:4175:79da with SMTP id e9e14a558f8ab-3a345173dfdmr50864675ab.13.1727470083508; Fri, 27 Sep 2024 13:48:03 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6db294533sm2036531a12.12.2024.09.27.13.48.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 13:48:03 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Konstantin Ananyev , Ray Kinsella Subject: [PATCH 08/16] bpf: fix free mismatch if convert fails Date: Fri, 27 Sep 2024 13:45:44 -0700 Message-ID: <20240927204742.546164-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927204742.546164-1-stephen@networkplumber.org> References: <20240927204742.546164-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