All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] db: Fix timespec length assumptions
@ 2020-02-14 22:33 Khem Raj
  2020-02-15  4:10 ` Bruce Ashfield
  0 siblings, 1 reply; 3+ messages in thread
From: Khem Raj @ 2020-02-14 22:33 UTC (permalink / raw)
  To: openembedded-core

This should fix the vdso crashes seen with kernel 5.0+

python3[11312] general protection fault ip:b7e966b0 sp:bf8175cc error:0 in libc.so[b7e8b000+6b000]

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Bruce Ashfield <bruce.ashfield@gmail.com>
---
 ...001-clock-Do-not-define-own-timespec.patch | 45 +++++++++++++++++++
 meta/recipes-support/db/db_5.3.28.bb          |  1 +
 2 files changed, 46 insertions(+)
 create mode 100644 meta/recipes-support/db/db/0001-clock-Do-not-define-own-timespec.patch

diff --git a/meta/recipes-support/db/db/0001-clock-Do-not-define-own-timespec.patch b/meta/recipes-support/db/db/0001-clock-Do-not-define-own-timespec.patch
new file mode 100644
index 0000000000..9d51a44a26
--- /dev/null
+++ b/meta/recipes-support/db/db/0001-clock-Do-not-define-own-timespec.patch
@@ -0,0 +1,45 @@
+From 96b303caf70a7635953c36e5bfb9ad6e75cb7637 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Fri, 14 Feb 2020 14:12:59 -0800
+Subject: [PATCH] clock: Do not define own timespec
+
+timespec is provided by libc and its best left to libc
+os_gettime takes a db_timespec and passed its address to clock_gettime
+which assumes that db_timespec and timespec are same but actually
+its 12-bytes here and libc has 16-bytes
+
+This can cause problems especially with 64bit time_t
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/dbinc/clock.h | 17 +----------------
+ 1 file changed, 1 insertion(+), 16 deletions(-)
+
+--- a/src/dbinc/clock.h
++++ b/src/dbinc/clock.h
+@@ -44,22 +44,8 @@
+ extern "C" {
+ #endif
+ 
+-/*
+- * This declaration is POSIX-compatible.  Because there are lots of different
+- * time.h include file patterns out there, it's easier to declare our own name
+- * in all cases than to try and discover if a system has a struct timespec.
+- * For the same reason, and because we'd have to #include <sys/time.h> in db.h,
+- * we don't export any timespec structures in the DB API, even in places where
+- * it would make sense, like the replication statistics information.
+- */
+-typedef struct {
+-	time_t	tv_sec;				/* seconds */
+-#ifdef HAVE_MIXED_SIZE_ADDRESSING
+-	int32_t tv_nsec;
+-#else
+-	long	tv_nsec;			/* nanoseconds */
+-#endif
+-} db_timespec;
++#include <time.h>
++#define db_timespec struct timespec
+ 
+ /* Operations on timespecs */
+ #undef	timespecclear
diff --git a/meta/recipes-support/db/db_5.3.28.bb b/meta/recipes-support/db/db_5.3.28.bb
index a2969055a6..badb79f9ea 100644
--- a/meta/recipes-support/db/db_5.3.28.bb
+++ b/meta/recipes-support/db/db_5.3.28.bb
@@ -26,6 +26,7 @@ SRC_URI += "file://fix-parallel-build.patch \
             file://0001-configure-Add-explicit-tag-options-to-libtool-invoca.patch \
             file://sequence-type.patch \
             file://0001-Fix-libc-compatibility-by-renaming-atomic_init-API.patch \
+            file://0001-clock-Do-not-define-own-timespec.patch \
            "
 # We are not interested in official latest 6.x versions;
 # let's track what debian is using.
-- 
2.25.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] db: Fix timespec length assumptions
  2020-02-14 22:33 [PATCH] db: Fix timespec length assumptions Khem Raj
@ 2020-02-15  4:10 ` Bruce Ashfield
  2020-02-17 19:40   ` Bruce Ashfield
  0 siblings, 1 reply; 3+ messages in thread
From: Bruce Ashfield @ 2020-02-15  4:10 UTC (permalink / raw)
  To: Khem Raj; +Cc: Patches and discussions about the oe-core layer

On Fri, Feb 14, 2020 at 5:33 PM Khem Raj <raj.khem@gmail.com> wrote:
>
> This should fix the vdso crashes seen with kernel 5.0+

cool. I'll test this locally and follow up over the weekend.

Bruce

>
> python3[11312] general protection fault ip:b7e966b0 sp:bf8175cc error:0 in libc.so[b7e8b000+6b000]
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> Cc: Bruce Ashfield <bruce.ashfield@gmail.com>
> ---
>  ...001-clock-Do-not-define-own-timespec.patch | 45 +++++++++++++++++++
>  meta/recipes-support/db/db_5.3.28.bb          |  1 +
>  2 files changed, 46 insertions(+)
>  create mode 100644 meta/recipes-support/db/db/0001-clock-Do-not-define-own-timespec.patch
>
> diff --git a/meta/recipes-support/db/db/0001-clock-Do-not-define-own-timespec.patch b/meta/recipes-support/db/db/0001-clock-Do-not-define-own-timespec.patch
> new file mode 100644
> index 0000000000..9d51a44a26
> --- /dev/null
> +++ b/meta/recipes-support/db/db/0001-clock-Do-not-define-own-timespec.patch
> @@ -0,0 +1,45 @@
> +From 96b303caf70a7635953c36e5bfb9ad6e75cb7637 Mon Sep 17 00:00:00 2001
> +From: Khem Raj <raj.khem@gmail.com>
> +Date: Fri, 14 Feb 2020 14:12:59 -0800
> +Subject: [PATCH] clock: Do not define own timespec
> +
> +timespec is provided by libc and its best left to libc
> +os_gettime takes a db_timespec and passed its address to clock_gettime
> +which assumes that db_timespec and timespec are same but actually
> +its 12-bytes here and libc has 16-bytes
> +
> +This can cause problems especially with 64bit time_t
> +
> +Upstream-Status: Pending
> +Signed-off-by: Khem Raj <raj.khem@gmail.com>
> +---
> + src/dbinc/clock.h | 17 +----------------
> + 1 file changed, 1 insertion(+), 16 deletions(-)
> +
> +--- a/src/dbinc/clock.h
> ++++ b/src/dbinc/clock.h
> +@@ -44,22 +44,8 @@
> + extern "C" {
> + #endif
> +
> +-/*
> +- * This declaration is POSIX-compatible.  Because there are lots of different
> +- * time.h include file patterns out there, it's easier to declare our own name
> +- * in all cases than to try and discover if a system has a struct timespec.
> +- * For the same reason, and because we'd have to #include <sys/time.h> in db.h,
> +- * we don't export any timespec structures in the DB API, even in places where
> +- * it would make sense, like the replication statistics information.
> +- */
> +-typedef struct {
> +-      time_t  tv_sec;                         /* seconds */
> +-#ifdef HAVE_MIXED_SIZE_ADDRESSING
> +-      int32_t tv_nsec;
> +-#else
> +-      long    tv_nsec;                        /* nanoseconds */
> +-#endif
> +-} db_timespec;
> ++#include <time.h>
> ++#define db_timespec struct timespec
> +
> + /* Operations on timespecs */
> + #undef        timespecclear
> diff --git a/meta/recipes-support/db/db_5.3.28.bb b/meta/recipes-support/db/db_5.3.28.bb
> index a2969055a6..badb79f9ea 100644
> --- a/meta/recipes-support/db/db_5.3.28.bb
> +++ b/meta/recipes-support/db/db_5.3.28.bb
> @@ -26,6 +26,7 @@ SRC_URI += "file://fix-parallel-build.patch \
>              file://0001-configure-Add-explicit-tag-options-to-libtool-invoca.patch \
>              file://sequence-type.patch \
>              file://0001-Fix-libc-compatibility-by-renaming-atomic_init-API.patch \
> +            file://0001-clock-Do-not-define-own-timespec.patch \
>             "
>  # We are not interested in official latest 6.x versions;
>  # let's track what debian is using.
> --
> 2.25.0
>


-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] db: Fix timespec length assumptions
  2020-02-15  4:10 ` Bruce Ashfield
@ 2020-02-17 19:40   ` Bruce Ashfield
  0 siblings, 0 replies; 3+ messages in thread
From: Bruce Ashfield @ 2020-02-17 19:40 UTC (permalink / raw)
  To: Khem Raj, Richard Purdie; +Cc: Patches and discussions about the oe-core layer

On Fri, Feb 14, 2020 at 11:10 PM Bruce Ashfield
<bruce.ashfield@gmail.com> wrote:
>
> On Fri, Feb 14, 2020 at 5:33 PM Khem Raj <raj.khem@gmail.com> wrote:
> >
> > This should fix the vdso crashes seen with kernel 5.0+
>
> cool. I'll test this locally and follow up over the weekend.

I can confirm that 32bit x86 + musl no longer traps for me with this
patch in place.

I'll bump the 5.4 recipes again, retest and then send the patches to
make them the default.

Bruce

>
> Bruce
>
> >
> > python3[11312] general protection fault ip:b7e966b0 sp:bf8175cc error:0 in libc.so[b7e8b000+6b000]
> >
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > Cc: Bruce Ashfield <bruce.ashfield@gmail.com>
> > ---
> >  ...001-clock-Do-not-define-own-timespec.patch | 45 +++++++++++++++++++
> >  meta/recipes-support/db/db_5.3.28.bb          |  1 +
> >  2 files changed, 46 insertions(+)
> >  create mode 100644 meta/recipes-support/db/db/0001-clock-Do-not-define-own-timespec.patch
> >
> > diff --git a/meta/recipes-support/db/db/0001-clock-Do-not-define-own-timespec.patch b/meta/recipes-support/db/db/0001-clock-Do-not-define-own-timespec.patch
> > new file mode 100644
> > index 0000000000..9d51a44a26
> > --- /dev/null
> > +++ b/meta/recipes-support/db/db/0001-clock-Do-not-define-own-timespec.patch
> > @@ -0,0 +1,45 @@
> > +From 96b303caf70a7635953c36e5bfb9ad6e75cb7637 Mon Sep 17 00:00:00 2001
> > +From: Khem Raj <raj.khem@gmail.com>
> > +Date: Fri, 14 Feb 2020 14:12:59 -0800
> > +Subject: [PATCH] clock: Do not define own timespec
> > +
> > +timespec is provided by libc and its best left to libc
> > +os_gettime takes a db_timespec and passed its address to clock_gettime
> > +which assumes that db_timespec and timespec are same but actually
> > +its 12-bytes here and libc has 16-bytes
> > +
> > +This can cause problems especially with 64bit time_t
> > +
> > +Upstream-Status: Pending
> > +Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > +---
> > + src/dbinc/clock.h | 17 +----------------
> > + 1 file changed, 1 insertion(+), 16 deletions(-)
> > +
> > +--- a/src/dbinc/clock.h
> > ++++ b/src/dbinc/clock.h
> > +@@ -44,22 +44,8 @@
> > + extern "C" {
> > + #endif
> > +
> > +-/*
> > +- * This declaration is POSIX-compatible.  Because there are lots of different
> > +- * time.h include file patterns out there, it's easier to declare our own name
> > +- * in all cases than to try and discover if a system has a struct timespec.
> > +- * For the same reason, and because we'd have to #include <sys/time.h> in db.h,
> > +- * we don't export any timespec structures in the DB API, even in places where
> > +- * it would make sense, like the replication statistics information.
> > +- */
> > +-typedef struct {
> > +-      time_t  tv_sec;                         /* seconds */
> > +-#ifdef HAVE_MIXED_SIZE_ADDRESSING
> > +-      int32_t tv_nsec;
> > +-#else
> > +-      long    tv_nsec;                        /* nanoseconds */
> > +-#endif
> > +-} db_timespec;
> > ++#include <time.h>
> > ++#define db_timespec struct timespec
> > +
> > + /* Operations on timespecs */
> > + #undef        timespecclear
> > diff --git a/meta/recipes-support/db/db_5.3.28.bb b/meta/recipes-support/db/db_5.3.28.bb
> > index a2969055a6..badb79f9ea 100644
> > --- a/meta/recipes-support/db/db_5.3.28.bb
> > +++ b/meta/recipes-support/db/db_5.3.28.bb
> > @@ -26,6 +26,7 @@ SRC_URI += "file://fix-parallel-build.patch \
> >              file://0001-configure-Add-explicit-tag-options-to-libtool-invoca.patch \
> >              file://sequence-type.patch \
> >              file://0001-Fix-libc-compatibility-by-renaming-atomic_init-API.patch \
> > +            file://0001-clock-Do-not-define-own-timespec.patch \
> >             "
> >  # We are not interested in official latest 6.x versions;
> >  # let's track what debian is using.
> > --
> > 2.25.0
> >
>
>
> --
> - Thou shalt not follow the NULL pointer, for chaos and madness await
> thee at its end
> - "Use the force Harry" - Gandalf, Star Trek II



-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-17 19:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14 22:33 [PATCH] db: Fix timespec length assumptions Khem Raj
2020-02-15  4:10 ` Bruce Ashfield
2020-02-17 19:40   ` Bruce Ashfield

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.