It looks like memmove() is broken by design for mips. This has come up
before in a previous thread, but with no proper resolution:
https://mailman.uclibc-ng.org/pipermail/devel/2016-April/000837.html
Per the man pages and posix specification, memmove() must work with
overlapping regions:
https://linux.die.net/man/3/memmovehttps://www.unix.com/man-page/POSIX/3posix/memmove/
Unless __ARCH_HAS_BWD_MEMCPY__ is set, the generic memmove() (which is
used for mips) will use memcpy() when the destination pointer is lower
than the source pointer, whether the regions are overlapping or not.
The author of libc/string/mips/memcpy.S is clear about the fact that
the mips implementation for memcpy() cannot deal with overlapping
regions. For Android, support for overlapping regions seems to be
required for memcpy(), so memcpy() will offload to memmove() when an
overlap occurs. How this could work with memmove() again offloading to
memcpy() on mips is lost on me.
I am observing the problem on a big-endian mips 34kc with OpenSSL. We
are using nginx as an https webserver with openssl as the ssl library.
We observed unexpected Message Authentication Code failures when data
was received.
After some detective work, we were observing the uClibc memmove()
occasionally copying a source buffer cache-line worth of zero's (32
bytes) to the destination buffer instead of the actual source data.
Needless to say, I do not know of a cipher that plays nicely when the
input buffer suffers from Alzheimer's. The OpenSSL implementation of
the GCM-128 cipher rightfully fails the tag check from it's perspective,
returning a Message Authentication Code failure to the client.
I quick solution is to always define __ARCH_HAS_BWD_MEMCPY__ on mips,
but I do not consider that a clear expression of the intent.
Can anyone comment on this?
- Pieter Smith
It looks like memmove() is broken by design for mips. This has come up
before in a previous thread, but with no proper resolution:
https://mailman.uclibc-ng.org/pipermail/devel/2016-April/000837.html
Per the man pages and posix specification, memmove() must work with
overlapping regions:
https://linux.die.net/man/3/memmovehttps://www.unix.com/man-page/POSIX/3posix/memmove/
Unless __ARCH_HAS_BWD_MEMCPY__ is set, the generic memmove() (which is
used for mips) will use memcpy() when the destination pointer is lower
than the source pointer, whether the regions are overlapping or not.
The author of libc/string/mips/memcpy.S is clear about the fact that
the mips implementation for memcpy() cannot deal with overlapping
regions. For Android, support for overlapping regions seems to be
required for memcpy(), so memcpy() will offload to memmove() when an
overlap occurs. How this could work with memmove() again offloading to
memcpy() on mips is lost on me.
I am observing the problem on a big-endian mips 34kc with OpenSSL. We
are using nginx as an https webserver with openssl as the ssl library.
We observed unexpected Message Authentication Code failures when data
was received.
After some detective work, we were observing the uClibc memmove()
occasionally copying a source buffer cache-line worth of zero's (32
bytes) to the destination buffer instead of the actual source data.
Needless to say, I do not know of a cipher that plays nicely when the
input buffer suffers from Alzheimer's. The OpenSSL implementation of
the GCM-128 cipher rightfully fails the tag check from it's perspective,
returning a Message Authentication Code failure to the client.
I quick solution is to always define __ARCH_HAS_BWD_MEMCPY__ on mips,
but I do not consider that a clear expression of the intent.
Can anyone comment on this?
- Pieter Smith
Hi,
I released uClibc-ng 1.0.29 today.
The new release contains mostly bugfixes for aarch64 and x86_64.
I use Gentoo/uClibc-ng since some weeks and found some
Glibc compatibility issues. I run chromium every day on my
Lenovo X200 with lates uClibc-ng.
I integrated gettext-tiny, which allows to use uClibc-ng for
Desktop when compiling software with i18n requirements.
Attention: arc4random is removed.
best regards
Waldemar
Hi,
this time it is only relevant to aarch64, as I imported it from glibc
without recognizing that I should have removed it.
best regards
Waldemar
> On 28. Feb 2018, at 11:34, Thomas Petazzoni <thomas.petazzoni(a)bootlin.com> wrote:
>
> Hello,
>
>> On Sun, 11 Feb 2018 12:07:33 -0800, Alexey Neyman wrote:
>>
>> I noticed a failure while compiling eudev against uClibc-ng 1.0.28 on
>> aarch64: it detected name_to_handle_at being declared in the header but
>> then failed to link because it is not implemented in uClibc-ng.
>>
>> Patch attached.
>
> A quick heads up on this: it is by far not the first time that I see
> uClibc headers having the prototype for a given function, and not the
> actual implementation of this function.
>
> It is confusing, and sometimes causes problems when just an autoconf
> compile test is done, and not an autoconf link test.
>
> Shouldn't this be fixed globally ?
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
> Embedded Linux and Kernel engineering
> http://bootlin.com
>
Hi,
I noticed a failure while compiling eudev against uClibc-ng 1.0.28 on
aarch64: it detected name_to_handle_at being declared in the header but
then failed to link because it is not implemented in uClibc-ng.
Patch attached.
Regards,
Alexey.
Signed-off-by: Guo Ren <ren_guo(a)c-sky.com>
---
libc/sysdeps/linux/csky/bits/fcntl.h | 55 ++++++++++++++++++++++++++++--------
1 file changed, 43 insertions(+), 12 deletions(-)
diff --git a/libc/sysdeps/linux/csky/bits/fcntl.h b/libc/sysdeps/linux/csky/bits/fcntl.h
index feacdad..15c1f52 100644
--- a/libc/sysdeps/linux/csky/bits/fcntl.h
+++ b/libc/sysdeps/linux/csky/bits/fcntl.h
@@ -2,11 +2,12 @@
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
#endif
-
#include <sys/types.h>
#ifdef __USE_GNU
# include <bits/uio.h>
#endif
+
+
/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
located on an ext2 file system */
#define O_ACCMODE 0003
@@ -24,12 +25,16 @@
#define O_FSYNC O_SYNC
#define O_ASYNC 020000
-#ifdef __USE_GNU
+#ifdef __USE_XOPEN2K8
# define O_DIRECTORY 040000 /* Must be a directory. */
# define O_NOFOLLOW 0100000 /* Do not follow links. */
+# define O_CLOEXEC 02000000 /* Set close_on_exec. */
+#endif
+
+#ifdef __USE_GNU
# define O_DIRECT 0200000 /* Direct disk access. */
-# define O_STREAMING 04000000/* streaming access */
-# define O_CLOEXEC 02000000 /* set close_on_exec */
+# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -63,7 +68,7 @@
#define F_SETLK64 13 /* Set record locking info (non-blocking). */
#define F_SETLKW64 14 /* Set record locking info (blocking). */
-#if defined __USE_BSD || defined __USE_XOPEN2K
+#if defined __USE_BSD || defined __USE_UNIX98
# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */
# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */
#endif
@@ -77,9 +82,13 @@
# define F_SETLEASE 1024 /* Set a lease. */
# define F_GETLEASE 1025 /* Enquire what lease is active. */
# define F_NOTIFY 1026 /* Request notfications on a directory. */
+# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
+ close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
-/* For F_[GET|SET]FL. */
+/* For F_[GET|SET]FD. */
#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
@@ -163,6 +172,28 @@ struct flock64
# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
#endif
+
+#if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
+/* Flags for SYNC_FILE_RANGE. */
+# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
+ in the range before performing the
+ write. */
+# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those
+ dirty pages in the range which are
+ not presently under writeback. */
+# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
+ the range after performing the
+ write. */
+
+/* Flags for SPLICE and VMSPLICE. */
+# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
+# define SPLICE_F_NONBLOCK 2 /* Don't block on the pipe splicing
+ (but we may still block on the fd
+ we splice from/to). */
+# define SPLICE_F_MORE 4 /* Expect more data. */
+# define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */
+#endif
+
__BEGIN_DECLS
#if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
@@ -171,23 +202,23 @@ __BEGIN_DECLS
extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
__THROW;
-
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
- unsigned int __flags);
+ unsigned int __flags);
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
- size_t __count, unsigned int __flags);
+ size_t __count, unsigned int __flags);
/* Splice two files together. */
extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout,
- __off64_t *__offout, size_t __len,
- unsigned int __flags);
+ __off64_t *__offout, size_t __len,
+ unsigned int __flags);
/* In-kernel implementation of tee for pipe buffers. */
extern ssize_t tee (int __fdin, int __fdout, size_t __len,
- unsigned int __flags);
+ unsigned int __flags);
#endif
__END_DECLS
+
--
2.7.4
Fixes a buildroot build error with ffmpeg
In file included from /home/bernd/buildroot/output/host/aarch64-buildroot-linux-uclibc/sysroot/usr/include/signal.h:329:0,
from fftools/ffmpeg.h:26,
from fftools/ffmpeg_opt.c:23:
/home/bernd/buildroot/output/host/aarch64-buildroot-linux-uclibc/sysroot/usr/include/sys/ucontext.h:52:16:
error: field 'uc_mcontext' has incomplete type
mcontext_t uc_mcontext;
^~~~~~~~~~~
using this defconfig:
BR2_aarch64=y
BR2_PACKAGE_FFMPEG=y
sys/ucontext.h for other archs already include bits/sigcontext.h,
on aarch64 this is needed as well.
Signed-off-by: Bernd Kuhls <bernd.kuhls(a)t-online.de>
---
libc/sysdeps/linux/aarch64/sys/ucontext.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libc/sysdeps/linux/aarch64/sys/ucontext.h b/libc/sysdeps/linux/aarch64/sys/ucontext.h
index d17458896..dc7303b54 100644
--- a/libc/sysdeps/linux/aarch64/sys/ucontext.h
+++ b/libc/sysdeps/linux/aarch64/sys/ucontext.h
@@ -26,6 +26,10 @@
#include <sys/procfs.h>
+/* We need the signal context definitions even if they are not used
+ included in <signal.h>. */
+#include <bits/sigcontext.h>
+
typedef elf_greg_t greg_t;
/* Container for all general registers. */
--
2.11.0