All of lore.kernel.org
 help / color / mirror / Atom feed
* v2: Y2038: Sanity checker for non-64-bit time and file functions
@ 2022-12-16 11:46 Ola x Nilsson
  2022-12-16 11:46 ` [PATCH RFC v2 1/2] Add QA check for 32 bit time and file offset functions Ola x Nilsson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ola x Nilsson @ 2022-12-16 11:46 UTC (permalink / raw)
  To: openembedded-core

v2:

Renamed conf/distro/time64.conf -> conf/distro/time64.inc
Use SITEINFO_BITS to select when to apply GLIBC_64BIT_TIME_FLAGS.


I did not add _LARGEFILE to the option yet as I do not believe it is
the right place.
The _TIME_BITS=64 and _FILE_OFFSET_BITS=64 option redefine types and
functions.  The _LARGEFILE* options add new types and functions.  The
purpose of the time64.inc file is to enforce the redefinition of
time_t and other types in code that has not bothered before.  The
_LARGEFILE* options should probably only be used by code that has
explicitly chosen to use these glibc extensions, possible configured
by autoconf.

--
Ola Nilsson







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

* [PATCH RFC v2 1/2] Add QA check for 32 bit time and file offset functions
  2022-12-16 11:46 v2: Y2038: Sanity checker for non-64-bit time and file functions Ola x Nilsson
@ 2022-12-16 11:46 ` Ola x Nilsson
  2022-12-16 11:46 ` [PATCH RFC v2 2/2] time64.inc: Include to enable 64 bit time flags Ola x Nilsson
  2022-12-16 11:47 ` [OE-core] v2: Y2038: Sanity checker for non-64-bit time and file functions Ola x Nilsson
  2 siblings, 0 replies; 4+ messages in thread
From: Ola x Nilsson @ 2022-12-16 11:46 UTC (permalink / raw)
  To: openembedded-core

Check for known symbols that should have been redirected to 64bit
variants when -D_FILE_OFFSET_BITS=64 and -D_TIME_BITS=64 are set.

Signed-off-by: Ola x Nilsson <olani@axis.com>
---
 meta/classes-global/insane.bbclass | 132 +++++++++++++++++++++++++++++
 1 file changed, 132 insertions(+)

diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass
index df2c40c3c5..b0e99c4c3f 100644
--- a/meta/classes-global/insane.bbclass
+++ b/meta/classes-global/insane.bbclass
@@ -506,6 +506,138 @@ def package_qa_check_symlink_to_sysroot(path, name, d, elf, messages):
                 trimmed = path.replace(os.path.join (d.getVar("PKGDEST"), name), "")
                 oe.qa.add_message(messages, "symlink-to-sysroot", "Symlink %s in %s points to TMPDIR" % (trimmed, name))
 
+QAPATHTEST[32bit-time] = "check_32bit_symbols"
+def check_32bit_symbols(path, packagename, d, elf, messages):
+    """
+    Check that ELF files do not use any 32 bit time APIs from glibc.
+    """
+    # TODO: We should have some DISTRO_FEATURE flag to check here
+    # if '-D_TIME_BITS=64' not in d.getVar('GLIBC_64BIT_TIME_FLAGS'):
+    #     # No use checking if the feature is not enabled?
+    #     return
+    import re
+    # This list is manually constructed by searching the image folder of the
+    # glibc recipe for __USE_TIME_BITS64.  There is no good way to do this
+    # automatically.
+    api32 = {
+        # /usr/include/time.h
+        "clock_getres", "clock_gettime", "clock_nanosleep", "clock_settime",
+        "ctime", "ctime_r", "difftime", "gmtime", "gmtime_r", "localtime",
+        "localtime_r", "mktime", "nanosleep", "time", "timegm", "timelocal",
+        "timer_gettime", "timer_settime", "timespec_get", "timespec_getres",
+        # /usr/include/bits/time.h
+        "clock_adjtime",
+        # /usr/include/signal.h
+        "sigtimedwait",
+        # /usr/include/sys/time.h
+        "futimes", "futimesat", "getitimer", "gettimeofday", "lutimes",
+        "setitimer", "settimeofday", "utimes",
+        # /usr/include/sys/timex.h
+        "adjtimex", "ntp_adjtime", "ntp_gettime", "ntp_gettimex",
+        # /usr/include/sys/wait.h
+        "wait3", "wait4",
+        # /usr/include/sys/stat.h
+        "fstat", "fstat64", "fstatat", "fstatat64", "futimens", "lstat",
+        "lstat64", "stat", "stat64", "utimensat",
+        # /usr/include/sys/poll.h
+        "ppoll",
+        # /usr/include/sys/resource.h
+        "getrusage",
+        # /usr/include/sys/ioctl.h
+        "ioctl",
+        # /usr/include/sys/select.h
+        "select", "pselect",
+        # /usr/include/sys/prctl.h
+        "prctl",
+        # /usr/include/sys/epoll.h
+        "epoll_pwait2",
+        # /usr/include/sys/timerfd.h
+        "timerfd_gettime", "timerfd_settime",
+        # /usr/include/sys/socket.h
+        "getsockopt", "recvmmsg", "recvmsg", "sendmmsg", "sendmsg",
+        "setsockopt",
+        # /usr/include/sys/msg.h
+        "msgctl",
+        # /usr/include/sys/sem.h
+        "semctl", "semtimedop",
+        # /usr/include/sys/shm.h
+        "shmctl",
+        # /usr/include/pthread.h
+        "pthread_clockjoin_np", "pthread_cond_clockwait",
+        "pthread_cond_timedwait", "pthread_mutex_clocklock",
+        "pthread_mutex_timedlock", "pthread_rwlock_clockrdlock",
+        "pthread_rwlock_clockwrlock", "pthread_rwlock_timedrdlock",
+        "pthread_rwlock_timedwrlock", "pthread_timedjoin_np",
+        # /usr/include/semaphore.h
+        "sem_clockwait", "sem_timedwait",
+        # /usr/include/threads.h
+        "cnd_timedwait", "mtx_timedlock", "thrd_sleep",
+        # /usr/include/aio.h
+        "aio_cancel", "aio_error", "aio_read", "aio_return", "aio_suspend",
+        "aio_write", "lio_listio",
+        # /usr/include/mqueue.h
+        "mq_timedreceive", "mq_timedsend",
+        # /usr/include/glob.h
+        "glob", "glob64", "globfree", "globfree64",
+        # /usr/include/sched.h
+        "sched_rr_get_interval",
+        # /usr/include/fcntl.h
+        "fcntl", "fcntl64",
+        # /usr/include/utime.h
+        "utime",
+        # /usr/include/ftw.h
+        "ftw", "ftw64", "nftw", "nftw64",
+        # /usr/include/fts.h
+        "fts64_children", "fts64_close", "fts64_open", "fts64_read",
+        "fts64_set", "fts_children", "fts_close", "fts_open", "fts_read",
+        "fts_set",
+        # /usr/include/netdb.h
+        "gai_suspend",
+    }
+
+    ptrn = re.compile(
+        r'''
+        (?P<value>[\da-fA-F]+) \s+
+        (?P<flags>[lgu! ][w ][C ][W ][Ii ][dD ]F) \s+
+        (?P<section>\*UND\*) \s+
+        (?P<alignment>(?P<size>[\da-fA-F]+)) \s+
+        (?P<symbol>
+        ''' +
+        r'(?P<notag>' + r'|'.join(sorted(api32)) + r')' +
+        r'''
+        (@+(?P<tag>GLIBC_\d+\.\d+\S*)))
+        ''', re.VERBOSE
+    )
+
+    # elf is a oe.qa.ELFFile object
+    if elf is not None:
+        phdrs = elf.run_objdump("-tw", d)
+        syms = re.finditer(ptrn, phdrs)
+        usedapis = {sym.group('notag') for sym in syms}
+        if usedapis:
+            elfpath = package_qa_clean_path(path, d, packagename)
+            # Remove any .debug dir, heuristic that probably works
+            # At this point, any symbol information is stripped into the debug
+            # package, so that is the only place we will find them.
+            elfpath = elfpath.replace('.debug/', '')
+            allowed = (
+                d.getVarFlag(
+                    'INSANE_SKIP:' + d.getVar('PN'), elfpath.replace('/', '_')
+                ) or ''
+            ).split()
+            usedapis -= set(allowed)
+            if usedapis:
+                msgformat = elfpath + " uses 32-bit api '%s'"
+                for sym in usedapis:
+                    oe.qa.add_message(messages, '32bit-time', msgformat % sym)
+                oe.qa.add_message(
+                    messages, '32bit-time',
+                    'Suppress with INSANE_SKIP:%s[%s] = "%s"' % (
+                        d.getVar('PN'), elfpath.replace('/', '_'),
+                        ' '.join(usedapis)
+                    )
+                )
+
 # Check license variables
 do_populate_lic[postfuncs] += "populate_lic_qa_checksum"
 python populate_lic_qa_checksum() {
-- 
2.30.2



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

* [PATCH RFC v2 2/2] time64.inc: Include to enable 64 bit time flags
  2022-12-16 11:46 v2: Y2038: Sanity checker for non-64-bit time and file functions Ola x Nilsson
  2022-12-16 11:46 ` [PATCH RFC v2 1/2] Add QA check for 32 bit time and file offset functions Ola x Nilsson
@ 2022-12-16 11:46 ` Ola x Nilsson
  2022-12-16 11:47 ` [OE-core] v2: Y2038: Sanity checker for non-64-bit time and file functions Ola x Nilsson
  2 siblings, 0 replies; 4+ messages in thread
From: Ola x Nilsson @ 2022-12-16 11:46 UTC (permalink / raw)
  To: openembedded-core

Signed-off-by: Ola x Nilsson <olani@axis.com>
---
 meta/conf/distro/include/time64.inc | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 meta/conf/distro/include/time64.inc

diff --git a/meta/conf/distro/include/time64.inc b/meta/conf/distro/include/time64.inc
new file mode 100644
index 0000000000..122ee6bf4c
--- /dev/null
+++ b/meta/conf/distro/include/time64.inc
@@ -0,0 +1,20 @@
+GLIBC_64BIT_TIME_FLAGS = "-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64"
+
+TARGET_CC_ARCH:append = " ${@oe.utils.conditional('SITEINFO_BITS', '32', '${GLIBC_64BIT_TIME_FLAGS}', '', d)}"
+
+GLIBC_64BIT_TIME_FLAGS:pn-glibc = ""
+GLIBC_64BIT_TIME_FLAGS:pn-glibc-tests = ""
+# pipewire-v4l2 explicitly sets _FILE_OFFSET_BITS=32 to get access to
+# both 32 and 64 bit file APIs.  But it does not handle the time side?
+# Needs further investigation
+GLIBC_64BIT_TIME_FLAGS:pn-pipewire = ""
+GLIBC_64BIT_TIME_FLAGS:pn-gcc-sanitizers = ""
+
+INSANE_SKIP:libstd-rs[_usr_lib_rustlib_armv7-poky-linux-gnueabihf_lib_libstd.so] = "clock_gettime gettime fcntl fstat64 fstatat64 getsockopt ioctl lstat64 nanosleep prctl recvmsg sendmsg setsockopt stat64"
+INSANE_SKIP:librsvg[_usr_bin_rsvg-convert] = "fcntl fstat64 prctl stat64 clock_gettime"
+INSANE_SKIP:librsvg[_usr_lib_librsvg-2.so.2.48.0] = "fcntl lstat64 setsockopt sendmsg fstat64 getsockopt ioctl nanosleep timegm fstatat64 prctl mktime gmtime_r recvmsg stat64 clock_gettime localtime_r"
+
+# libpulsedsp.so is a preload-library that hooks libc functions
+INSANE_SKIP:pulseaudio[_usr_lib_pulseaudio_libpulsedsp.so] = "setsockopt fcntl"
+
+
-- 
2.30.2



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

* Re: [OE-core] v2: Y2038: Sanity checker for non-64-bit time and file functions
  2022-12-16 11:46 v2: Y2038: Sanity checker for non-64-bit time and file functions Ola x Nilsson
  2022-12-16 11:46 ` [PATCH RFC v2 1/2] Add QA check for 32 bit time and file offset functions Ola x Nilsson
  2022-12-16 11:46 ` [PATCH RFC v2 2/2] time64.inc: Include to enable 64 bit time flags Ola x Nilsson
@ 2022-12-16 11:47 ` Ola x Nilsson
  2 siblings, 0 replies; 4+ messages in thread
From: Ola x Nilsson @ 2022-12-16 11:47 UTC (permalink / raw)
  To: Ola x Nilsson; +Cc: openembedded-core


On Fri, Dec 16 2022, Ola x Nilsson wrote:

> v2:
>
> Renamed conf/distro/time64.conf -> conf/distro/time64.inc
> Use SITEINFO_BITS to select when to apply GLIBC_64BIT_TIME_FLAGS.
>
>
> I did not add _LARGEFILE to the option yet as I do not believe it is
> the right place.
> The _TIME_BITS=64 and _FILE_OFFSET_BITS=64 option redefine types and
> functions.  The _LARGEFILE* options add new types and functions.  The
> purpose of the time64.inc file is to enforce the redefinition of
> time_t and other types in code that has not bothered before.  The
> _LARGEFILE* options should probably only be used by code that has
> explicitly chosen to use these glibc extensions, possible configured
> by autoconf.

I'm working on time64 support in pulseaudio at the moment.  If anyone
else has started on pulseaudio I can move on to something else. 

-- 
Ola x Nilsson


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

end of thread, other threads:[~2022-12-16 11:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-16 11:46 v2: Y2038: Sanity checker for non-64-bit time and file functions Ola x Nilsson
2022-12-16 11:46 ` [PATCH RFC v2 1/2] Add QA check for 32 bit time and file offset functions Ola x Nilsson
2022-12-16 11:46 ` [PATCH RFC v2 2/2] time64.inc: Include to enable 64 bit time flags Ola x Nilsson
2022-12-16 11:47 ` [OE-core] v2: Y2038: Sanity checker for non-64-bit time and file functions Ola x Nilsson

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.