parent
e6614da568
commit
a6daf903fa
@ -1,83 +0,0 @@
|
|||||||
From d5865759f8698f1c75339451a26fa3ae00276a51 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Guillem Jover <guillem@hadrons.org>
|
|
||||||
Date: Thu, 25 Aug 2022 00:52:43 +0200
|
|
||||||
Subject: [PATCH] test: Fix explicit_bzero() test on the Hurd
|
|
||||||
|
|
||||||
On the Hurd a small read(3) might end up (indirectly) copying the data
|
|
||||||
on the stack, which we will end up finding even when we have cleared
|
|
||||||
the buffer.
|
|
||||||
|
|
||||||
To avoid these side effects, we add a new function, that we force not
|
|
||||||
to be inlined, so that we can reuse the same stack space, that will
|
|
||||||
blank any possible stack side effects. This should be portable
|
|
||||||
regardless of stack growing up or down.
|
|
||||||
|
|
||||||
Diagnosis-by: Samuel Thibault <sthibault@debian.org>
|
|
||||||
---
|
|
||||||
COPYING | 2 +-
|
|
||||||
test/explicit_bzero.c | 15 +++++++++++++++
|
|
||||||
2 files changed, 16 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/COPYING b/COPYING
|
|
||||||
index 67223d4..cf43edd 100644
|
|
||||||
--- a/COPYING
|
|
||||||
+++ b/COPYING
|
|
||||||
@@ -369,7 +369,7 @@ Copyright:
|
|
||||||
Copyright © 2014 Theo de Raadt <deraadt@openbsd.org>
|
|
||||||
Copyright © 2014 Google Inc.
|
|
||||||
Copyright © 2015 Michael Felt <aixtools@gmail.com>
|
|
||||||
- Copyright © 2015 Guillem Jover <guillem@hadrons.org>
|
|
||||||
+ Copyright © 2015, 2022 Guillem Jover <guillem@hadrons.org>
|
|
||||||
License: ISC
|
|
||||||
Permission to use, copy, modify, and distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
diff --git a/test/explicit_bzero.c b/test/explicit_bzero.c
|
|
||||||
index 74993c2..bee29de 100644
|
|
||||||
--- a/test/explicit_bzero.c
|
|
||||||
+++ b/test/explicit_bzero.c
|
|
||||||
@@ -1,6 +1,7 @@
|
|
||||||
/* $OpenBSD: explicit_bzero.c,v 1.7 2021/03/27 11:17:58 bcook Exp $ */
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2014 Google Inc.
|
|
||||||
+ * Copyright (c) 2022 Guillem Jover <guillem@hadrons.org>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
@@ -123,6 +124,18 @@ populate_secret(char *buf, ssize_t len)
|
|
||||||
ASSERT_EQ(0, close(fds[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
+static void __attribute__((__noinline__))
|
|
||||||
+blank_stack_side_effects(char *buf, size_t len)
|
|
||||||
+{
|
|
||||||
+ char scratch[SECRETBYTES * 4];
|
|
||||||
+
|
|
||||||
+ /* If the read(3) in populate_secret() wrote into the stack, as it
|
|
||||||
+ * might happen on the Hurd for small data, then we might incorrectly
|
|
||||||
+ * detect the wrong secret on the stack. */
|
|
||||||
+ memset(scratch, 0xFF, sizeof(scratch));
|
|
||||||
+ ASSERT_EQ(NULL, memmem(scratch, sizeof(scratch), buf, len));
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static int
|
|
||||||
count_secrets(const char *buf)
|
|
||||||
{
|
|
||||||
@@ -143,6 +156,7 @@ test_without_bzero(void)
|
|
||||||
char *res;
|
|
||||||
assert_on_stack();
|
|
||||||
populate_secret(buf, sizeof(buf));
|
|
||||||
+ blank_stack_side_effects(buf, sizeof(buf));
|
|
||||||
res = memmem(altstack, ALTSTACK_SIZE, buf, sizeof(buf));
|
|
||||||
ASSERT_NE(NULL, res);
|
|
||||||
return (res);
|
|
||||||
@@ -155,6 +169,7 @@ test_with_bzero(void)
|
|
||||||
char *res;
|
|
||||||
assert_on_stack();
|
|
||||||
populate_secret(buf, sizeof(buf));
|
|
||||||
+ blank_stack_side_effects(buf, sizeof(buf));
|
|
||||||
res = memmem(altstack, ALTSTACK_SIZE, buf, sizeof(buf));
|
|
||||||
ASSERT_NE(NULL, res);
|
|
||||||
explicit_bzero(buf, sizeof(buf));
|
|
||||||
--
|
|
||||||
GitLab
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
|||||||
configure.ac: Improve C99 compatibility of __progname check
|
|
||||||
|
|
||||||
The check uses printf, so it needs to include <stdio.h> for compilers
|
|
||||||
which do not support implicit function declarations. (They were
|
|
||||||
removed from C99.)
|
|
||||||
|
|
||||||
Submitted upstream:
|
|
||||||
|
|
||||||
<https://gitlab.freedesktop.org/libbsd/libbsd/-/merge_requests/23>
|
|
||||||
|
|
||||||
diff -ur libbsd-0.11.7.orig/configure.ac libbsd-0.11.7/configure.ac
|
|
||||||
--- libbsd-0.11.7.orig/configure.ac 2022-10-06 04:06:31.000000000 +0200
|
|
||||||
+++ libbsd-0.11.7/configure.ac 2022-12-12 10:00:57.500065200 +0100
|
|
||||||
@@ -221,7 +221,9 @@
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([for __progname])
|
|
||||||
AC_LINK_IFELSE(
|
|
||||||
- [AC_LANG_PROGRAM([[extern char *__progname;]],
|
|
||||||
+ [AC_LANG_PROGRAM([[
|
|
||||||
+ #include <stdio.h>
|
|
||||||
+ extern char *__progname;]],
|
|
||||||
[[printf("%s", __progname);]])],
|
|
||||||
[AC_DEFINE([HAVE___PROGNAME], [1], [Define to 1 if you have __progname])
|
|
||||||
AC_MSG_RESULT([yes])],
|
|
@ -1,2 +1,2 @@
|
|||||||
SHA512 (libbsd-0.11.7.tar.xz) = 51fda4724f41dd8a4628afd58c21236a7588d9045e337e06eeabf83805a9aaaa53705441ca901ad11f1c65f18e881523bdc97721a7d3d6a5cced27f2450d09a2
|
SHA512 (libbsd-0.12.2.tar.xz) = ce43e4f0486d5f00d4a8119ee863eaaa2f968cae4aa3d622976bb31ad601dfc565afacef7ebade5eba33fff1c329b5296c6387c008d1e1805d878431038f8b21
|
||||||
SHA512 (libbsd-0.11.7.tar.xz.asc) = bdcce69ee261039900896c5be48659f1b6b809f3a6e8a5220aac30a6687926ac29e478a3ea737727d077d6575ee11b86eed896932568fdd261a9aaeb46d695b6
|
SHA512 (libbsd-0.12.2.tar.xz.asc) = c2e56aa572ce50d6342c0e45622958eba40319e09d45dc3cff6296cb10eebc0c4154d6f758dd2470a1794251fc0273d05ac2d735698eae83183769df5f7d44c3
|
||||||
|
Loading…
Reference in new issue