diff mbox series

[2/2] kunit: ubsan integration

Message ID 20200806174326.3577537-2-urielguajardojr@gmail.com (mailing list archive)
State Accepted
Headers show
Series [1/2] kunit: support failure from dynamic analysis tools | expand

Commit Message

Uriel Guajardo Aug. 6, 2020, 5:43 p.m. UTC
Integrates UBSAN into the KUnit testing framework. It fails KUnit tests
whenever it reports undefined behavior.

Signed-off-by: Uriel Guajardo <urielguajardo@google.com>
---
 lib/ubsan.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Brendan Higgins Aug. 10, 2020, 8:42 p.m. UTC | #1
On Thu, Aug 6, 2020 at 10:43 AM Uriel Guajardo
<urielguajardojr@gmail.com> wrote:
>
> Integrates UBSAN into the KUnit testing framework. It fails KUnit tests
> whenever it reports undefined behavior.
>
> Signed-off-by: Uriel Guajardo <urielguajardo@google.com>

You should resend this to the UBSAN maintainers as well; they will
need to sign off on this.

In the future, make sure to run get_maintainers.pl

Reviewed-by: Brendan Higgins <brendanhiggins@google.com>

> ---
>  lib/ubsan.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/lib/ubsan.c b/lib/ubsan.c
> index cb9af3f6b77e..1460e2c828c8 100644
> --- a/lib/ubsan.c
> +++ b/lib/ubsan.c
> @@ -14,6 +14,7 @@
>  #include <linux/types.h>
>  #include <linux/sched.h>
>  #include <linux/uaccess.h>
> +#include <kunit/test.h>
>
>  #include "ubsan.h"
>
> @@ -137,6 +138,7 @@ static void ubsan_prologue(struct source_location *loc, const char *reason)
>  {
>         current->in_ubsan++;
>
> +       kunit_fail_current_test();
>         pr_err("========================================"
>                 "========================================\n");
>         pr_err("UBSAN: %s in %s:%d:%d\n", reason, loc->file_name,
> --
> 2.28.0.163.g6104cc2f0b6-goog
>
Uriel Guajardo Aug. 13, 2020, 8:49 p.m. UTC | #2
On Mon, Aug 10, 2020 at 3:43 PM Brendan Higgins
<brendanhiggins@google.com> wrote:
>
> On Thu, Aug 6, 2020 at 10:43 AM Uriel Guajardo
> <urielguajardojr@gmail.com> wrote:
> >
> > Integrates UBSAN into the KUnit testing framework. It fails KUnit tests
> > whenever it reports undefined behavior.
> >
> > Signed-off-by: Uriel Guajardo <urielguajardo@google.com>
>
> You should resend this to the UBSAN maintainers as well; they will
> need to sign off on this.
>
> In the future, make sure to run get_maintainers.pl

There are no listed UBSAN maintainers. Will instead resend to the
suggestions from get_maintainers.

>
> Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
>
> > ---
> >  lib/ubsan.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/lib/ubsan.c b/lib/ubsan.c
> > index cb9af3f6b77e..1460e2c828c8 100644
> > --- a/lib/ubsan.c
> > +++ b/lib/ubsan.c
> > @@ -14,6 +14,7 @@
> >  #include <linux/types.h>
> >  #include <linux/sched.h>
> >  #include <linux/uaccess.h>
> > +#include <kunit/test.h>
> >
> >  #include "ubsan.h"
> >
> > @@ -137,6 +138,7 @@ static void ubsan_prologue(struct source_location *loc, const char *reason)
> >  {
> >         current->in_ubsan++;
> >
> > +       kunit_fail_current_test();
> >         pr_err("========================================"
> >                 "========================================\n");
> >         pr_err("UBSAN: %s in %s:%d:%d\n", reason, loc->file_name,
> > --
> > 2.28.0.163.g6104cc2f0b6-goog
> >
Qian Cai Sept. 2, 2020, 12:52 p.m. UTC | #3
On Thu, Aug 06, 2020 at 05:43:26PM +0000, Uriel Guajardo wrote:
> Integrates UBSAN into the KUnit testing framework. It fails KUnit tests
> whenever it reports undefined behavior.
> 
> Signed-off-by: Uriel Guajardo <urielguajardo@google.com>

It looks like this patch had been merged into linux-next but the "[PATCH 1/2]
kunit: support failure from dynamic analysis tools" did not. Hence, it caused a
compiling failure.

lib/ubsan.c: In function ‘ubsan_prologue’:
lib/ubsan.c:141:2: error: implicit declaration of function ‘kunit_fail_current_test’; did you mean ‘kunit_init_test’? [-Werror=implicit-function-declaration]
  kunit_fail_current_test();
  ^~~~~~~~~~~~~~~~~~~~~~~
  kunit_init_test
cc1: some warnings being treated as errors

> ---
>  lib/ubsan.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/ubsan.c b/lib/ubsan.c
> index cb9af3f6b77e..1460e2c828c8 100644
> --- a/lib/ubsan.c
> +++ b/lib/ubsan.c
> @@ -14,6 +14,7 @@
>  #include <linux/types.h>
>  #include <linux/sched.h>
>  #include <linux/uaccess.h>
> +#include <kunit/test.h>
>  
>  #include "ubsan.h"
>  
> @@ -137,6 +138,7 @@ static void ubsan_prologue(struct source_location *loc, const char *reason)
>  {
>  	current->in_ubsan++;
>  
> +	kunit_fail_current_test();
>  	pr_err("========================================"
>  		"========================================\n");
>  	pr_err("UBSAN: %s in %s:%d:%d\n", reason, loc->file_name,
> -- 
> 2.28.0.163.g6104cc2f0b6-goog
>
Qian Cai Sept. 3, 2020, 12:38 p.m. UTC | #4
On Wed, Sep 02, 2020 at 08:52:24AM -0400, Qian Cai wrote:
> On Thu, Aug 06, 2020 at 05:43:26PM +0000, Uriel Guajardo wrote:
> > Integrates UBSAN into the KUnit testing framework. It fails KUnit tests
> > whenever it reports undefined behavior.
> > 
> > Signed-off-by: Uriel Guajardo <urielguajardo@google.com>
> 
> It looks like this patch had been merged into linux-next but the "[PATCH 1/2]
> kunit: support failure from dynamic analysis tools" did not. Hence, it caused a
> compiling failure.
> 
> lib/ubsan.c: In function ‘ubsan_prologue’:
> lib/ubsan.c:141:2: error: implicit declaration of function ‘kunit_fail_current_test’; did you mean ‘kunit_init_test’? [-Werror=implicit-function-declaration]
>   kunit_fail_current_test();
>   ^~~~~~~~~~~~~~~~~~~~~~~
>   kunit_init_test
> cc1: some warnings being treated as errors

Stephen, Shuah, can you revert this commit or pick up its dependency as well?

https://lore.kernel.org/linux-kselftest/20200813205722.1384108-1-urielguajardojr@gmail.com/

Still seeing this on today's linux-next build.

> 
> > ---
> >  lib/ubsan.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/lib/ubsan.c b/lib/ubsan.c
> > index cb9af3f6b77e..1460e2c828c8 100644
> > --- a/lib/ubsan.c
> > +++ b/lib/ubsan.c
> > @@ -14,6 +14,7 @@
> >  #include <linux/types.h>
> >  #include <linux/sched.h>
> >  #include <linux/uaccess.h>
> > +#include <kunit/test.h>
> >  
> >  #include "ubsan.h"
> >  
> > @@ -137,6 +138,7 @@ static void ubsan_prologue(struct source_location *loc, const char *reason)
> >  {
> >  	current->in_ubsan++;
> >  
> > +	kunit_fail_current_test();
> >  	pr_err("========================================"
> >  		"========================================\n");
> >  	pr_err("UBSAN: %s in %s:%d:%d\n", reason, loc->file_name,
> > -- 
> > 2.28.0.163.g6104cc2f0b6-goog
> >
Stephen Rothwell Sept. 9, 2020, 3 a.m. UTC | #5
Hi Qian,

On Thu, 3 Sep 2020 08:38:25 -0400 Qian Cai <cai@lca.pw> wrote:
>
> On Wed, Sep 02, 2020 at 08:52:24AM -0400, Qian Cai wrote:
> > On Thu, Aug 06, 2020 at 05:43:26PM +0000, Uriel Guajardo wrote:  
> > > Integrates UBSAN into the KUnit testing framework. It fails KUnit tests
> > > whenever it reports undefined behavior.
> > > 
> > > Signed-off-by: Uriel Guajardo <urielguajardo@google.com>  
> > 
> > It looks like this patch had been merged into linux-next but the "[PATCH 1/2]
> > kunit: support failure from dynamic analysis tools" did not. Hence, it caused a
> > compiling failure.
> > 
> > lib/ubsan.c: In function ‘ubsan_prologue’:
> > lib/ubsan.c:141:2: error: implicit declaration of function ‘kunit_fail_current_test’; did you mean ‘kunit_init_test’? [-Werror=implicit-function-declaration]
> >   kunit_fail_current_test();
> >   ^~~~~~~~~~~~~~~~~~~~~~~
> >   kunit_init_test
> > cc1: some warnings being treated as errors  
> 
> Stephen, Shuah, can you revert this commit or pick up its dependency as well?

Sorry, for the slow response ... this should be gone today.
diff mbox series

Patch

diff --git a/lib/ubsan.c b/lib/ubsan.c
index cb9af3f6b77e..1460e2c828c8 100644
--- a/lib/ubsan.c
+++ b/lib/ubsan.c
@@ -14,6 +14,7 @@ 
 #include <linux/types.h>
 #include <linux/sched.h>
 #include <linux/uaccess.h>
+#include <kunit/test.h>
 
 #include "ubsan.h"
 
@@ -137,6 +138,7 @@  static void ubsan_prologue(struct source_location *loc, const char *reason)
 {
 	current->in_ubsan++;
 
+	kunit_fail_current_test();
 	pr_err("========================================"
 		"========================================\n");
 	pr_err("UBSAN: %s in %s:%d:%d\n", reason, loc->file_name,