Re: [PATCH v4 08/12] ptrace: Document that wait_task_inactive can't fail

2022-05-05 Thread Sebastian Andrzej Siewior
On 2022-05-05 13:26:41 [-0500], Eric W. Biederman wrote: > After ptrace_freeze_traced succeeds it is known that the the tracee the > has a __state value of __TASK_TRACED and that no __ptrace_unlink will > happen because the tracer is waiting f

Re: [PATCH v3 15/15] kbuild: make *.mod rule robust against too long argument error

2022-05-05 Thread Nicolas Schier
On Thu, May 05, 2022 at 04:22:44PM +0900 Masahiro Yamada wrote: > Like built-in.a, the command length of the *.mod rule scales with > the depth of the directory times the number of objects in the Makefile. > > Add $(obj)/ by the shell command (awk) instead of by Make's builtin > function. > > In-

Re: [PATCH v3 14/15] kbuild: make built-in.a rule robust against too long argument error

2022-05-05 Thread Nicolas Schier
On Thu, May 05, 2022 at 04:22:43PM +0900 Masahiro Yamada wrote: > Kbuild runs at the top of objtree instead of changing the working > directory to subdirectories. I think this design is nice overall but > some commands have a scapability issue. > > The build command of built-in.a is one of them wh

Re: [PATCH v3 12/15] modpost: simplify the ->is_static initialization

2022-05-05 Thread Nicolas Schier
On Thu, May 05, 2022 at 04:22:41PM +0900 Masahiro Yamada wrote: > ->is_static is set to true at allocation, then to false if the symbol > comes from the dump file. > > It is simpler to use !mod->from_dump as the init value. > > Signed-off-by: Masahiro Yamada > --- > > (no changes since v2) > >

Re: [PATCH v3 10/15] genksyms: adjust the output format to modpost

2022-05-05 Thread Nicolas Schier
On Thu, May 05, 2022 at 04:22:39PM +0900 Masahiro Yamada wrote: > Make genksyms output symbol versions in the format modpost expects, > so the 'sed' is unneeded. > > This commit makes *.symversions completely unneeded. > > I will keep *.symversions in .gitignore and 'make clean' for a while. > Ot

Re: [PATCH v3 09/15] kbuild: stop merging *.symversions

2022-05-05 Thread Nicolas Schier
On Thu, May 05, 2022 at 04:22:38PM +0900 Masahiro Yamada wrote: > Now modpost reads symbol versions from .*.cmd files. > > These merged *.symversions are not used any more. > > Signed-off-by: Masahiro Yamada > --- > > (no changes since v1) > > scripts/Makefile.build | 21 ++--

Re: [PATCH v3 07/15] modpost: extract symbol versions from *.cmd files

2022-05-05 Thread Nicolas Schier
On Thu, May 05, 2022 at 04:22:36PM +0900 Masahiro Yamada wrote: > Currently, CONFIG_MODVERSIONS needs extra link to embed the symbol > versions into ELF objects. Then, modpost extracts the version CRCs > from them. > > The following figures show how it currently works, and how I am trying > to cha

Re: [PATCH v3 04/15] modpost: move *.mod.c generation to write_mod_c_files()

2022-05-05 Thread Nicolas Schier
On Thu, May 05, 2022 at 04:22:33PM +0900 Masahiro Yamada wrote: > A later commit will add more code to this list_for_each_entry loop. > > Before that, move the loop body into a separate helper function. > > Signed-off-by: Masahiro Yamada > --- > > Changes in v3: > - New patch > > scripts/mo

Re: [PATCH v3 03/15] modpost: merge add_{intree_flag,retpoline,staging_flag} to add_header

2022-05-05 Thread Nicolas Schier
On Thu, May 05, 2022 at 04:22:32PM +0900 Masahiro Yamada wrote: > add_intree_flag(), add_retpoline(), and add_staging_flag() are small > enough to be merged into add_header(). > > Signed-off-by: Masahiro Yamada > --- > > Changes in v3: > - New patch > > scripts/mod/modpost.c | 25 +++

Re: [PATCH v3 02/15] modpost: change the license of EXPORT_SYMBOL to bool type

2022-05-05 Thread Nicolas Schier
On Thu, May 05, 2022 at 10:48:55PM +0900 Masahiro Yamada wrote: > On Thu, May 5, 2022 at 4:24 PM Masahiro Yamada wrote: > > > > Currently, enum export is tristate, but export_unknown does not make > > sense in any way. > > > > If the symbol name starts with "__ksymtab_", but the section name > > d

Re: [PATCH 08/30] powerpc/setup: Refactor/untangle panic notifiers

2022-05-05 Thread Guilherme G. Piccoli
On 05/05/2022 15:55, Hari Bathini wrote: > [...] > > The change looks good. I have tested it on an LPAR (ppc64). > > Reviewed-by: Hari Bathini Thanks a bunch Hari, much appreciated! ___ linux-um mailing list linux-um@lists.infradead.org http://lists

Re: [PATCH v3 01/15] modpost: mitigate false-negatives for static EXPORT_SYMBOL checks

2022-05-05 Thread Nicolas Schier
On Thu, May 05, 2022 at 04:22:30PM +0900 Masahiro Yamada wrote: > The 'static' specifier and EXPORT_SYMBOL() are an odd combination. > > Since commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* > functions"), modpost tries to detect it, but there are false negatives. > > Here is the s

Re: [PATCH 08/30] powerpc/setup: Refactor/untangle panic notifiers

2022-05-05 Thread Hari Bathini
On 28/04/22 4:19 am, Guilherme G. Piccoli wrote: The panic notifiers infrastructure is a bit limited in the scope of the callbacks - basically every kind of functionality is dropped in a list that runs in the same point during the kernel panic path. This is not really on par with the complexiti

[PATCH v4 12/12] sched, signal, ptrace: Rework TASK_TRACED, TASK_STOPPED state

2022-05-05 Thread Eric W. Biederman
From: Peter Zijlstra Currently ptrace_stop() / do_signal_stop() rely on the special states TASK_TRACED and TASK_STOPPED resp. to keep unique state. That is, this state exists only in task->__state and nowhere else. There's two spots of bother with this: - PREEMPT_RT has task->saved_state which

[PATCH v4 11/12] ptrace: Always take siglock in ptrace_resume

2022-05-05 Thread Eric W. Biederman
Make code analysis simpler and future changes easier by always taking siglock in ptrace_resume. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 13 ++--- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 83ed28262708..36a5b7a0

[PATCH v4 10/12] ptrace: Don't change __state

2022-05-05 Thread Eric W. Biederman
Stop playing with tsk->__state to remove TASK_WAKEKILL while a ptrace command is executing. Instead remove TASK_WAKEKILL from the definition of TASK_TRACED, and implement a new jobctl flag TASK_PTRACE_FROZEN. This new flag is set in jobctl_freeze_task and cleared when ptrace_stop is awoken or in

[PATCH v4 09/12] ptrace: Admit ptrace_stop can generate spuriuos SIGTRAPs

2022-05-05 Thread Eric W. Biederman
Long ago and far away there was a BUG_ON at the start of ptrace_stop that did "BUG_ON(!(current->ptrace & PT_PTRACED));" [1]. The BUG_ON had never triggered but examination of the code showed that the BUG_ON could actually trigger. To complement removing the BUG_ON an attempt to better handle the

[PATCH v4 08/12] ptrace: Document that wait_task_inactive can't fail

2022-05-05 Thread Eric W. Biederman
After ptrace_freeze_traced succeeds it is known that the the tracee has a __state value of __TASK_TRACED and that no __ptrace_unlink will happen because the tracer is waiting for the tracee, and the tracee is in ptrace_stop. The function ptrace_freeze_traced can succeed at any point after ptrace_s

[PATCH v4 07/12] ptrace: Reimplement PTRACE_KILL by always sending SIGKILL

2022-05-05 Thread Eric W. Biederman
The current implementation of PTRACE_KILL is buggy and has been for many years as it assumes it's target has stopped in ptrace_stop. At a quick skim it looks like this assumption has existed since ptrace support was added in linux v1.0. While PTRACE_KILL has been deprecated we can not remove it a

[PATCH v4 06/12] signal: Use lockdep_assert_held instead of assert_spin_locked

2022-05-05 Thread Eric W. Biederman
The distinction is that assert_spin_locked() checks if the lock is held *by*anyone* whereas lockdep_assert_held() asserts the current context holds the lock. Also, the check goes away if you build without lockdep. Suggested-by: Peter Zijlstra Link: https://lkml.kernel.org/r/Ympr/+PX4XgT/u...@hi

[PATCH v4 05/12] ptrace: Remove arch_ptrace_attach

2022-05-05 Thread Eric W. Biederman
The last remaining implementation of arch_ptrace_attach is ia64's ptrace_attach_sync_user_rbs which was added at the end of 2007 in commit aa91a2e90044 ("[IA64] Synchronize RBS on PTRACE_ATTACH"). Reading the comments and examining the code ptrace_attach_sync_user_rbs has the sole purpose of savin

[PATCH v4 04/12] ptrace/xtensa: Replace PT_SINGLESTEP with TIF_SINGLESTEP

2022-05-05 Thread Eric W. Biederman
xtensa is the last user of the PT_SINGLESTEP flag. Changing tsk->ptrace in user_enable_single_step and user_disable_single_step without locking could potentiallly cause problems. So use a thread info flag instead of a flag in tsk->ptrace. Use TIF_SINGLESTEP that xtensa already had defined but un

[PATCH v4 03/12] ptrace/um: Replace PT_DTRACE with TIF_SINGLESTEP

2022-05-05 Thread Eric W. Biederman
User mode linux is the last user of the PT_DTRACE flag. Using the flag to indicate single stepping is a little confusing and worse changing tsk->ptrace without locking could potentionally cause problems. So use a thread info flag with a better name instead of flag in tsk->ptrace. Remove the de

[PATCH v4 01/12] signal: Rename send_signal send_signal_locked

2022-05-05 Thread Eric W. Biederman
Rename send_signal and __send_signal to send_signal_locked and __send_signal_locked to make send_signal usable outside of signal.c. Signed-off-by: "Eric W. Biederman" --- include/linux/signal.h | 2 ++ kernel/signal.c| 24 2 files changed, 14 insertions(+), 12 d

[PATCH v4 02/12] signal: Replace __group_send_sig_info with send_signal_locked

2022-05-05 Thread Eric W. Biederman
The function __group_send_sig_info is just a light wrapper around send_signal_locked with one parameter fixed to a constant value. As the wrapper adds no real value update the code to directly call the wrapped function. Signed-off-by: "Eric W. Biederman" --- drivers/tty/tty_jobctrl.c | 4 +

[PATCH v4 0/12] ptrace: cleaning up ptrace_stop

2022-05-05 Thread Eric W. Biederman
The states TASK_STOPPED and TASK_TRACE are special in they can not handle spurious wake-ups. This plus actively depending upon and changing the value of tsk->__state causes problems for PREEMPT_RT and Peter's freezer rewrite. There are a lot of details we have to get right to sort out the techn

Re: [PATCH v3 08/11] ptrace: Admit ptrace_stop can generate spuriuos SIGTRAPs

2022-05-05 Thread Oleg Nesterov
On 05/05, Eric W. Biederman wrote: > > So I vote for deleting code, and making ptrace_stop easier to reason > about. Yes, yes, agreed. Oleg. ___ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um

Re: [PATCH v3 08/11] ptrace: Admit ptrace_stop can generate spuriuos SIGTRAPs

2022-05-05 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/04, Eric W. Biederman wrote: >> >> -static int ptrace_stop(int exit_code, int why, int clear_code, >> -unsigned long message, kernel_siginfo_t *info) >> +static int ptrace_stop(int exit_code, int why, unsigned long message, >> +

Re: [PATCH v3 08/11] ptrace: Admit ptrace_stop can generate spuriuos SIGTRAPs

2022-05-05 Thread Oleg Nesterov
On 05/05, Eric W. Biederman wrote: > > And yes that WARN_ON_ONCE can trigger on PREEMPT_RT but that is just > because PREMPT_RT is currently broken with respect to ptrace. Which > makes a WARN_ON_ONCE appropriate. Yes agreed. In this case WARN_ON_ONCE() can help a user to understand that a failur

Re: [PATCH v3 08/11] ptrace: Admit ptrace_stop can generate spuriuos SIGTRAPs

2022-05-05 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/04, Eric W. Biederman wrote: >> >> With the removal of the incomplete detection of the tracer going away >> in ptrace_stop, ptrace_stop always sleeps in schedule after >> ptrace_freeze_traced succeeds. Modify ptrace_check_attach to >> warn if wait_task_inactive fail

Re: [PATCH v3 08/11] ptrace: Admit ptrace_stop can generate spuriuos SIGTRAPs

2022-05-05 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/04, Eric W. Biederman wrote: >> >> -static int ptrace_stop(int exit_code, int why, int clear_code, >> -unsigned long message, kernel_siginfo_t *info) >> +static int ptrace_stop(int exit_code, int why, unsigned long message, >> +

Re: [PATCH v3 00/15] kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS)

2022-05-05 Thread Masahiro Yamada
On Thu, May 5, 2022 at 4:24 PM Masahiro Yamada wrote: > > > This is the third batch of cleanups in this development cycle. This series is available at: git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git lto-cleanup-v3 -- Best Regards Masahiro Yamada __

Re: [PATCH v3 09/11] ptrace: Don't change __state

2022-05-05 Thread Eric W. Biederman
Sebastian Andrzej Siewior writes: > On 2022-05-04 17:40:56 [-0500], Eric W. Biederman wrote: >> Stop playing with tsk->__state to remove TASK_WAKEKILL while a ptrace >> command is executing. >> >> Instead remove TASK_WAKEKILL from the definition of TASK_TRACED, and >> implemention a new jobctl f

Re: [PATCH v3 08/11] ptrace: Admit ptrace_stop can generate spuriuos SIGTRAPs

2022-05-05 Thread Oleg Nesterov
On 05/04, Eric W. Biederman wrote: > > -static int ptrace_stop(int exit_code, int why, int clear_code, > - unsigned long message, kernel_siginfo_t *info) > +static int ptrace_stop(int exit_code, int why, unsigned long message, > +kernel_siginfo_t *info) Forg

Re: [PATCH v3 08/11] ptrace: Admit ptrace_stop can generate spuriuos SIGTRAPs

2022-05-05 Thread Oleg Nesterov
On 05/04, Eric W. Biederman wrote: > > With the removal of the incomplete detection of the tracer going away > in ptrace_stop, ptrace_stop always sleeps in schedule after > ptrace_freeze_traced succeeds. Modify ptrace_check_attach to > warn if wait_task_inactive fails. Oh. Again, I don't understa

Re: [PATCH v3 08/11] ptrace: Admit ptrace_stop can generate spuriuos SIGTRAPs

2022-05-05 Thread Oleg Nesterov
On 05/04, Eric W. Biederman wrote: > > -static int ptrace_stop(int exit_code, int why, int clear_code, > - unsigned long message, kernel_siginfo_t *info) > +static int ptrace_stop(int exit_code, int why, unsigned long message, > +kernel_siginfo_t *info) >

Re: [PATCH v3 02/15] modpost: change the license of EXPORT_SYMBOL to bool type

2022-05-05 Thread Masahiro Yamada
On Thu, May 5, 2022 at 4:24 PM Masahiro Yamada wrote: > > Currently, enum export is tristate, but export_unknown does not make > sense in any way. > > If the symbol name starts with "__ksymtab_", but the section name > does not start with "___ksymtab+" or "___ksymtab_gpl+", it is not > an exported

Re: [PATCH v3 09/11] ptrace: Don't change __state

2022-05-05 Thread Sebastian Andrzej Siewior
On 2022-05-04 17:40:56 [-0500], Eric W. Biederman wrote: > Stop playing with tsk->__state to remove TASK_WAKEKILL while a ptrace > command is executing. > > Instead remove TASK_WAKEKILL from the definition of TASK_TRACED, and > implemention a new jobctl flag TASK_PTRACE_FROZEN. This new flag is i

[PATCH v3 08/15] kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS

2022-05-05 Thread Masahiro Yamada
include/{linux,asm-generic}/export.h defines a weak symbol, __crc_* as a placeholder. Genksyms writes the version CRCs into the linker script, which will be used for filling the __crc_* symbols. The linker script format depends on CONFIG_MODULE_REL_CRCS. If it is enabled, __crc_* holds the offset

[PATCH v3 15/15] kbuild: make *.mod rule robust against too long argument error

2022-05-05 Thread Masahiro Yamada
Like built-in.a, the command length of the *.mod rule scales with the depth of the directory times the number of objects in the Makefile. Add $(obj)/ by the shell command (awk) instead of by Make's builtin function. In-tree modules still have some room to the limit (ARG_MAX=2097152), but this is

[PATCH v3 09/15] kbuild: stop merging *.symversions

2022-05-05 Thread Masahiro Yamada
Now modpost reads symbol versions from .*.cmd files. These merged *.symversions are not used any more. Signed-off-by: Masahiro Yamada --- (no changes since v1) scripts/Makefile.build | 21 ++--- scripts/link-vmlinux.sh | 15 --- 2 files changed, 2 insertions(+), 3

[PATCH v3 13/15] modpost: use hlist for hash table implementation

2022-05-05 Thread Masahiro Yamada
Import hlist macros from include/linux/list.h to implement the hash table in a more generic way. While I was here, I increased the hash table size from 1024 to 8192 to decrease the hash collision. I moved ARRAY_SIZE() from file2alias.c to modpost.h because it is needed in modpost.c as well. Sign

[PATCH v3 07/15] modpost: extract symbol versions from *.cmd files

2022-05-05 Thread Masahiro Yamada
Currently, CONFIG_MODVERSIONS needs extra link to embed the symbol versions into ELF objects. Then, modpost extracts the version CRCs from them. The following figures show how it currently works, and how I am trying to change it. Current implementation ==

[PATCH v3 14/15] kbuild: make built-in.a rule robust against too long argument error

2022-05-05 Thread Masahiro Yamada
Kbuild runs at the top of objtree instead of changing the working directory to subdirectories. I think this design is nice overall but some commands have a scapability issue. The build command of built-in.a is one of them whose length scales with: O(D * N) Here, D is the length of the direct

[PATCH v3 11/15] kbuild: do not create *.prelink.o for Clang LTO or IBT

2022-05-05 Thread Masahiro Yamada
When CONFIG_LTO_CLANG=y, additional intermediate *.prelink.o is created for each module. Also, objtool is postponed until LLVM bitcode is converted to ELF. CONFIG_X86_KERNEL_IBT works in a similar way to postpone objtool until objects are merged together. This commit stops generating *.prelink.o,

[PATCH v3 12/15] modpost: simplify the ->is_static initialization

2022-05-05 Thread Masahiro Yamada
->is_static is set to true at allocation, then to false if the symbol comes from the dump file. It is simpler to use !mod->from_dump as the init value. Signed-off-by: Masahiro Yamada --- (no changes since v2) Changes in v2: - New patch scripts/mod/modpost.c | 4 ++-- 1 file changed, 2 inse

[PATCH v3 02/15] modpost: change the license of EXPORT_SYMBOL to bool type

2022-05-05 Thread Masahiro Yamada
Currently, enum export is tristate, but export_unknown does not make sense in any way. If the symbol name starts with "__ksymtab_", but the section name does not start with "___ksymtab+" or "___ksymtab_gpl+", it is not an exported symbol. The variable name just happens to start with "__ksymtab_".

[PATCH v3 10/15] genksyms: adjust the output format to modpost

2022-05-05 Thread Masahiro Yamada
Make genksyms output symbol versions in the format modpost expects, so the 'sed' is unneeded. This commit makes *.symversions completely unneeded. I will keep *.symversions in .gitignore and 'make clean' for a while. Otherwise, some people might be upset with 'git status'. Signed-off-by: Masahir

[PATCH v3 06/15] kbuild: record symbol versions in *.cmd files

2022-05-05 Thread Masahiro Yamada
When CONFIG_MODVERSIONS=y, the output from genksyms is saved in separate *.symversions files, and will be used much later when CONFIG_LTO_CLANG=y because it is impossible to update LLVM bit code here. This approach is not robust because: - *.symversions may or may not exist. If *.symversions doe

[PATCH v3 04/15] modpost: move *.mod.c generation to write_mod_c_files()

2022-05-05 Thread Masahiro Yamada
A later commit will add more code to this list_for_each_entry loop. Before that, move the loop body into a separate helper function. Signed-off-by: Masahiro Yamada --- Changes in v3: - New patch scripts/mod/modpost.c | 56 --- 1 file changed, 31 inser

[PATCH v3 01/15] modpost: mitigate false-negatives for static EXPORT_SYMBOL checks

2022-05-05 Thread Masahiro Yamada
The 'static' specifier and EXPORT_SYMBOL() are an odd combination. Since commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* functions"), modpost tries to detect it, but there are false negatives. Here is the sample code. [Sample 1] Makefile: obj-m += mymod1.o mymod2.o mymo

[PATCH v3 00/15] kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS)

2022-05-05 Thread Masahiro Yamada
This is the third batch of cleanups in this development cycle. Major changes in v3: - Generate symbol CRCs as C code, and remove CONFIG_MODULE_REL_CRCS. Major changes in v2: - V1 did not work with CONFIG_MODULE_REL_CRCS. I fixed this for v2. - Reflect some review comments in v1 - Ref

[PATCH v3 03/15] modpost: merge add_{intree_flag, retpoline, staging_flag} to add_header

2022-05-05 Thread Masahiro Yamada
add_intree_flag(), add_retpoline(), and add_staging_flag() are small enough to be merged into add_header(). Signed-off-by: Masahiro Yamada --- Changes in v3: - New patch scripts/mod/modpost.c | 25 +++-- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/scrip

[PATCH v3 05/15] kbuild: generate a list of objects in vmlinux

2022-05-05 Thread Masahiro Yamada
A *.mod file lists the member objects of a module, but vmlinux does not have such a file to list out all the member objects. Generate this list to allow modpost to know all the member objects. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- (no changes since v2) Changes in v2: