From 7e5949771011a4a5ee071fe2f2d2dac70f7e5a50 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Sun, 3 Jul 2022 01:18:18 +0200 Subject: Update to 5.18.8 - Drop one patch that's included in it --- .../io_uring-reinstate-the-inflight-tracking.patch | 199 --------------------- 1 file changed, 199 deletions(-) delete mode 100644 debian/patches/bugfix/all/io_uring-reinstate-the-inflight-tracking.patch (limited to 'debian/patches/bugfix') diff --git a/debian/patches/bugfix/all/io_uring-reinstate-the-inflight-tracking.patch b/debian/patches/bugfix/all/io_uring-reinstate-the-inflight-tracking.patch deleted file mode 100644 index 4ec90b2bd..000000000 --- a/debian/patches/bugfix/all/io_uring-reinstate-the-inflight-tracking.patch +++ /dev/null @@ -1,199 +0,0 @@ -From: Jens Axboe -Date: Wed, 1 Jun 2022 23:57:02 -0600 -Subject: io_uring: reinstate the inflight tracking -Origin: https://git.kernel.org/linus/9cae36a094e7e9d6e5fe8b6dcd4642138b3eb0c7 -Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2022-1976 - -After some debugging, it was realized that we really do still need the -old inflight tracking for any file type that has io_uring_fops assigned. -If we don't, then trivial circular references will mean that we never get -the ctx cleaned up and hence it'll leak. - -Just bring back the inflight tracking, which then also means we can -eliminate the conditional dropping of the file when task_work is queued. - -Fixes: d5361233e9ab ("io_uring: drop the old style inflight file tracking") -Signed-off-by: Jens Axboe ---- - fs/io_uring.c | 82 +++++++++++++++++++++++++++++++++++++++------------------- - 1 file changed, 56 insertions(+), 26 deletions(-) - ---- a/fs/io_uring.c -+++ b/fs/io_uring.c -@@ -111,7 +111,8 @@ - IOSQE_IO_DRAIN | IOSQE_CQE_SKIP_SUCCESS) - - #define IO_REQ_CLEAN_FLAGS (REQ_F_BUFFER_SELECTED | REQ_F_NEED_CLEANUP | \ -- REQ_F_POLLED | REQ_F_CREDS | REQ_F_ASYNC_DATA) -+ REQ_F_POLLED | REQ_F_INFLIGHT | REQ_F_CREDS | \ -+ REQ_F_ASYNC_DATA) - - #define IO_TCTX_REFS_CACHE_NR (1U << 10) - -@@ -493,6 +494,7 @@ struct io_uring_task { - const struct io_ring_ctx *last; - struct io_wq *io_wq; - struct percpu_counter inflight; -+ atomic_t inflight_tracked; - atomic_t in_idle; - - spinlock_t task_lock; -@@ -1186,8 +1188,6 @@ static void io_clean_op(struct io_kiocb - static inline struct file *io_file_get_fixed(struct io_kiocb *req, int fd, - unsigned issue_flags); - static inline struct file *io_file_get_normal(struct io_kiocb *req, int fd); --static void io_drop_inflight_file(struct io_kiocb *req); --static bool io_assign_file(struct io_kiocb *req, unsigned int issue_flags); - static void __io_queue_sqe(struct io_kiocb *req); - static void io_rsrc_put_work(struct work_struct *work); - -@@ -1435,9 +1435,29 @@ static bool io_match_task(struct io_kioc - bool cancel_all) - __must_hold(&req->ctx->timeout_lock) - { -+ struct io_kiocb *req; -+ - if (task && head->task != task) - return false; -- return cancel_all; -+ if (cancel_all) -+ return true; -+ -+ io_for_each_link(req, head) { -+ if (req->flags & REQ_F_INFLIGHT) -+ return true; -+ } -+ return false; -+} -+ -+static bool io_match_linked(struct io_kiocb *head) -+{ -+ struct io_kiocb *req; -+ -+ io_for_each_link(req, head) { -+ if (req->flags & REQ_F_INFLIGHT) -+ return true; -+ } -+ return false; - } - - /* -@@ -1447,9 +1467,24 @@ static bool io_match_task(struct io_kioc - static bool io_match_task_safe(struct io_kiocb *head, struct task_struct *task, - bool cancel_all) - { -+ bool matched; -+ - if (task && head->task != task) - return false; -- return cancel_all; -+ if (cancel_all) -+ return true; -+ -+ if (head->flags & REQ_F_LINK_TIMEOUT) { -+ struct io_ring_ctx *ctx = head->ctx; -+ -+ /* protect against races with linked timeouts */ -+ spin_lock_irq(&ctx->timeout_lock); -+ matched = io_match_linked(head); -+ spin_unlock_irq(&ctx->timeout_lock); -+ } else { -+ matched = io_match_linked(head); -+ } -+ return matched; - } - - static inline bool req_has_async_data(struct io_kiocb *req) -@@ -1608,6 +1643,14 @@ static inline bool io_req_ffs_set(struct - return req->flags & REQ_F_FIXED_FILE; - } - -+static inline void io_req_track_inflight(struct io_kiocb *req) -+{ -+ if (!(req->flags & REQ_F_INFLIGHT)) { -+ req->flags |= REQ_F_INFLIGHT; -+ atomic_inc(¤t->io_uring->inflight_tracked); -+ } -+} -+ - static struct io_kiocb *__io_prep_linked_timeout(struct io_kiocb *req) - { - if (WARN_ON_ONCE(!req->link)) -@@ -2516,8 +2559,6 @@ static void io_req_task_work_add(struct - - WARN_ON_ONCE(!tctx); - -- io_drop_inflight_file(req); -- - spin_lock_irqsave(&tctx->task_lock, flags); - if (priority) - wq_list_add_tail(&req->io_task_work.node, &tctx->prior_task_list); -@@ -5869,10 +5910,6 @@ static int io_poll_check_events(struct i - - if (!req->result) { - struct poll_table_struct pt = { ._key = req->apoll_events }; -- unsigned flags = locked ? 0 : IO_URING_F_UNLOCKED; -- -- if (unlikely(!io_assign_file(req, flags))) -- return -EBADF; - req->result = vfs_poll(req->file, &pt) & req->apoll_events; - } - -@@ -7097,6 +7134,11 @@ static void io_clean_op(struct io_kiocb - kfree(req->apoll); - req->apoll = NULL; - } -+ if (req->flags & REQ_F_INFLIGHT) { -+ struct io_uring_task *tctx = req->task->io_uring; -+ -+ atomic_dec(&tctx->inflight_tracked); -+ } - if (req->flags & REQ_F_CREDS) - put_cred(req->creds); - if (req->flags & REQ_F_ASYNC_DATA) { -@@ -7393,19 +7435,6 @@ out: - return file; - } - --/* -- * Drop the file for requeue operations. Only used of req->file is the -- * io_uring descriptor itself. -- */ --static void io_drop_inflight_file(struct io_kiocb *req) --{ -- if (unlikely(req->flags & REQ_F_INFLIGHT)) { -- fput(req->file); -- req->file = NULL; -- req->flags &= ~REQ_F_INFLIGHT; -- } --} -- - static struct file *io_file_get_normal(struct io_kiocb *req, int fd) - { - struct file *file = fget(fd); -@@ -7414,7 +7443,7 @@ static struct file *io_file_get_normal(s - - /* we don't allow fixed io_uring files */ - if (file && file->f_op == &io_uring_fops) -- req->flags |= REQ_F_INFLIGHT; -+ io_req_track_inflight(req); - return file; - } - -@@ -9211,6 +9240,7 @@ static __cold int io_uring_alloc_task_co - xa_init(&tctx->xa); - init_waitqueue_head(&tctx->wait); - atomic_set(&tctx->in_idle, 0); -+ atomic_set(&tctx->inflight_tracked, 0); - task->io_uring = tctx; - spin_lock_init(&tctx->task_lock); - INIT_WQ_LIST(&tctx->task_list); -@@ -10402,7 +10432,7 @@ static __cold void io_uring_clean_tctx(s - static s64 tctx_inflight(struct io_uring_task *tctx, bool tracked) - { - if (tracked) -- return 0; -+ return atomic_read(&tctx->inflight_tracked); - return percpu_counter_sum(&tctx->inflight); - } - -- cgit v1.2.3 From bd191a253a15ac7279407d621c21f70eb4277337 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 5 Jul 2022 17:18:13 +0200 Subject: tools/bpf, tools/perf: Update for init_disassemble_info() API change In binutils 2.38.50, the init_disassemble_info() function in libopcodes takes an extra parameter. This only affects custom builds, not package builds, because we do not allow bpftool or perf to be linked with libbfd (and implicitly, not with libopcodes either). --- debian/changelog | 2 + ...m-fix-compilation-error-with-new-binutils.patch | 94 ++++++++++++++ ...l-fix-compilation-error-with-new-binutils.patch | 142 +++++++++++++++++++++ ...est-for-init_disassemble_info-api-changes.patch | 96 ++++++++++++++ ...sm-compat.h-to-handle-version-differences.patch | 87 +++++++++++++ .../all/tools-perf-fix-build-without-libbfd.patch | 26 ++++ ...f-fix-compilation-error-with-new-binutils.patch | 101 +++++++++++++++ debian/patches/series | 6 + 8 files changed, 554 insertions(+) create mode 100644 debian/patches/bugfix/all/tools-bpf_jit_disasm-fix-compilation-error-with-new-binutils.patch create mode 100644 debian/patches/bugfix/all/tools-bpftool-fix-compilation-error-with-new-binutils.patch create mode 100644 debian/patches/bugfix/all/tools-build-add-feature-test-for-init_disassemble_info-api-changes.patch create mode 100644 debian/patches/bugfix/all/tools-include-add-dis-asm-compat.h-to-handle-version-differences.patch create mode 100644 debian/patches/bugfix/all/tools-perf-fix-build-without-libbfd.patch create mode 100644 debian/patches/bugfix/all/tools-perf-fix-compilation-error-with-new-binutils.patch (limited to 'debian/patches/bugfix') diff --git a/debian/changelog b/debian/changelog index 7a3fa30e6..d0da92366 100644 --- a/debian/changelog +++ b/debian/changelog @@ -290,6 +290,8 @@ linux (5.18.8-1) UNRELEASED; urgency=medium * Bump ABI to 3 * Disable SECURITY_LOCKDOWN_LSM and MODULE_SIG where we don't sign code (Closes: #825141) + * tools/bpf, tools/perf: Update for init_disassemble_info() API change in + binutils 2.38.50 -- Ben Hutchings Mon, 20 Jun 2022 12:48:13 +0200 diff --git a/debian/patches/bugfix/all/tools-bpf_jit_disasm-fix-compilation-error-with-new-binutils.patch b/debian/patches/bugfix/all/tools-bpf_jit_disasm-fix-compilation-error-with-new-binutils.patch new file mode 100644 index 000000000..439b31bf0 --- /dev/null +++ b/debian/patches/bugfix/all/tools-bpf_jit_disasm-fix-compilation-error-with-new-binutils.patch @@ -0,0 +1,94 @@ +From: Andres Freund +Subject: [4/5] tools bpf_jit_disasm: Fix compilation error with new binutils +Date: Sun, 3 Jul 2022 14:25:50 -0700 +Origin: https://lore.kernel.org/lkml/20220703212551.1114923-5-andres@anarazel.de/ + +binutils changed the signature of init_disassemble_info(), which now causes +compilation to fail for tools/bpf/bpf_jit_disasm.c, e.g. on debian +unstable. Relevant binutils commit: +https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=60a3da00bd5407f07 + +Wire up the feature test and switch to init_disassemble_info_compat(), +which were introduced in prior commits, fixing the compilation failure. + +I verified that bpf_jit_disasm can still disassemble bpf programs, both +with the old and new dis-asm.h API. With old binutils there's no change in +output before/after this patch. When comparing the output from old +binutils (2.35) to new bintuils with the patch (upstream snapshot) there +are a few output differences, but they are unrelated to this patch. An +example hunk is: + f4: mov %r14,%rsi + f7: mov %r15,%rdx + fa: mov $0x2a,%ecx +- ff: callq 0xffffffffea8c4988 ++ ff: call 0xffffffffea8c4988 + 104: test %rax,%rax + 107: jge 0x0000000000000110 + 109: xor %eax,%eax +- 10b: jmpq 0x0000000000000073 ++ 10b: jmp 0x0000000000000073 + 110: cmp $0x16,%rax + +However, I had to use an older kernel to generate the bpf_jit_enabled = 2 +output, as that has been broken since 5.18 / 1022a5498f6f: +https://lore.kernel.org/20220703030210.pmjft7qc2eajzi6c@alap3.anarazel.de + +Cc: Alexei Starovoitov +Cc: Daniel Borkmann +Cc: Sedat Dilek +Cc: Quentin Monnet +Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.anarazel.de +Signed-off-by: Andres Freund +--- + tools/bpf/Makefile | 7 +++++-- + tools/bpf/bpf_jit_disasm.c | 5 ++++- + 2 files changed, 9 insertions(+), 3 deletions(-) + +diff --git a/tools/bpf/Makefile b/tools/bpf/Makefile +index b11cfc86a3d0..9c4e61c3a92b 100644 +--- a/tools/bpf/Makefile ++++ b/tools/bpf/Makefile +@@ -34,8 +34,8 @@ else + endif + + FEATURE_USER = .bpf +-FEATURE_TESTS = libbfd disassembler-four-args +-FEATURE_DISPLAY = libbfd disassembler-four-args ++FEATURE_TESTS = libbfd disassembler-four-args disassembler-init-styled ++FEATURE_DISPLAY = libbfd disassembler-four-args disassembler-init-styled + + check_feat := 1 + NON_CHECK_FEAT_TARGETS := clean bpftool_clean runqslower_clean resolve_btfids_clean +@@ -56,6 +56,9 @@ endif + ifeq ($(feature-disassembler-four-args), 1) + CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE + endif ++ifeq ($(feature-disassembler-init-styled), 1) ++CFLAGS += -DDISASM_INIT_STYLED ++endif + + $(OUTPUT)%.yacc.c: $(srctree)/tools/bpf/%.y + $(QUIET_BISON)$(YACC) -o $@ -d $< +diff --git a/tools/bpf/bpf_jit_disasm.c b/tools/bpf/bpf_jit_disasm.c +index c8ae95804728..a90a5d110f92 100644 +--- a/tools/bpf/bpf_jit_disasm.c ++++ b/tools/bpf/bpf_jit_disasm.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + + #define CMD_ACTION_SIZE_BUFFER 10 + #define CMD_ACTION_READ_ALL 3 +@@ -64,7 +65,9 @@ static void get_asm_insns(uint8_t *image, size_t len, int opcodes) + assert(bfdf); + assert(bfd_check_format(bfdf, bfd_object)); + +- init_disassemble_info(&info, stdout, (fprintf_ftype) fprintf); ++ init_disassemble_info_compat(&info, stdout, ++ (fprintf_ftype) fprintf, ++ fprintf_styled); + info.arch = bfd_get_arch(bfdf); + info.mach = bfd_get_mach(bfdf); + info.buffer = image; diff --git a/debian/patches/bugfix/all/tools-bpftool-fix-compilation-error-with-new-binutils.patch b/debian/patches/bugfix/all/tools-bpftool-fix-compilation-error-with-new-binutils.patch new file mode 100644 index 000000000..2a9c043c6 --- /dev/null +++ b/debian/patches/bugfix/all/tools-bpftool-fix-compilation-error-with-new-binutils.patch @@ -0,0 +1,142 @@ +From: Andres Freund +Subject: [PATCH v2 5/5] tools bpftool: Fix compilation error with new binutils +Date: Sun, 3 Jul 2022 14:25:51 -0700 +Origin: https://lore.kernel.org/lkml/20220703212551.1114923-6-andres@anarazel.de/ + +binutils changed the signature of init_disassemble_info(), which now causes +compilation to fail for tools/bpf/bpftool/jit_disasm.c, e.g. on debian +unstable. Relevant binutils commit: +https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=60a3da00bd5407f07 + +Wire up the feature test and switch to init_disassemble_info_compat(), +which were introduced in prior commits, fixing the compilation failure. + +I verified that bpftool can still disassemble bpf programs, both with an +old and new dis-asm.h API. There are no output changes for plain and json +formats. When comparing the output from old binutils (2.35) +to new bintuils with the patch (upstream snapshot) there are a few output +differences, but they are unrelated to this patch. An example hunk is: + 2f: pop %r14 + 31: pop %r13 + 33: pop %rbx +- 34: leaveq +- 35: retq ++ 34: leave ++ 35: ret + +Cc: Alexei Starovoitov +Cc: Sedat Dilek +Cc: Quentin Monnet +Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.anarazel.de +Signed-off-by: Andres Freund +--- + tools/bpf/bpftool/Makefile | 7 ++++-- + tools/bpf/bpftool/jit_disasm.c | 42 +++++++++++++++++++++++++++------- + 2 files changed, 39 insertions(+), 10 deletions(-) + +diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile +index c6d2c77d0252..62195118d377 100644 +--- a/tools/bpf/bpftool/Makefile ++++ b/tools/bpf/bpftool/Makefile +@@ -93,9 +93,9 @@ INSTALL ?= install + RM ?= rm -f + + FEATURE_USER = .bpftool +-FEATURE_TESTS = libbfd disassembler-four-args zlib libcap \ ++FEATURE_TESTS = libbfd disassembler-four-args disassembler-init-styled zlib libcap \ + clang-bpf-co-re +-FEATURE_DISPLAY = libbfd disassembler-four-args zlib libcap \ ++FEATURE_DISPLAY = libbfd disassembler-four-args disassembler-init-styled zlib libcap \ + clang-bpf-co-re + + check_feat := 1 +@@ -117,6 +117,9 @@ endif + ifeq ($(feature-disassembler-four-args), 1) + CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE + endif ++ifeq ($(feature-disassembler-init-styled), 1) ++ CFLAGS += -DDISASM_INIT_STYLED ++endif + + LIBS = $(LIBBPF) -lelf -lz + LIBS_BOOTSTRAP = $(LIBBPF_BOOTSTRAP) -lelf -lz +diff --git a/tools/bpf/bpftool/jit_disasm.c b/tools/bpf/bpftool/jit_disasm.c +index 24734f2249d6..aaf99a0168c9 100644 +--- a/tools/bpf/bpftool/jit_disasm.c ++++ b/tools/bpf/bpftool/jit_disasm.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + #include "json_writer.h" + #include "main.h" +@@ -39,15 +40,12 @@ static void get_exec_path(char *tpath, size_t size) + } + + static int oper_count; +-static int fprintf_json(void *out, const char *fmt, ...) ++static int printf_json(void *out, const char *fmt, va_list ap) + { +- va_list ap; + char *s; + int err; + +- va_start(ap, fmt); + err = vasprintf(&s, fmt, ap); +- va_end(ap); + if (err < 0) + return -1; + +@@ -73,6 +71,32 @@ static int fprintf_json(void *out, const char *fmt, ...) + return 0; + } + ++static int fprintf_json(void *out, const char *fmt, ...) ++{ ++ va_list ap; ++ int r; ++ ++ va_start(ap, fmt); ++ r = printf_json(out, fmt, ap); ++ va_end(ap); ++ ++ return r; ++} ++ ++static int fprintf_json_styled(void *out, ++ enum disassembler_style style __maybe_unused, ++ const char *fmt, ...) ++{ ++ va_list ap; ++ int r; ++ ++ va_start(ap, fmt); ++ r = printf_json(out, fmt, ap); ++ va_end(ap); ++ ++ return r; ++} ++ + void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes, + const char *arch, const char *disassembler_options, + const struct btf *btf, +@@ -99,11 +123,13 @@ void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes, + assert(bfd_check_format(bfdf, bfd_object)); + + if (json_output) +- init_disassemble_info(&info, stdout, +- (fprintf_ftype) fprintf_json); ++ init_disassemble_info_compat(&info, stdout, ++ (fprintf_ftype) fprintf_json, ++ fprintf_json_styled); + else +- init_disassemble_info(&info, stdout, +- (fprintf_ftype) fprintf); ++ init_disassemble_info_compat(&info, stdout, ++ (fprintf_ftype) fprintf, ++ fprintf_styled); + + /* Update architecture info for offload. */ + if (arch) { diff --git a/debian/patches/bugfix/all/tools-build-add-feature-test-for-init_disassemble_info-api-changes.patch b/debian/patches/bugfix/all/tools-build-add-feature-test-for-init_disassemble_info-api-changes.patch new file mode 100644 index 000000000..1a0ea2aa4 --- /dev/null +++ b/debian/patches/bugfix/all/tools-build-add-feature-test-for-init_disassemble_info-api-changes.patch @@ -0,0 +1,96 @@ +From: Andres Freund +Subject: [1/5] tools build: add feature test for init_disassemble_info API changes +Date: Sun, 3 Jul 2022 14:25:47 -0700 +Origin: https://lore.kernel.org/lkml/20220703212551.1114923-2-andres@anarazel.de/ + +binutils changed the signature of init_disassemble_info(), which now causes +compilation failures for tools/{perf,bpf}, e.g. on debian unstable. +Relevant binutils commit: +https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=60a3da00bd5407f07 + +This commit adds a feature test to detect the new signature. Subsequent +commits will use it to fix the build failures. + +Cc: Alexei Starovoitov +Cc: Arnaldo Carvalho de Melo +Cc: Sedat Dilek +Cc: Quentin Monnet +Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.anarazel.de +Signed-off-by: Andres Freund +--- + tools/build/Makefile.feature | 4 +++- + tools/build/feature/Makefile | 4 ++++ + tools/build/feature/test-all.c | 4 ++++ + tools/build/feature/test-disassembler-init-styled.c | 13 +++++++++++++ + 4 files changed, 24 insertions(+), 1 deletion(-) + create mode 100644 tools/build/feature/test-disassembler-init-styled.c + +--- a/tools/build/Makefile.feature ++++ b/tools/build/Makefile.feature +@@ -70,6 +70,7 @@ FEATURE_TESTS_BASIC := + libaio \ + libzstd \ + disassembler-four-args \ ++ disassembler-init-styled \ + file-handle + + # FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list +@@ -131,7 +132,8 @@ FEATURE_DISPLAY ?= \ + bpf \ + libaio \ + libzstd \ +- disassembler-four-args ++ disassembler-four-args \ ++ disassembler-init-styled + + # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features. + # If in the future we need per-feature checks/flags for features not +--- a/tools/build/feature/Makefile ++++ b/tools/build/feature/Makefile +@@ -18,6 +18,7 @@ FILES= + test-libbfd.bin \ + test-libbfd-buildid.bin \ + test-disassembler-four-args.bin \ ++ test-disassembler-init-styled.bin \ + test-reallocarray.bin \ + test-libbfd-liberty.bin \ + test-libbfd-liberty-z.bin \ +@@ -243,6 +244,9 @@ $(OUTPUT)test-libbfd-buildid.bin: + $(OUTPUT)test-disassembler-four-args.bin: + $(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes + ++$(OUTPUT)test-disassembler-init-styled.bin: ++ $(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes ++ + $(OUTPUT)test-reallocarray.bin: + $(BUILD) + +--- a/tools/build/feature/test-all.c ++++ b/tools/build/feature/test-all.c +@@ -166,6 +166,10 @@ + # include "test-disassembler-four-args.c" + #undef main + ++#define main main_test_disassembler_init_styled ++# include "test-disassembler-init-styled.c" ++#undef main ++ + #define main main_test_libzstd + # include "test-libzstd.c" + #undef main +--- /dev/null ++++ b/tools/build/feature/test-disassembler-init-styled.c +@@ -0,0 +1,13 @@ ++// SPDX-License-Identifier: GPL-2.0 ++#include ++#include ++ ++int main(void) ++{ ++ struct disassemble_info info; ++ ++ init_disassemble_info(&info, stdout, ++ NULL, NULL); ++ ++ return 0; ++} diff --git a/debian/patches/bugfix/all/tools-include-add-dis-asm-compat.h-to-handle-version-differences.patch b/debian/patches/bugfix/all/tools-include-add-dis-asm-compat.h-to-handle-version-differences.patch new file mode 100644 index 000000000..026e69dc4 --- /dev/null +++ b/debian/patches/bugfix/all/tools-include-add-dis-asm-compat.h-to-handle-version-differences.patch @@ -0,0 +1,87 @@ +From: Andres Freund +Subject: [2/5] tools include: add dis-asm-compat.h to handle version differences +Date: Sun, 3 Jul 2022 14:25:48 -0700 +Origin: https://lore.kernel.org/lkml/20220703212551.1114923-3-andres@anarazel.de/ + +binutils changed the signature of init_disassemble_info(), which now causes +compilation failures for tools/{perf,bpf}, e.g. on debian unstable. +Relevant binutils commit: +https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=60a3da00bd5407f07 + +This commit introduces a wrapper for init_disassemble_info(), to avoid +spreading #ifdef DISASM_INIT_STYLED to a bunch of places. Subsequent +commits will use it to fix the build failures. + +It likely is worth adding a wrapper for disassember(), to avoid the already +existing DISASM_FOUR_ARGS_SIGNATURE ifdefery. + +Cc: Alexei Starovoitov +Cc: Arnaldo Carvalho de Melo +Cc: Sedat Dilek +Cc: Quentin Monnet +Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.anarazel.de +Signed-off-by: Andres Freund +--- + tools/include/tools/dis-asm-compat.h | 53 ++++++++++++++++++++++++++++ + 1 file changed, 53 insertions(+) + create mode 100644 tools/include/tools/dis-asm-compat.h + +diff --git a/tools/include/tools/dis-asm-compat.h b/tools/include/tools/dis-asm-compat.h +new file mode 100644 +index 000000000000..d1d003ee3e2f +--- /dev/null ++++ b/tools/include/tools/dis-asm-compat.h +@@ -0,0 +1,53 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++#ifndef _TOOLS_DIS_ASM_COMPAT_H ++#define _TOOLS_DIS_ASM_COMPAT_H ++ ++#include ++#include ++#include ++ ++/* define types for older binutils version, to centralize ifdef'ery a bit */ ++#ifndef DISASM_INIT_STYLED ++enum disassembler_style {DISASSEMBLER_STYLE_NOT_EMPTY}; ++typedef int (*fprintf_styled_ftype) (void *, enum disassembler_style, const char*, ...); ++#endif ++ ++/* ++ * Trivial fprintf wrapper to be used as the fprintf_styled_func argument to ++ * init_disassemble_info_compat() when normal fprintf suffices. ++ */ ++static inline int fprintf_styled(void *out, ++ enum disassembler_style style __maybe_unused, ++ const char *fmt, ...) ++{ ++ va_list args; ++ int r; ++ ++ va_start(args, fmt); ++ r = vfprintf(out, fmt, args); ++ va_end(args); ++ ++ return r; ++} ++ ++/* ++ * Wrapper for init_disassemble_info() that hides version ++ * differences. Depending on binutils version and architecture either ++ * fprintf_func or fprintf_styled_func will be called. ++ */ ++static inline void init_disassemble_info_compat(struct disassemble_info *info, ++ void *stream, ++ fprintf_ftype unstyled_func, ++ fprintf_styled_ftype styled_func __maybe_unused) ++{ ++#ifdef DISASM_INIT_STYLED ++ init_disassemble_info(info, stream, ++ unstyled_func, ++ styled_func); ++#else ++ init_disassemble_info(info, stream, ++ unstyled_func); ++#endif ++} ++ ++#endif /* _TOOLS_DIS_ASM_COMPAT_H */ diff --git a/debian/patches/bugfix/all/tools-perf-fix-build-without-libbfd.patch b/debian/patches/bugfix/all/tools-perf-fix-build-without-libbfd.patch new file mode 100644 index 000000000..726bdfc47 --- /dev/null +++ b/debian/patches/bugfix/all/tools-perf-fix-build-without-libbfd.patch @@ -0,0 +1,26 @@ +From: Ben Hutchings +Date: Tue, 05 Jul 2022 18:02:28 +0200 +Subject: tools/perf: Fix build without libbfd + +Only include if we are using libbfd. + +Signed-off-by: Ben Hutchings +--- +--- a/tools/perf/util/annotate.c ++++ b/tools/perf/util/annotate.c +@@ -41,7 +41,6 @@ + #include + #include + #include +-#include + + /* FIXME: For the HE_COLORSET */ + #include "ui/browser.h" +@@ -1721,6 +1720,7 @@ fallback: + #include + #include + #include ++#include + + static int symbol__disassemble_bpf(struct symbol *sym, + struct annotate_args *args) diff --git a/debian/patches/bugfix/all/tools-perf-fix-compilation-error-with-new-binutils.patch b/debian/patches/bugfix/all/tools-perf-fix-compilation-error-with-new-binutils.patch new file mode 100644 index 000000000..e24915fe0 --- /dev/null +++ b/debian/patches/bugfix/all/tools-perf-fix-compilation-error-with-new-binutils.patch @@ -0,0 +1,101 @@ +From: Andres Freund +Subject: [3/5] tools perf: Fix compilation error with new binutils +Date: Sun, 3 Jul 2022 14:25:49 -0700 +Origin: https://lore.kernel.org/lkml/20220703212551.1114923-4-andres@anarazel.de/ + +binutils changed the signature of init_disassemble_info(), which now causes +compilation failures for tools/perf/util/annotate.c, e.g. on debian +unstable. Relevant binutils commit: +https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=60a3da00bd5407f07 + +Wire up the feature test and switch to init_disassemble_info_compat(), +which were introduced in prior commits, fixing the compilation failure. + +I verified that perf can still disassemble bpf programs by using bpftrace +under load, recording a perf trace, and then annotating the bpf "function" +with and without the changes. With old binutils there's no change in output +before/after this patch. When comparing the output from old binutils (2.35) +to new bintuils with the patch (upstream snapshot) there are a few output +differences, but they are unrelated to this patch. An example hunk is: + + 1.15 : 55:mov %rbp,%rdx + 0.00 : 58:add $0xfffffffffffffff8,%rdx + 0.00 : 5c:xor %ecx,%ecx +- 1.03 : 5e:callq 0xffffffffe12aca3c ++ 1.03 : 5e:call 0xffffffffe12aca3c + 0.00 : 63:xor %eax,%eax +- 2.18 : 65:leaveq +- 2.82 : 66:retq ++ 2.18 : 65:leave ++ 2.82 : 66:ret + +Cc: Arnaldo Carvalho de Melo +Cc: Sedat Dilek +Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.anarazel.de +Signed-off-by: Andres Freund +--- + tools/perf/Makefile.config | 8 ++++++++ + tools/perf/util/annotate.c | 7 ++++--- + 2 files changed, 12 insertions(+), 3 deletions(-) + +--- a/tools/perf/Makefile.config ++++ b/tools/perf/Makefile.config +@@ -298,6 +298,7 @@ FEATURE_CHECK_LDFLAGS-libpython := $(PYT + FEATURE_CHECK_LDFLAGS-libaio = -lrt + + FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl ++FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl + + CORE_CFLAGS += -fno-omit-frame-pointer + CORE_CFLAGS += -ggdb3 +@@ -877,13 +878,16 @@ ifndef NO_LIBBFD + ifeq ($(feature-libbfd-liberty), 1) + EXTLIBS += -lbfd -lopcodes -liberty + FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl ++ FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -ldl + else + ifeq ($(feature-libbfd-liberty-z), 1) + EXTLIBS += -lbfd -lopcodes -liberty -lz + FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl ++ FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -lz -ldl + endif + endif + $(call feature_check,disassembler-four-args) ++ $(call feature_check,disassembler-init-styled) + endif + + ifeq ($(feature-libbfd-buildid), 1) +@@ -997,6 +1001,10 @@ ifeq ($(feature-disassembler-four-args), + CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE + endif + ++ifeq ($(feature-disassembler-init-styled), 1) ++ CFLAGS += -DDISASM_INIT_STYLED ++endif ++ + ifeq (${IS_64_BIT}, 1) + ifndef NO_PERF_READ_VDSO32 + $(call feature_check,compile-32) +--- a/tools/perf/util/annotate.c ++++ b/tools/perf/util/annotate.c +@@ -41,6 +41,7 @@ + #include + #include + #include ++#include + + /* FIXME: For the HE_COLORSET */ + #include "ui/browser.h" +@@ -1762,9 +1763,9 @@ static int symbol__disassemble_bpf(struc + ret = errno; + goto out; + } +- init_disassemble_info(&info, s, +- (fprintf_ftype) fprintf); +- ++ init_disassemble_info_compat(&info, s, ++ (fprintf_ftype) fprintf, ++ fprintf_styled); + info.arch = bfd_get_arch(bfdf); + info.mach = bfd_get_mach(bfdf); + diff --git a/debian/patches/series b/debian/patches/series index 0996d4691..d967e708b 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -115,5 +115,11 @@ bugfix/all/tools-perf-pmu-events-fix-reproducibility.patch bugfix/all/tools-include-uapi-fix-errno.h.patch bugfix/all/libapi-define-_fortify_source-as-2-not-empty.patch bugfix/all/tools-perf-fix-missing-ldflags-for-some-programs.patch +bugfix/all/tools-build-add-feature-test-for-init_disassemble_info-api-changes.patch +bugfix/all/tools-include-add-dis-asm-compat.h-to-handle-version-differences.patch +bugfix/all/tools-perf-fix-compilation-error-with-new-binutils.patch +bugfix/all/tools-bpf_jit_disasm-fix-compilation-error-with-new-binutils.patch +bugfix/all/tools-bpftool-fix-compilation-error-with-new-binutils.patch +bugfix/all/tools-perf-fix-build-without-libbfd.patch # ABI maintenance -- cgit v1.2.3 From 689c889bc28c2cb88a532410c81e412c1a06571f Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 5 Jul 2022 17:22:15 +0200 Subject: tools/perf: Fix "unused parameter" warning "tools/perf: pmu-events: Fix reproducibility" adds a callback function which does not use all its parameters. Since perf wrongly defaults to using -Werror, this breaks custom builds. --- debian/changelog | 2 ++ .../all/tools-perf-pmu-events-fix-reproducibility.patch | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'debian/patches/bugfix') diff --git a/debian/changelog b/debian/changelog index d0da92366..7216fec63 100644 --- a/debian/changelog +++ b/debian/changelog @@ -292,6 +292,8 @@ linux (5.18.8-1) UNRELEASED; urgency=medium (Closes: #825141) * tools/bpf, tools/perf: Update for init_disassemble_info() API change in binutils 2.38.50 + * tools/perf: Fix "unused parameter" warning introduced by "tools/perf: + pmu-events: Fix reproducibility" -- Ben Hutchings Mon, 20 Jun 2022 12:48:13 +0200 diff --git a/debian/patches/bugfix/all/tools-perf-pmu-events-fix-reproducibility.patch b/debian/patches/bugfix/all/tools-perf-pmu-events-fix-reproducibility.patch index f6deb46bf..bd1bcd490 100644 --- a/debian/patches/bugfix/all/tools-perf-pmu-events-fix-reproducibility.patch +++ b/debian/patches/bugfix/all/tools-perf-pmu-events-fix-reproducibility.patch @@ -19,7 +19,7 @@ Signed-off-by: Ben Hutchings --- --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c -@@ -50,6 +50,18 @@ +@@ -51,6 +51,18 @@ #include "json.h" #include "pmu-events.h" @@ -38,13 +38,14 @@ Signed-off-by: Ben Hutchings int verbose; char *prog; -@@ -971,6 +983,78 @@ static int get_maxfds(void) +@@ -981,6 +993,79 @@ static int get_maxfds(void) */ static FILE *eventsfp; static char *mapfile; +static struct ordered_ftw_state *ordered_ftw_state; + -+static int ordered_ftw_add(const char *fpath, const struct stat *sb, ++static int ordered_ftw_add(const char *fpath, ++ const struct stat *sb __maybe_unused, + int typeflag, struct FTW *ftwbuf) +{ + struct ordered_ftw_state *state = ordered_ftw_state; @@ -117,7 +118,7 @@ Signed-off-by: Ben Hutchings static int is_leaf_dir(const char *fpath) { -@@ -1023,19 +1107,19 @@ static int is_json_file(const char *name +@@ -1033,19 +1118,19 @@ static int is_json_file(const char *name return 0; } @@ -140,7 +141,7 @@ Signed-off-by: Ben Hutchings int typeflag, struct FTW *ftwbuf) { char *tblname, *bname; -@@ -1065,9 +1149,9 @@ static int process_one_file(const char * +@@ -1075,9 +1160,9 @@ static int process_one_file(const char * } else bname = (char *) fpath + ftwbuf->base; @@ -152,7 +153,7 @@ Signed-off-by: Ben Hutchings /* base dir or too deep */ if (level == 0 || level > 4) -@@ -1241,21 +1325,21 @@ int main(int argc, char *argv[]) +@@ -1251,21 +1336,21 @@ int main(int argc, char *argv[]) */ maxfds = get_maxfds(); -- cgit v1.2.3 From 5c810a8de2e59655f52ea6ef54c88ee4de68468f Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 7 Jul 2022 19:10:21 +0200 Subject: [amd64,arm64,armhf] wireguard: Clear keys after suspend despite CONFIG_ANDROID=y WireGuard assumes that CONFIG_ANDROID implies Android power management, i.e. user-space suspending the system automatically at short intervals, and so does not clear keys after a suspend/resume cycle. Debian systems don't do that kind of power management but we do set CONFIG_ANDROID on some architectures as a dependency of Binder. Remove this test that does the wrong thing for us. --- debian/changelog | 2 ++ .../all/wireguard-ignore-config_android.patch | 29 ++++++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 32 insertions(+) create mode 100644 debian/patches/bugfix/all/wireguard-ignore-config_android.patch (limited to 'debian/patches/bugfix') diff --git a/debian/changelog b/debian/changelog index d36a32d48..18d24b12c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -294,6 +294,8 @@ linux (5.18.8-1) UNRELEASED; urgency=medium binutils 2.38.50 * tools/perf: Fix "unused parameter" warning introduced by "tools/perf: pmu-events: Fix reproducibility" + * [amd64,arm64,armhf] wireguard: Clear keys after suspend despite + CONFIG_ANDROID=y [ Vincent Blut ] * [armhf] drivers/crypto/caam: Enable CRYPTO_DEV_FSL_CAAM as module diff --git a/debian/patches/bugfix/all/wireguard-ignore-config_android.patch b/debian/patches/bugfix/all/wireguard-ignore-config_android.patch new file mode 100644 index 000000000..4c1cb9491 --- /dev/null +++ b/debian/patches/bugfix/all/wireguard-ignore-config_android.patch @@ -0,0 +1,29 @@ +From: Ben Hutchings +Date: Thu, 07 Jul 2022 18:58:43 +0200 +Subject: wireguard: Clear keys after suspend despite CONFIG_ANDROID=y +Forwarded: not-needed + +WireGuard assumes that CONFIG_ANDROID implies Android power +management, i.e. user-space suspending the system automatically at +short intervals, and so does not clear keys after a suspend/resume +cycle. Debian systems don't do that kind of power management but we +do set CONFIG_ANDROID on some architectures as a dependency of Binder. + +In 5.20, CONFIG_PM_USERSPACE_AUTOSLEEP will be introduced to tell the +kernel that this kind of power management is in use, and +CONFIG_ANDROID will be removed. For now, remove this one test that +does the wrong thing for us. + +References: https://lwn.net/Articles/899743/ +--- +--- a/drivers/net/wireguard/device.c ++++ b/drivers/net/wireguard/device.c +@@ -69,7 +69,7 @@ static int wg_pm_notification(struct not + * its normal operation rather than as a somewhat rare event, then we + * don't actually want to clear keys. + */ +- if (IS_ENABLED(CONFIG_PM_AUTOSLEEP) || IS_ENABLED(CONFIG_ANDROID)) ++ if (IS_ENABLED(CONFIG_PM_AUTOSLEEP)) + return 0; + + if (action != PM_HIBERNATION_PREPARE && action != PM_SUSPEND_PREPARE) diff --git a/debian/patches/series b/debian/patches/series index d967e708b..550311549 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -79,6 +79,7 @@ features/x86/x86-make-x32-syscall-support-conditional.patch # Miscellaneous bug fixes bugfix/all/disable-some-marvell-phys.patch bugfix/all/fs-add-module_softdep-declarations-for-hard-coded-cr.patch +bugfix/all/wireguard-ignore-config_android.patch # Miscellaneous features -- cgit v1.2.3