Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package libbpf for openSUSE:Factory checked 
in at 2023-07-15 23:14:59
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libbpf (Old)
 and      /work/SRC/openSUSE:Factory/.libbpf.new.3193 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libbpf"

Sat Jul 15 23:14:59 2023 rev:17 rq:1098588 version:1.2.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/libbpf/libbpf.changes    2023-05-04 
17:09:32.256000684 +0200
+++ /work/SRC/openSUSE:Factory/.libbpf.new.3193/libbpf.changes  2023-07-15 
23:15:03.503479434 +0200
@@ -1,0 +2,10 @@
+Fri Jul 14 05:04:50 UTC 2023 - Shung-Hsi Yu <shung-hsi...@suse.com>
+
+- update to v1.2.2:
+  * fix a regression in perf tool caused by libbpf resetting its custom
+    catch-all SEC() handler on explicit bpf_program__set_type() call
+  * fix possible double-free in USDT-related libbpf code, which happens when
+    libbpf runs out of space in __bpf_usdt_specs map due to having too many
+    unique USDT specs
+
+-------------------------------------------------------------------

Old:
----
  libbpf-1.2.0.tar.gz

New:
----
  libbpf-1.2.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libbpf.spec ++++++
--- /var/tmp/diff_new_pack.FbRQcF/_old  2023-07-15 23:15:04.247483798 +0200
+++ /var/tmp/diff_new_pack.FbRQcF/_new  2023-07-15 23:15:04.251483822 +0200
@@ -19,7 +19,7 @@
 %define sover_major 1
 %define libname libbpf%{sover_major}
 Name:           libbpf
-Version:        1.2.0
+Version:        1.2.2
 Release:        0
 Summary:        C library for managing eBPF programs and maps
 License:        LGPL-2.1-only

++++++ libbpf-1.2.0.tar.gz -> libbpf-1.2.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libbpf-1.2.0/src/Makefile 
new/libbpf-1.2.2/src/Makefile
--- old/libbpf-1.2.0/src/Makefile       2023-04-20 21:01:06.000000000 +0200
+++ new/libbpf-1.2.2/src/Makefile       2023-07-12 01:38:33.000000000 +0200
@@ -10,7 +10,7 @@
 
 LIBBPF_MAJOR_VERSION := 1
 LIBBPF_MINOR_VERSION := 2
-LIBBPF_PATCH_VERSION := 0
+LIBBPF_PATCH_VERSION := 2
 LIBBPF_VERSION := 
$(LIBBPF_MAJOR_VERSION).$(LIBBPF_MINOR_VERSION).$(LIBBPF_PATCH_VERSION)
 LIBBPF_MAJMIN_VERSION := $(LIBBPF_MAJOR_VERSION).$(LIBBPF_MINOR_VERSION).0
 LIBBPF_MAP_VERSION := $(shell grep -oE '^LIBBPF_([0-9.]+)' libbpf.map | sort 
-rV | head -n1 | cut -d'_' -f2)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libbpf-1.2.0/src/libbpf.c 
new/libbpf-1.2.2/src/libbpf.c
--- old/libbpf-1.2.0/src/libbpf.c       2023-04-20 21:01:06.000000000 +0200
+++ new/libbpf-1.2.2/src/libbpf.c       2023-07-12 01:38:33.000000000 +0200
@@ -6133,7 +6133,11 @@
        if (main_prog == subprog)
                return 0;
        relos = libbpf_reallocarray(main_prog->reloc_desc, new_cnt, 
sizeof(*relos));
-       if (!relos)
+       /* if new count is zero, reallocarray can return a valid NULL result;
+        * in this case the previous pointer will be freed, so we *have to*
+        * reassign old pointer to the new value (even if it's NULL)
+        */
+       if (!relos && new_cnt)
                return -ENOMEM;
        if (subprog->nr_reloc)
                memcpy(relos + main_prog->nr_reloc, subprog->reloc_desc,
@@ -8501,7 +8505,8 @@
                return -EBUSY;
 
        insns = libbpf_reallocarray(prog->insns, new_insn_cnt, sizeof(*insns));
-       if (!insns) {
+       /* NULL is a valid return from reallocarray if the new count is zero */
+       if (!insns && new_insn_cnt) {
                pr_warn("prog '%s': failed to realloc prog code\n", prog->name);
                return -ENOMEM;
        }
@@ -8531,13 +8536,31 @@
        return prog->type;
 }
 
+static size_t custom_sec_def_cnt;
+static struct bpf_sec_def *custom_sec_defs;
+static struct bpf_sec_def custom_fallback_def;
+static bool has_custom_fallback_def;
+static int last_custom_sec_def_handler_id;
+
 int bpf_program__set_type(struct bpf_program *prog, enum bpf_prog_type type)
 {
        if (prog->obj->loaded)
                return libbpf_err(-EBUSY);
 
+       /* if type is not changed, do nothing */
+       if (prog->type == type)
+               return 0;
+
        prog->type = type;
-       prog->sec_def = NULL;
+
+       /* If a program type was changed, we need to reset associated SEC()
+        * handler, as it will be invalid now. The only exception is a generic
+        * fallback handler, which by definition is program type-agnostic and
+        * is a catch-all custom handler, optionally set by the application,
+        * so should be able to handle any type of BPF program.
+        */
+       if (prog->sec_def != &custom_fallback_def)
+               prog->sec_def = NULL;
        return 0;
 }
 
@@ -8712,13 +8735,6 @@
        SEC_DEF("sk_lookup",            SK_LOOKUP, BPF_SK_LOOKUP, 
SEC_ATTACHABLE),
 };
 
-static size_t custom_sec_def_cnt;
-static struct bpf_sec_def *custom_sec_defs;
-static struct bpf_sec_def custom_fallback_def;
-static bool has_custom_fallback_def;
-
-static int last_custom_sec_def_handler_id;
-
 int libbpf_register_prog_handler(const char *sec,
                                 enum bpf_prog_type prog_type,
                                 enum bpf_attach_type exp_attach_type,
@@ -8798,7 +8814,11 @@
 
        /* try to shrink the array, but it's ok if we couldn't */
        sec_defs = libbpf_reallocarray(custom_sec_defs, custom_sec_def_cnt, 
sizeof(*sec_defs));
-       if (sec_defs)
+       /* if new count is zero, reallocarray can return a valid NULL result;
+        * in this case the previous pointer will be freed, so we *have to*
+        * reassign old pointer to the new value (even if it's NULL)
+        */
+       if (sec_defs || custom_sec_def_cnt == 0)
                custom_sec_defs = sec_defs;
 
        return 0;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libbpf-1.2.0/src/usdt.c new/libbpf-1.2.2/src/usdt.c
--- old/libbpf-1.2.0/src/usdt.c 2023-04-20 21:01:06.000000000 +0200
+++ new/libbpf-1.2.2/src/usdt.c 2023-07-12 01:38:33.000000000 +0200
@@ -852,8 +852,11 @@
                 * system is so exhausted on memory, it's the least of user's
                 * concerns, probably.
                 * So just do our best here to return those IDs to usdt_manager.
+                * Another edge case when we can legitimately get NULL is when
+                * new_cnt is zero, which can happen in some edge cases, so we
+                * need to be careful about that.
                 */
-               if (new_free_ids) {
+               if (new_free_ids || new_cnt == 0) {
                        memcpy(new_free_ids + man->free_spec_cnt, 
usdt_link->spec_ids,
                               usdt_link->spec_cnt * 
sizeof(*usdt_link->spec_ids));
                        man->free_spec_ids = new_free_ids;

Reply via email to