Browse Source

Tighten behavior of _rs_allocate failure for portable arc4random implementations.

In the event of a failure in _rs_allocate for rsx, we still have a reference to
freed memory for rs on return. Not a huge deal since we subsequently abort in
_rs_init, but it looks strange on its own.
ok deraadt@
OPENBSD_6_0
bcook 8 years ago
parent
commit
468bf1902b
14 changed files with 28 additions and 14 deletions
  1. +2
    -1
      src/lib/libcrypto/arc4random/arc4random_aix.h
  2. +2
    -1
      src/lib/libcrypto/arc4random/arc4random_freebsd.h
  3. +2
    -1
      src/lib/libcrypto/arc4random/arc4random_hpux.h
  4. +2
    -1
      src/lib/libcrypto/arc4random/arc4random_linux.h
  5. +2
    -1
      src/lib/libcrypto/arc4random/arc4random_netbsd.h
  6. +2
    -1
      src/lib/libcrypto/arc4random/arc4random_osx.h
  7. +2
    -1
      src/lib/libcrypto/arc4random/arc4random_solaris.h
  8. +2
    -1
      src/lib/libcrypto/crypto/arc4random_aix.h
  9. +2
    -1
      src/lib/libcrypto/crypto/arc4random_freebsd.h
  10. +2
    -1
      src/lib/libcrypto/crypto/arc4random_hpux.h
  11. +2
    -1
      src/lib/libcrypto/crypto/arc4random_linux.h
  12. +2
    -1
      src/lib/libcrypto/crypto/arc4random_netbsd.h
  13. +2
    -1
      src/lib/libcrypto/crypto/arc4random_osx.h
  14. +2
    -1
      src/lib/libcrypto/crypto/arc4random_solaris.h

+ 2
- 1
src/lib/libcrypto/arc4random/arc4random_aix.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_aix.h,v 1.1 2015/03/30 11:29:48 bcook Exp $ */
/* $OpenBSD: arc4random_aix.h,v 1.2 2016/06/30 12:19:51 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -72,6 +72,7 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
munmap(*rsp, sizeof(**rsp));
*rsp = NULL;
return (-1);
}


+ 2
- 1
src/lib/libcrypto/arc4random/arc4random_freebsd.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_freebsd.h,v 1.3 2015/09/11 11:52:55 deraadt Exp $ */
/* $OpenBSD: arc4random_freebsd.h,v 1.4 2016/06/30 12:19:51 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -78,6 +78,7 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
munmap(*rsp, sizeof(**rsp));
*rsp = NULL;
return (-1);
}


+ 2
- 1
src/lib/libcrypto/arc4random/arc4random_hpux.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_hpux.h,v 1.2 2015/01/15 06:57:18 deraadt Exp $ */
/* $OpenBSD: arc4random_hpux.h,v 1.3 2016/06/30 12:19:51 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -72,6 +72,7 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
munmap(*rsp, sizeof(**rsp));
*rsp = NULL;
return (-1);
}


+ 2
- 1
src/lib/libcrypto/arc4random/arc4random_linux.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_linux.h,v 1.10 2016/01/04 02:04:56 bcook Exp $ */
/* $OpenBSD: arc4random_linux.h,v 1.11 2016/06/30 12:19:51 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -79,6 +79,7 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
munmap(*rsp, sizeof(**rsp));
*rsp = NULL;
return (-1);
}


+ 2
- 1
src/lib/libcrypto/arc4random/arc4random_netbsd.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_netbsd.h,v 1.2 2015/09/11 11:52:55 deraadt Exp $ */
/* $OpenBSD: arc4random_netbsd.h,v 1.3 2016/06/30 12:19:51 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -78,6 +78,7 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
munmap(*rsp, sizeof(**rsp));
*rsp = NULL;
return (-1);
}


+ 2
- 1
src/lib/libcrypto/arc4random/arc4random_osx.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_osx.h,v 1.10 2015/09/11 11:52:55 deraadt Exp $ */
/* $OpenBSD: arc4random_osx.h,v 1.11 2016/06/30 12:19:51 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -72,6 +72,7 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
munmap(*rsp, sizeof(**rsp));
*rsp = NULL;
return (-1);
}


+ 2
- 1
src/lib/libcrypto/arc4random/arc4random_solaris.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_solaris.h,v 1.9 2015/01/15 06:57:18 deraadt Exp $ */
/* $OpenBSD: arc4random_solaris.h,v 1.10 2016/06/30 12:19:51 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -72,6 +72,7 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
munmap(*rsp, sizeof(**rsp));
*rsp = NULL;
return (-1);
}


+ 2
- 1
src/lib/libcrypto/crypto/arc4random_aix.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_aix.h,v 1.1 2015/03/30 11:29:48 bcook Exp $ */
/* $OpenBSD: arc4random_aix.h,v 1.2 2016/06/30 12:19:51 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -72,6 +72,7 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
munmap(*rsp, sizeof(**rsp));
*rsp = NULL;
return (-1);
}


+ 2
- 1
src/lib/libcrypto/crypto/arc4random_freebsd.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_freebsd.h,v 1.3 2015/09/11 11:52:55 deraadt Exp $ */
/* $OpenBSD: arc4random_freebsd.h,v 1.4 2016/06/30 12:19:51 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -78,6 +78,7 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
munmap(*rsp, sizeof(**rsp));
*rsp = NULL;
return (-1);
}


+ 2
- 1
src/lib/libcrypto/crypto/arc4random_hpux.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_hpux.h,v 1.2 2015/01/15 06:57:18 deraadt Exp $ */
/* $OpenBSD: arc4random_hpux.h,v 1.3 2016/06/30 12:19:51 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -72,6 +72,7 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
munmap(*rsp, sizeof(**rsp));
*rsp = NULL;
return (-1);
}


+ 2
- 1
src/lib/libcrypto/crypto/arc4random_linux.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_linux.h,v 1.10 2016/01/04 02:04:56 bcook Exp $ */
/* $OpenBSD: arc4random_linux.h,v 1.11 2016/06/30 12:19:51 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -79,6 +79,7 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
munmap(*rsp, sizeof(**rsp));
*rsp = NULL;
return (-1);
}


+ 2
- 1
src/lib/libcrypto/crypto/arc4random_netbsd.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_netbsd.h,v 1.2 2015/09/11 11:52:55 deraadt Exp $ */
/* $OpenBSD: arc4random_netbsd.h,v 1.3 2016/06/30 12:19:51 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -78,6 +78,7 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
munmap(*rsp, sizeof(**rsp));
*rsp = NULL;
return (-1);
}


+ 2
- 1
src/lib/libcrypto/crypto/arc4random_osx.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_osx.h,v 1.10 2015/09/11 11:52:55 deraadt Exp $ */
/* $OpenBSD: arc4random_osx.h,v 1.11 2016/06/30 12:19:51 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -72,6 +72,7 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
munmap(*rsp, sizeof(**rsp));
*rsp = NULL;
return (-1);
}


+ 2
- 1
src/lib/libcrypto/crypto/arc4random_solaris.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_solaris.h,v 1.9 2015/01/15 06:57:18 deraadt Exp $ */
/* $OpenBSD: arc4random_solaris.h,v 1.10 2016/06/30 12:19:51 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -72,6 +72,7 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
munmap(*rsp, sizeof(**rsp));
*rsp = NULL;
return (-1);
}


Loading…
Cancel
Save