[dm-devel] [PATCH 4/4] libmultipath: avoid cleanup __attribute__ with cancellation points

2022-10-11 Thread Benjamin Marzinski
the cleanup __attribute__ doesn't get run when a thread is cancelled, so it is only safe in cases where there aren't pthreads or no cancellation points happen in the code block after the variable needs cleaning up. Signed-off-by: Benjamin Marzinski --- libmultipath/configure.c |

[dm-devel] [PATCH 3/4] libmultipath: use regular array for field widths

2022-10-11 Thread Benjamin Marzinski
We know the size of these arrays, so we can just allocate them on the stack. Also, show_path() doesn't use the width, so don't initialize it in the first place. Signed-off-by: Benjamin Marzinski --- libmultipath/foreign.c| 5 ++-- libmultipath/libmultipath.version | 4 +--

[dm-devel] [PATCH 1/4] libmultipath: don't print garbage keywords

2022-10-11 Thread Benjamin Marzinski
If snprint_keyword() failed to correctly set up sbuf, don't print it. Instead, return an error. Signed-off-by: Benjamin Marzinski --- libmpathutil/parser.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libmpathutil/parser.c b/libmpathutil/parser.c index

[dm-devel] [PATCH 2/4] libmultipath: avoid STRBUF_ON_STACK with cancellation points

2022-10-11 Thread Benjamin Marzinski
STRBUF_ON_STACK() uses the cleanup __attribute__, which doesn't get run if a thread is cancelled. condlog() will call fprintf() when run under systemd, which is a cancellation point. The snprint function for the generic mutipath and generic path operations both call cancellation points. Also, the

[dm-devel] [PATCH 0/4] remove dangerous cleanup __attribute__ uses

2022-10-11 Thread Benjamin Marzinski
the cleanup __attribute__ is only run when a variable goes out of scope normally. It is not run on pthread cancellation. This means that multipathd could leak whatever resources were supposed to be cleaned up if the thread was cancelled in a function using variables with the cleanup __attribute__.

[dm-devel] [PATCH 4/4 v2] persistent-data: reduce lock contention while walking the btree

2022-10-11 Thread Mikulas Patocka
Hi Here I'm sending updated patch 4 that fixes hang on discard. We must not do the optimization in dm_btree_lookup_next. Mikulas From: Mikulas Patocka This patch reduces lock contention in btree walks. We modify the functions init_ro_wpin, exit_ro_spine and ro_step so that they use

[dm-devel] dm: Fix UAF in run_timer_softirq()

2022-10-11 Thread Luo Meng
From: Luo Meng When dm_resume() and dm_destroy() are concurrent, it will lead to UAF. One of the concurrency UAF can be shown as below: use free do_resume | __find_device_hash_cell | dm_get

[dm-devel] [dm-devel resend] dm mpath: fix UAF in multipath_message()

2022-10-11 Thread Luo Meng
From: Luo Meng If dm_get_device() create dd in multipath_message(), and then call table_deps() after dm_put_table_device(), it will lead to concurrency UAF bugs. One of the concurrency UAF can be shown as below: (USE)|(FREE)