From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 15DAC158086 for ; Sat, 23 Oct 2021 22:19:51 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3A923E07A7; Sat, 23 Oct 2021 22:19:50 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0BC9EE07A7 for ; Sat, 23 Oct 2021 22:19:50 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DBD39343437 for ; Sat, 23 Oct 2021 22:19:48 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 51A28169 for ; Sat, 23 Oct 2021 22:19:47 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1635027483.afa38c053de48152beef9d8bf6726a4710bcba58.vapier@gentoo> Subject: [gentoo-commits] proj/sandbox:master commit in: libsandbox/, libsandbox/wrapper-funcs/, tests/ X-VCS-Repository: proj/sandbox X-VCS-Files: libsandbox/symbols.h.in libsandbox/wrapper-funcs/__futimesat64.c libsandbox/wrapper-funcs/__lutimes64.c libsandbox/wrapper-funcs/__utime64.c libsandbox/wrapper-funcs/__utimensat64.c libsandbox/wrapper-funcs/__utimes64.c libsandbox/wrapper-funcs/futimesat.c libsandbox/wrapper-funcs/lutimes.c libsandbox/wrapper-funcs/utime.c libsandbox/wrapper-funcs/utimensat.c libsandbox/wrapper-funcs/utimes.c tests/local.mk tests/test-skel-0.c tests/utimensat64-0.c tests/utimensat64-1.sh tests/utimensat64.at tests/utimensat64_static-0.c tests/utimensat64_static-1.sh tests/utimensat64_static.at X-VCS-Directories: libsandbox/wrapper-funcs/ libsandbox/ tests/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: afa38c053de48152beef9d8bf6726a4710bcba58 X-VCS-Branch: master Date: Sat, 23 Oct 2021 22:19:47 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: f5e95adb-45d4-4a4d-818f-c9568e43c86c X-Archives-Hash: 9d3bfb48aef6f6ac41b773e5b8cd419f commit: afa38c053de48152beef9d8bf6726a4710bcba58 Author: Mike Frysinger gentoo org> AuthorDate: Sat Oct 23 07:25:25 2021 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sat Oct 23 22:18:03 2021 +0000 URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=afa38c05 libsandbox: add 64-bit time_t wrappers This intercepts the C library 64-bit time_t interfaces. The syscall trace side will need more work first. Bug: https://bugs.gentoo.org/751241 Signed-off-by: Mike Frysinger gentoo.org> libsandbox/symbols.h.in | 5 +++++ libsandbox/wrapper-funcs/__futimesat64.c | 13 +++++++++++++ libsandbox/wrapper-funcs/__lutimes64.c | 13 +++++++++++++ libsandbox/wrapper-funcs/__utime64.c | 13 +++++++++++++ libsandbox/wrapper-funcs/__utimensat64.c | 13 +++++++++++++ libsandbox/wrapper-funcs/__utimes64.c | 13 +++++++++++++ libsandbox/wrapper-funcs/futimesat.c | 4 +++- libsandbox/wrapper-funcs/lutimes.c | 4 +++- libsandbox/wrapper-funcs/utime.c | 4 +++- libsandbox/wrapper-funcs/utimensat.c | 4 +++- libsandbox/wrapper-funcs/utimes.c | 4 +++- tests/local.mk | 2 ++ tests/test-skel-0.c | 4 ++-- tests/utimensat64-0.c | 3 +++ tests/utimensat64-1.sh | 9 +++++++++ tests/utimensat64.at | 1 + tests/utimensat64_static-0.c | 1 + tests/utimensat64_static-1.sh | 10 ++++++++++ tests/utimensat64_static.at | 1 + 19 files changed, 114 insertions(+), 7 deletions(-) diff --git a/libsandbox/symbols.h.in b/libsandbox/symbols.h.in index 0fe6eca..40c04e3 100644 --- a/libsandbox/symbols.h.in +++ b/libsandbox/symbols.h.in @@ -74,9 +74,14 @@ lremovexattr setxattr lsetxattr utime +__utime64 utimes +__utimes64 utimensat +__utimensat64 futimesat +__futimesat64 lutimes +__lutimes64 fork vfork diff --git a/libsandbox/wrapper-funcs/__futimesat64.c b/libsandbox/wrapper-funcs/__futimesat64.c new file mode 100644 index 0000000..9ad791e --- /dev/null +++ b/libsandbox/wrapper-funcs/__futimesat64.c @@ -0,0 +1,13 @@ +/* + * __futimesat64() wrapper. + * + * Copyright 1999-2021 Gentoo Foundation + * Licensed under the GPL-2 + */ + +/* + * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit time interface uses a + * different structure, but we never decode the time values in sandbox, so it doesn't matter to use. + */ +#define WRAPPER_SAFE() _SB_SAFE_AT(SB_NR_FUTIMESAT, STRING_NAME, dirfd, filename, 0) +#include "futimesat.c" diff --git a/libsandbox/wrapper-funcs/__lutimes64.c b/libsandbox/wrapper-funcs/__lutimes64.c new file mode 100644 index 0000000..edab47c --- /dev/null +++ b/libsandbox/wrapper-funcs/__lutimes64.c @@ -0,0 +1,13 @@ +/* + * __lutimes64() wrapper. + * + * Copyright 1999-2021 Gentoo Foundation + * Licensed under the GPL-2 + */ + +/* + * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit time interface uses a + * different structure, but we never decode the time values in sandbox, so it doesn't matter to use. + */ +#define WRAPPER_SAFE() _SB_SAFE(SB_NR_LUTIMES, STRING_NAME, filename) +#include "lutimes.c" diff --git a/libsandbox/wrapper-funcs/__utime64.c b/libsandbox/wrapper-funcs/__utime64.c new file mode 100644 index 0000000..4e1b573 --- /dev/null +++ b/libsandbox/wrapper-funcs/__utime64.c @@ -0,0 +1,13 @@ +/* + * __utime64() wrapper. + * + * Copyright 1999-2021 Gentoo Foundation + * Licensed under the GPL-2 + */ + +/* + * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit time interface uses a + * different structure, but we never decode the time values in sandbox, so it doesn't matter to use. + */ +#define WRAPPER_SAFE() _SB_SAFE(SB_NR_UTIME, STRING_NAME, filename) +#include "utime.c" diff --git a/libsandbox/wrapper-funcs/__utimensat64.c b/libsandbox/wrapper-funcs/__utimensat64.c new file mode 100644 index 0000000..4ef1c69 --- /dev/null +++ b/libsandbox/wrapper-funcs/__utimensat64.c @@ -0,0 +1,13 @@ +/* + * __utimensat64() wrapper. + * + * Copyright 1999-2021 Gentoo Foundation + * Licensed under the GPL-2 + */ + +/* + * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit time interface uses a + * different structure, but we never decode the time values in sandbox, so it doesn't matter to use. + */ +#define WRAPPER_SAFE() _SB_SAFE_AT(SB_NR_UTIMENSAT, STRING_NAME, dirfd, filename, flags) +#include "utimensat.c" diff --git a/libsandbox/wrapper-funcs/__utimes64.c b/libsandbox/wrapper-funcs/__utimes64.c new file mode 100644 index 0000000..3fa6688 --- /dev/null +++ b/libsandbox/wrapper-funcs/__utimes64.c @@ -0,0 +1,13 @@ +/* + * __utimes64() wrapper. + * + * Copyright 1999-2021 Gentoo Foundation + * Licensed under the GPL-2 + */ + +/* + * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit time interface uses a + * different structure, but we never decode the time values in sandbox, so it doesn't matter to use. + */ +#define WRAPPER_SAFE() _SB_SAFE(SB_NR_UTIMES, STRING_NAME, filename) +#include "utimes.c" diff --git a/libsandbox/wrapper-funcs/futimesat.c b/libsandbox/wrapper-funcs/futimesat.c index 6f6481b..bc1a966 100644 --- a/libsandbox/wrapper-funcs/futimesat.c +++ b/libsandbox/wrapper-funcs/futimesat.c @@ -7,5 +7,7 @@ #define WRAPPER_ARGS_PROTO int dirfd, const char *filename, const struct timeval times[2] #define WRAPPER_ARGS dirfd, filename, times -#define WRAPPER_SAFE() SB_SAFE_AT(dirfd, filename, 0) +#ifndef WRAPPER_SAFE +# define WRAPPER_SAFE() SB_SAFE_AT(dirfd, filename, 0) +#endif #include "__wrapper_simple.c" diff --git a/libsandbox/wrapper-funcs/lutimes.c b/libsandbox/wrapper-funcs/lutimes.c index 3192a33..fb9ae68 100644 --- a/libsandbox/wrapper-funcs/lutimes.c +++ b/libsandbox/wrapper-funcs/lutimes.c @@ -7,5 +7,7 @@ #define WRAPPER_ARGS_PROTO const char *filename, const struct timeval times[2] #define WRAPPER_ARGS filename, times -#define WRAPPER_SAFE() SB_SAFE(filename) +#ifndef WRAPPER_SAFE +# define WRAPPER_SAFE() SB_SAFE(filename) +#endif #include "__wrapper_simple.c" diff --git a/libsandbox/wrapper-funcs/utime.c b/libsandbox/wrapper-funcs/utime.c index f0a6814..4bbf374 100644 --- a/libsandbox/wrapper-funcs/utime.c +++ b/libsandbox/wrapper-funcs/utime.c @@ -7,5 +7,7 @@ #define WRAPPER_ARGS_PROTO const char *filename, const struct utimbuf *times #define WRAPPER_ARGS filename, times -#define WRAPPER_SAFE() SB_SAFE(filename) +#ifndef WRAPPER_SAFE +# define WRAPPER_SAFE() SB_SAFE(filename) +#endif #include "__wrapper_simple.c" diff --git a/libsandbox/wrapper-funcs/utimensat.c b/libsandbox/wrapper-funcs/utimensat.c index 840ff18..3baf89c 100644 --- a/libsandbox/wrapper-funcs/utimensat.c +++ b/libsandbox/wrapper-funcs/utimensat.c @@ -7,5 +7,7 @@ #define WRAPPER_ARGS_PROTO int dirfd, const char *filename, const struct timespec times[2], int flags #define WRAPPER_ARGS dirfd, filename, times, flags -#define WRAPPER_SAFE() SB_SAFE_AT(dirfd, filename, flags) +#ifndef WRAPPER_SAFE +# define WRAPPER_SAFE() SB_SAFE_AT(dirfd, filename, flags) +#endif #include "__wrapper_simple.c" diff --git a/libsandbox/wrapper-funcs/utimes.c b/libsandbox/wrapper-funcs/utimes.c index b117895..902c6f5 100644 --- a/libsandbox/wrapper-funcs/utimes.c +++ b/libsandbox/wrapper-funcs/utimes.c @@ -7,5 +7,7 @@ #define WRAPPER_ARGS_PROTO const char *filename, const struct timeval times[2] #define WRAPPER_ARGS filename, times -#define WRAPPER_SAFE() SB_SAFE(filename) +#ifndef WRAPPER_SAFE +# define WRAPPER_SAFE() SB_SAFE(filename) +#endif #include "__wrapper_simple.c" diff --git a/tests/local.mk b/tests/local.mk index aa2acac..86a8a65 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -81,7 +81,9 @@ check_PROGRAMS += \ %D%/unlinkat-0 \ %D%/utime-0 \ %D%/utimensat-0 \ + %D%/utimensat64-0 \ %D%/utimensat_static-0 \ + %D%/utimensat64_static-0 \ %D%/utimes-0 \ %D%/vfork-0 \ \ diff --git a/tests/test-skel-0.c b/tests/test-skel-0.c index 96e42ae..de88cf4 100644 --- a/tests/test-skel-0.c +++ b/tests/test-skel-0.c @@ -144,8 +144,8 @@ struct timespec *parse_timespec(const char *s) if (!strcmp(s, "NOW")) { times->tv_sec = time(0); } else { - long sec = 0, nsec = 0; - sscanf(s, "%li,%li", &sec, &nsec); + int64_t sec = 0, nsec = 0; + sscanf(s, "%" PRIi64 ",%" PRIi64, &sec, &nsec); times->tv_sec = sec; times->tv_nsec = nsec; } diff --git a/tests/utimensat64-0.c b/tests/utimensat64-0.c new file mode 100644 index 0000000..bbacef5 --- /dev/null +++ b/tests/utimensat64-0.c @@ -0,0 +1,3 @@ +#define _TIME_BITS 64 +#define _FILE_OFFSET_BITS 64 +#include "utimensat-0.c" diff --git a/tests/utimensat64-1.sh b/tests/utimensat64-1.sh new file mode 100755 index 0000000..2aebc5f --- /dev/null +++ b/tests/utimensat64-1.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# basic functionality check + +addwrite $PWD + +touch -r / file || exit 1 +utimensat64-0 0 AT_FDCWD . NULL 0 || exit 1 +utimensat64-0 0 AT_FDCWD file NULL 0 || exit 1 +[ file -nt / ] diff --git a/tests/utimensat64.at b/tests/utimensat64.at new file mode 100644 index 0000000..081d7d2 --- /dev/null +++ b/tests/utimensat64.at @@ -0,0 +1 @@ +SB_CHECK(1) diff --git a/tests/utimensat64_static-0.c b/tests/utimensat64_static-0.c new file mode 100644 index 0000000..73e7602 --- /dev/null +++ b/tests/utimensat64_static-0.c @@ -0,0 +1 @@ +#include "utimensat64-0.c" diff --git a/tests/utimensat64_static-1.sh b/tests/utimensat64_static-1.sh new file mode 100755 index 0000000..7b0355c --- /dev/null +++ b/tests/utimensat64_static-1.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# basic functionality check +[ "${at_xfail}" = "yes" ] && exit 77 # see trace-0 + +addwrite $PWD + +touch -r / file || exit 1 +utimensat64_static-0 0 AT_FDCWD . NULL 0 || exit 1 +utimensat64_static-0 0 AT_FDCWD file NULL 0 || exit 1 +[ file -nt / ] diff --git a/tests/utimensat64_static.at b/tests/utimensat64_static.at new file mode 100644 index 0000000..081d7d2 --- /dev/null +++ b/tests/utimensat64_static.at @@ -0,0 +1 @@ +SB_CHECK(1)