lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <CAK8ByeLaE1xumns+g6EMYK1weRwBhyEKR8YpYjx4uQqohvPTzg@mail.gmail.com> Date: Sat, 9 Dec 2023 01:32:37 +0100 From: Łukasz Bartosik <lb@...ihalf.com> To: Jim Cromie <jim.cromie@...il.com> Cc: linux-kernel@...r.kernel.org, akpm@...ux-foundation.org, bleung@...gle.com, contact@...rsion.fr, daniel@...ll.ch, dianders@...omium.org, groeck@...gle.com, jbaron@...mai.com, john.ogness@...utronix.de, keescook@...omium.org, pmladek@...e.com, ppaalanen@...il.com, rostedt@...dmis.org, seanpaul@...omium.org, sergey.senozhatsky@...il.com, upstream@...ihalf.com, vincent.whitchurch@...s.com, yanivt@...gle.com, gregkh@...uxfoundation.org Subject: Re: [re: PATCH v2 00/15 - 10/11] dyndbg: move lock,unlock into ddebug_change, drop goto pt., 8 gru 2023 o 01:15 Jim Cromie <jim.cromie@...il.com> napisał(a): > > Signed-off-by: Jim Cromie <jim.cromie@...il.com> > --- > lib/dynamic_debug.c | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c > index fc903e90ea0d..b63429462d69 100644 > --- a/lib/dynamic_debug.c > +++ b/lib/dynamic_debug.c > @@ -537,6 +537,8 @@ static int ddebug_change(const struct ddebug_query *query, > struct ddebug_class_map *map = NULL; > int __outvar valid_class; > > + mutex_lock(&ddebug_lock); > + > /* search for matching ddebugs */ > list_for_each_entry(dt, &ddebug_tables, link) { > > @@ -625,6 +627,7 @@ static int ddebug_change(const struct ddebug_query *query, > if (nfound) > update_tr_default_dst(modifiers); > > + mutex_unlock(&ddebug_lock); > return nfound; > } > > @@ -932,23 +935,17 @@ static int ddebug_exec_query(char *query_string, const char *modname) > return -EINVAL; > } > > - mutex_lock(&ddebug_lock); > - I deliberately moved locking here from ddebug_change because ddebug_parse_flags calls read_T_args (when T flag is present) and this in turn calls find_tr_instance which uses global bitmap (tr.bmap). If we add that ddebug_proc_show can be triggered concurrently then it can lead to trouble. For example echo "open usb" > /proc/dynamic_debug/control echo "module usbcore =T:usb" > /proc/dynamic_debug/control # from one console echo "close usb" > / /proc/dynamic_debug/control # from another console and we can end up with an attempt to use closed trace instance"usb" > /* check flags 1st (last arg) so query is pairs of spec,val */ > if (ddebug_parse_flags(words[nwords-1], &modifiers)) { > pr_err("flags parse failed\n"); > - goto err; > + return -EINVAL; > } > > /* actually go and implement the change */ > nfound = ddebug_change(&query, &modifiers); > > - mutex_unlock(&ddebug_lock); > vpr_info_dq(&query, nfound ? "applied" : "no-match"); > return nfound; > -err: > - mutex_unlock(&ddebug_lock); > - return -EINVAL; > } > > /* handle multiple queries in query string, continue on error, return > -- > 2.43.0 >
Powered by blists - more mailing lists