Message ID | 20201013094938.356837-1-gabriele.paoloni@intel.com (mailing list archive) |
---|---|
Headers | show |
Series | improve bust_spinlocks dependability | expand |
+CC safety arch mailing list > -----Original Message----- > From: linux-safety@lists.elisa.tech <linux-safety@lists.elisa.tech> On Behalf > Of Paoloni, Gabriele > Sent: Tuesday, October 13, 2020 11:50 AM > To: linux-safety@lists.elisa.tech > Cc: Paoloni, Gabriele <gabriele.paoloni@intel.com> > Subject: [linux-safety] [RFC PATCH 1/2] bust_spinlocks: add kernel-doc > format doc > > In the ELISA Linux Foundation project we are trying to > improve the functions' documentation to make it more suitable > to derive functions' specs and write unit tests. This is needed > to make Linux more usable in functional safety systems. > So I am adding a proper kernel-doc format for bust_spinlocks. > > Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com> > --- > With respect to this patch I have a question on how to set > the function context; i.e. I don't know if it can be executed > in any context or if it has limitations. > --- > lib/bust_spinlocks.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/lib/bust_spinlocks.c b/lib/bust_spinlocks.c > index 8be59f84eaea..594b270161d9 100644 > --- a/lib/bust_spinlocks.c > +++ b/lib/bust_spinlocks.c > @@ -5,8 +5,6 @@ > * Provides a minimal bust_spinlocks for architectures which don't > * have one of their own. > * > - * bust_spinlocks() clears any spinlocks which would prevent oops, die(), > BUG() > - * and panic() information from reaching the user. > */ > > #include <linux/kernel.h> > @@ -17,6 +15,15 @@ > #include <linux/vt_kern.h> > #include <linux/console.h> > > +/** > + * bust_spinlocks - increases or decreases oops_in_progress. > + * if oops_in_progress != 0 spinlocks which would prevent > + * oops, die(), BUG() and panic() information from reaching > + * the user are busted. > + * @yes: input flag; if zero decreases oops_in_progress, > + * otherwise increases it. > + * > + */ > void bust_spinlocks(int yes) > { > if (yes) { > -- > 2.25.1 > > --------------------------------------------------------------------- > INTEL CORPORATION ITALIA S.p.A. con unico socio > Sede: Milanofiori Palazzo E 4 > CAP 20094 Assago (MI) > Capitale Sociale Euro 104.000,00 interamente versato > Partita I.V.A. e Codice Fiscale 04236760155 > Repertorio Economico Amministrativo n. 997124 > Registro delle Imprese di Milano nr. 183983/5281/33 > Soggetta ad attivita' di direzione e coordinamento di > INTEL CORPORATION, USA > > This e-mail and any attachments may contain confidential material for > the sole use of the intended recipient(s). Any review or distribution > by others is strictly prohibited. If you are not the intended > recipient, please contact the sender and delete all copies. > > > > > --------------------------------------------------------------------- INTEL CORPORATION ITALIA S.p.A. con unico socio Sede: Milanofiori Palazzo E 4 CAP 20094 Assago (MI) Capitale Sociale Euro 104.000,00 interamente versato Partita I.V.A. e Codice Fiscale 04236760155 Repertorio Economico Amministrativo n. 997124 Registro delle Imprese di Milano nr. 183983/5281/33 Soggetta ad attivita' di direzione e coordinamento di INTEL CORPORATION, USA This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#95): https://lists.elisa.tech/g/linux-safety/message/95 Mute This Topic: https://lists.elisa.tech/mt/77481124/4688437 Group Owner: linux-safety+owner@lists.elisa.tech Unsubscribe: https://lists.elisa.tech/g/linux-safety/unsub [patchwork-linux-safety@patchwork.kernel.org] -=-=-=-=-=-=-=-=-=-=-=-
+CC safety arch mailing list > -----Original Message----- > From: linux-safety@lists.elisa.tech <linux-safety@lists.elisa.tech> On Behalf > Of Paoloni, Gabriele > Sent: Tuesday, October 13, 2020 11:50 AM > To: linux-safety@lists.elisa.tech > Cc: Paoloni, Gabriele <gabriele.paoloni@intel.com> > Subject: [linux-safety] [RFC PATCH 2/2] bust_spinlocks: do not decrement > oops_in_progress unconditionally > > In the current implementation if the input flag is 0 > oops_in_progress is unconditionally decremented, thus allowing > to become a negative number. Since right now oops_in_progress > is a global variable used in the kernel as a conditional flag > to check if oops, panic(), BUG() or die() is in progress the > current unconditional decrement may lead to unexpected behavior > in the Kernel paths conditionally executing over this flag. > > This patch only decrement oops_in_progress if it is non zero > > Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com> > --- > lib/bust_spinlocks.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/lib/bust_spinlocks.c b/lib/bust_spinlocks.c > index 594b270161d9..842633ac9130 100644 > --- a/lib/bust_spinlocks.c > +++ b/lib/bust_spinlocks.c > @@ -23,6 +23,9 @@ > * @yes: input flag; if zero decreases oops_in_progress, > * otherwise increases it. > * > + * Note: if oops_in_progress is already 0 it will not > + * be decreased > + * > */ > void bust_spinlocks(int yes) > { > @@ -33,7 +36,9 @@ void bust_spinlocks(int yes) > unblank_screen(); > #endif > console_unblank(); > - if (--oops_in_progress == 0) > + if (oops_in_progress) > + oops_in_progress--; > + if (!oops_in_progress) > wake_up_klogd(); > } > } > -- > 2.25.1 > > --------------------------------------------------------------------- > INTEL CORPORATION ITALIA S.p.A. con unico socio > Sede: Milanofiori Palazzo E 4 > CAP 20094 Assago (MI) > Capitale Sociale Euro 104.000,00 interamente versato > Partita I.V.A. e Codice Fiscale 04236760155 > Repertorio Economico Amministrativo n. 997124 > Registro delle Imprese di Milano nr. 183983/5281/33 > Soggetta ad attivita' di direzione e coordinamento di > INTEL CORPORATION, USA > > This e-mail and any attachments may contain confidential material for > the sole use of the intended recipient(s). Any review or distribution > by others is strictly prohibited. If you are not the intended > recipient, please contact the sender and delete all copies. > > > > > --------------------------------------------------------------------- INTEL CORPORATION ITALIA S.p.A. con unico socio Sede: Milanofiori Palazzo E 4 CAP 20094 Assago (MI) Capitale Sociale Euro 104.000,00 interamente versato Partita I.V.A. e Codice Fiscale 04236760155 Repertorio Economico Amministrativo n. 997124 Registro delle Imprese di Milano nr. 183983/5281/33 Soggetta ad attivita' di direzione e coordinamento di INTEL CORPORATION, USA This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#96): https://lists.elisa.tech/g/linux-safety/message/96 Mute This Topic: https://lists.elisa.tech/mt/77481133/4688437 Group Owner: linux-safety+owner@lists.elisa.tech Unsubscribe: https://lists.elisa.tech/g/linux-safety/unsub [patchwork-linux-safety@patchwork.kernel.org] -=-=-=-=-=-=-=-=-=-=-=-
Hi Gab I think so, this patch is good. If you agree to my opinion, please more improve. In a very rare case, the oops_in_progress could be a negative value. Because this decrement/increment is a read-modified statement. On the other hand, shouldn't take exclusions such as spin lock with this function. if (!oops_in_progress) change to if (oops_in_progress <= 0) How about? Best, /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ Doctor of Informatics, Specialist Software Fundamental Technology Group Application Development Department Connected & Sharing Solutions Division AISIN AW CO.,LTD. YAMAGUCHI Naoto E-mail: i33399_YAMAGUCHI@aisin-aw.co.jp /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ -----Original Message----- From: safety-architecture@lists.elisa.tech <safety-architecture@lists.elisa.tech> On Behalf Of Paoloni, Gabriele Sent: Tuesday, October 13, 2020 8:58 PM To: Paoloni, Gabriele <gabriele.paoloni@intel.com>; linux-safety@lists.elisa.tech Cc: safety-architecture@lists.elisa.tech Subject: Re: [ELISA Safety Architecture WG] [linux-safety] [RFC PATCH 2/2] bust_spinlocks: do not decrement oops_in_progress unconditionally +CC safety arch mailing list > -----Original Message----- > From: linux-safety@lists.elisa.tech <linux-safety@lists.elisa.tech> On > Behalf Of Paoloni, Gabriele > Sent: Tuesday, October 13, 2020 11:50 AM > To: linux-safety@lists.elisa.tech > Cc: Paoloni, Gabriele <gabriele.paoloni@intel.com> > Subject: [linux-safety] [RFC PATCH 2/2] bust_spinlocks: do not > decrement oops_in_progress unconditionally > > In the current implementation if the input flag is 0 oops_in_progress > is unconditionally decremented, thus allowing to become a negative > number. Since right now oops_in_progress is a global variable used in > the kernel as a conditional flag to check if oops, panic(), BUG() or > die() is in progress the current unconditional decrement may lead to > unexpected behavior in the Kernel paths conditionally executing over > this flag. > > This patch only decrement oops_in_progress if it is non zero > > Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com> > --- > lib/bust_spinlocks.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/lib/bust_spinlocks.c b/lib/bust_spinlocks.c index > 594b270161d9..842633ac9130 100644 > --- a/lib/bust_spinlocks.c > +++ b/lib/bust_spinlocks.c > @@ -23,6 +23,9 @@ > * @yes: input flag; if zero decreases oops_in_progress, > * otherwise increases it. > * > + * Note: if oops_in_progress is already 0 it will not > + * be decreased > + * > */ > void bust_spinlocks(int yes) > { > @@ -33,7 +36,9 @@ void bust_spinlocks(int yes) > unblank_screen(); > #endif > console_unblank(); > - if (--oops_in_progress == 0) > + if (oops_in_progress) > + oops_in_progress--; > + if (!oops_in_progress) > wake_up_klogd(); > } > } > -- > 2.25.1 > > --------------------------------------------------------------------- > INTEL CORPORATION ITALIA S.p.A. con unico socio > Sede: Milanofiori Palazzo E 4 > CAP 20094 Assago (MI) > Capitale Sociale Euro 104.000,00 interamente versato Partita I.V.A. e > Codice Fiscale 04236760155 Repertorio Economico Amministrativo n. > 997124 Registro delle Imprese di Milano nr. 183983/5281/33 Soggetta ad > attivita' di direzione e coordinamento di INTEL CORPORATION, USA > > This e-mail and any attachments may contain confidential material for > the sole use of the intended recipient(s). Any review or distribution > by others is strictly prohibited. If you are not the intended > recipient, please contact the sender and delete all copies. > > > > > --------------------------------------------------------------------- INTEL CORPORATION ITALIA S.p.A. con unico socio Sede: Milanofiori Palazzo E 4 CAP 20094 Assago (MI) Capitale Sociale Euro 104.000,00 interamente versato Partita I.V.A. e Codice Fiscale 04236760155 Repertorio Economico Amministrativo n. 997124 Registro delle Imprese di Milano nr. 183983/5281/33 Soggetta ad attivita' di direzione e coordinamento di INTEL CORPORATION, USA This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#107): https://lists.elisa.tech/g/linux-safety/message/107 Mute This Topic: https://lists.elisa.tech/mt/77485000/4688437 Group Owner: linux-safety+owner@lists.elisa.tech Unsubscribe: https://lists.elisa.tech/g/linux-safety/unsub [patchwork-linux-safety@patchwork.kernel.org] -=-=-=-=-=-=-=-=-=-=-=-
> -----Original Message----- > From: safety-architecture@lists.elisa.tech <safety- > architecture@lists.elisa.tech> On Behalf Of i33399_yamaguchi@aisin- > aw.co.jp > Sent: Tuesday, October 13, 2020 3:07 PM > To: Paoloni, Gabriele <gabriele.paoloni@intel.com>; linux- > safety@lists.elisa.tech > Cc: safety-architecture@lists.elisa.tech > Subject: Re: [ELISA Safety Architecture WG] [linux-safety] [RFC PATCH 2/2] > bust_spinlocks: do not decrement oops_in_progress unconditionally > > Hi Gab > > I think so, this patch is good. > If you agree to my opinion, please more improve. > In a very rare case, the oops_in_progress could be a negative value. Because > this decrement/increment is a read-modified statement. On the other hand, > shouldn't take exclusions such as spin lock with this function. > > if (!oops_in_progress) > change to > if (oops_in_progress <= 0) > > How about? Mmmmm what you are proposing is right, I was just wondering if it is needed.... Looking in the Kernel source code I am seeing that oops_in_progress is always set to 1 or 0 except in https://elixir.bootlin.com/linux/latest/source/kernel/debug/kdb/kdb_io.c#L578. Here oops_in_progress is incremented and then decremented right after... actually I am wondering if in this file we should call bust_spinlocks() instead of directly incrementing/decremeting the variable.... Thanks Gab > > Best, > /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ > Doctor of Informatics, Specialist > Software Fundamental Technology Group > Application Development Department > Connected & Sharing Solutions Division > AISIN AW CO.,LTD. > YAMAGUCHI Naoto > E-mail: i33399_YAMAGUCHI@aisin-aw.co.jp > /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ > -----Original Message----- > From: safety-architecture@lists.elisa.tech <safety- > architecture@lists.elisa.tech> On Behalf Of Paoloni, Gabriele > Sent: Tuesday, October 13, 2020 8:58 PM > To: Paoloni, Gabriele <gabriele.paoloni@intel.com>; linux- > safety@lists.elisa.tech > Cc: safety-architecture@lists.elisa.tech > Subject: Re: [ELISA Safety Architecture WG] [linux-safety] [RFC PATCH 2/2] > bust_spinlocks: do not decrement oops_in_progress unconditionally > > +CC safety arch mailing list > > > -----Original Message----- > > From: linux-safety@lists.elisa.tech <linux-safety@lists.elisa.tech> On > > Behalf Of Paoloni, Gabriele > > Sent: Tuesday, October 13, 2020 11:50 AM > > To: linux-safety@lists.elisa.tech > > Cc: Paoloni, Gabriele <gabriele.paoloni@intel.com> > > Subject: [linux-safety] [RFC PATCH 2/2] bust_spinlocks: do not > > decrement oops_in_progress unconditionally > > > > In the current implementation if the input flag is 0 oops_in_progress > > is unconditionally decremented, thus allowing to become a negative > > number. Since right now oops_in_progress is a global variable used in > > the kernel as a conditional flag to check if oops, panic(), BUG() or > > die() is in progress the current unconditional decrement may lead to > > unexpected behavior in the Kernel paths conditionally executing over > > this flag. > > > > This patch only decrement oops_in_progress if it is non zero > > > > Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com> > > --- > > lib/bust_spinlocks.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/lib/bust_spinlocks.c b/lib/bust_spinlocks.c index > > 594b270161d9..842633ac9130 100644 > > --- a/lib/bust_spinlocks.c > > +++ b/lib/bust_spinlocks.c > > @@ -23,6 +23,9 @@ > > * @yes: input flag; if zero decreases oops_in_progress, > > * otherwise increases it. > > * > > + * Note: if oops_in_progress is already 0 it will not > > + * be decreased > > + * > > */ > > void bust_spinlocks(int yes) > > { > > @@ -33,7 +36,9 @@ void bust_spinlocks(int yes) > > unblank_screen(); > > #endif > > console_unblank(); > > - if (--oops_in_progress == 0) > > + if (oops_in_progress) > > + oops_in_progress--; > > + if (!oops_in_progress) > > wake_up_klogd(); > > } > > } > > -- > > 2.25.1 > > > > --------------------------------------------------------------------- > > INTEL CORPORATION ITALIA S.p.A. con unico socio > > Sede: Milanofiori Palazzo E 4 > > CAP 20094 Assago (MI) > > Capitale Sociale Euro 104.000,00 interamente versato Partita I.V.A. e > > Codice Fiscale 04236760155 Repertorio Economico Amministrativo n. > > 997124 Registro delle Imprese di Milano nr. 183983/5281/33 Soggetta ad > > attivita' di direzione e coordinamento di INTEL CORPORATION, USA > > > > This e-mail and any attachments may contain confidential material for > > the sole use of the intended recipient(s). Any review or distribution > > by others is strictly prohibited. If you are not the intended > > recipient, please contact the sender and delete all copies. > > > > > > > > > > > > --------------------------------------------------------------------- > INTEL CORPORATION ITALIA S.p.A. con unico socio > Sede: Milanofiori Palazzo E 4 > CAP 20094 Assago (MI) > Capitale Sociale Euro 104.000,00 interamente versato Partita I.V.A. e Codice > Fiscale 04236760155 Repertorio Economico Amministrativo n. 997124 Registro > delle Imprese di Milano nr. 183983/5281/33 Soggetta ad attivita' di direzione e > coordinamento di INTEL CORPORATION, USA > > This e-mail and any attachments may contain confidential material for the > sole use of the intended recipient(s). Any review or distribution by others is > strictly prohibited. If you are not the intended recipient, please contact the > sender and delete all copies. > > > > > > > > > > --------------------------------------------------------------------- INTEL CORPORATION ITALIA S.p.A. con unico socio Sede: Milanofiori Palazzo E 4 CAP 20094 Assago (MI) Capitale Sociale Euro 104.000,00 interamente versato Partita I.V.A. e Codice Fiscale 04236760155 Repertorio Economico Amministrativo n. 997124 Registro delle Imprese di Milano nr. 183983/5281/33 Soggetta ad attivita' di direzione e coordinamento di INTEL CORPORATION, USA This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#97): https://lists.elisa.tech/g/linux-safety/message/97 Mute This Topic: https://lists.elisa.tech/mt/77482956/4688437 Group Owner: linux-safety+owner@lists.elisa.tech Unsubscribe: https://lists.elisa.tech/g/linux-safety/unsub [patchwork-linux-safety@patchwork.kernel.org] -=-=-=-=-=-=-=-=-=-=-=-
On Tue, 13 Oct 2020, Paoloni, Gabriele wrote: > This patchset provides a kernel-doc documentation format > for bust_spinlocks() and fixes a weakness where the global > variable oops_in_progress gets unconditionally decremented > > Gabriele Paoloni (2): > bust_spinlocks: add kernel-doc format doc > bust_spinlocks: do not decrement oops_in_progress unconditionally > > lib/bust_spinlocks.c | 18 +++++++++++++++--- > 1 file changed, 15 insertions(+), 3 deletions(-) > Patchset looks good to me! I would love to see the feedback you get. Lukas > -- > 2.25.1 > > --------------------------------------------------------------------- > INTEL CORPORATION ITALIA S.p.A. con unico socio > Sede: Milanofiori Palazzo E 4 > CAP 20094 Assago (MI) > Capitale Sociale Euro 104.000,00 interamente versato > Partita I.V.A. e Codice Fiscale 04236760155 > Repertorio Economico Amministrativo n. 997124 > Registro delle Imprese di Milano nr. 183983/5281/33 > Soggetta ad attivita' di direzione e coordinamento di > INTEL CORPORATION, USA > > This e-mail and any attachments may contain confidential material for > the sole use of the intended recipient(s). Any review or distribution > by others is strictly prohibited. If you are not the intended > recipient, please contact the sender and delete all copies. > > > > > > > -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#110): https://lists.elisa.tech/g/linux-safety/message/110 Mute This Topic: https://lists.elisa.tech/mt/77479832/4688437 Group Owner: linux-safety+owner@lists.elisa.tech Unsubscribe: https://lists.elisa.tech/g/linux-safety/unsub [patchwork-linux-safety@patchwork.kernel.org] -=-=-=-=-=-=-=-=-=-=-=-