NetBSD Problem Report #42273

From jon@xw8200.Bullers.Net  Fri Nov  6 01:55:04 2009
Return-Path: <jon@xw8200.Bullers.Net>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id CF72263B844
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  6 Nov 2009 01:55:04 +0000 (UTC)
Message-Id: <20091106015550.BD73F1AF2FD0@xw8200.Bullers.Net>
Date: Thu,  5 Nov 2009 17:55:50 -0800 (PST)
From: jon@bullers.net
Reply-To: jon@bullers.net
To: gnats-bugs@gnats.NetBSD.org
Subject: SHA512_CTX struct not properly aligned
X-Send-Pr-Version: 3.95

>Number:         42273
>Category:       lib
>Synopsis:       Alignment problem with digest[] in SHA512_Final
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    joerg
>State:          closed
>Class:          sw-bug
>Submitter-Id:   unknown
>Arrival-Date:   Fri Nov 06 02:00:00 +0000 2009
>Closed-Date:    Sat Jan 30 19:38:29 +0000 2010
>Last-Modified:  Sat Jan 30 20:40:08 +0000 2010
>Originator:     jon@bullers.net
>Release:        NetBSD current (as of Oct 30, 2009)
>Organization:

>Environment:
System: NetBSD sparc release built on amd64 system, kernel 5.99.15
        test code run in chroot area populated with a native built
	release from sources checked out on Oct 30, 2009.
Architecture: sparc
Machine: sparc
>Description:
	pkg_admin gets a bus error when downloading the vulnerabilities
	file.  gdb shows crash occured in SHA512_Final()  Small test
	case (near verbatim to example in man page) duplicates problem.

        martin@ tracked the test case down to an alignment problem in
	the digest array allocation and usage.  pkg_admin code
	appears to allocate the struct exactly like the test case.
>How-To-Repeat:

#include <stdio.h>

#include <sys/types.h>
#include <sha1.h>

int main (int argc, char *argv[]) {
  SHA1_CTX ctx;
  uint8_t buf[27] = "abcdefghijklmnopqrstuvwxyz";
  uint8_t digest[20];
  int i;

  SHA1Init (&ctx);
  SHA1Update (&ctx, buf, sizeof(buf));
  SHA1Final (digest, &ctx);
  for (i = 0; i < 20; i++) {
    printf ("%2.2x", digest[i]);
  }
  printf ("\n");
}

>Fix:
	martin@ said joerg@ has a fix for this ready, and to assign
	this PR to joerg (if pr-bug people don't do it for me first)

>Release-Note:

>Audit-Trail:
	Assigning to joerg per suggestion of martin.
Responsible-Changed-From-To: port-sparc-maintainer->joerg
Responsible-Changed-By: jonb@NetBSD.org
Responsible-Changed-When: Fri, 06 Nov 2009 02:55:14 +0000
Responsible-Changed-Why:
martin suggested that this should be assigned to joerg when I opened it


State-Changed-From-To: open->analyzed
State-Changed-By: joerg@NetBSD.org
State-Changed-When: Fri, 06 Nov 2009 20:44:55 +0000
State-Changed-Why:
A fix was commited to HEAD. Needs further testing, pullups and a regression
test.


From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: joerg@NetBSD.org, netbsd-bugs@netbsd.org, gnats-admin@netbsd.org,
	jon@bullers.net
Subject: Re: lib/42273 (SHA512_CTX struct not properly aligned)
Date: Sat, 7 Nov 2009 20:59:09 +0100

 On Fri, Nov 06, 2009 at 08:44:56PM +0000, joerg@NetBSD.org wrote:
 > A fix was commited to HEAD. Needs further testing, pullups and a regression
 > test.

 You didn't fix the identical problem in the other SHA*_Final() functions.

 Martin

From: Jon Buller <jon@bullers.net>
To: gnats-bugs@NetBSD.org
Cc: joerg@NetBSD.org, netbsd-bugs@netbsd.org, gnats-admin@netbsd.org
Subject: Re: lib/42273 (SHA512_CTX struct not properly aligned)
Date: Mon, 16 Nov 2009 07:33:53 -0800

 joerg@NetBSD.org wrote:

 > A fix was commited to HEAD. Needs further testing, pullups and a regression
 > test.

 I have finally(!) been able to get the old, slow, sparc system to 
 rebuild and
 test this.  Both download-vulnerability-list (which runs pkg_admin which 
 uses
 SHA512_Final in a core causing way) and the test program included in the PR
 both produce valid results now.  Thanks Joerg!

 Jon

From: Joerg Sonnenberger <joerg@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42273 CVS commit: src/common/lib/libc/hash/sha2
Date: Sun, 24 Jan 2010 21:11:18 +0000

 Module Name:	src
 Committed By:	joerg
 Date:		Sun Jan 24 21:11:18 UTC 2010

 Modified Files:
 	src/common/lib/libc/hash/sha2: sha2.c

 Log Message:
 Fix unaligned access in *_Final for SHA224/SHA256/SHA384.
 Remaining part of PR 42273. Tested by snj.


 To generate a diff of this commit:
 cvs rdiff -u -r1.20 -r1.21 src/common/lib/libc/hash/sha2/sha2.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42273 CVS commit: [netbsd-4] src/common/lib/libc/hash/sha2
Date: Wed, 27 Jan 2010 21:05:52 +0000

 Module Name:	src
 Committed By:	bouyer
 Date:		Wed Jan 27 21:05:52 UTC 2010

 Modified Files:
 	src/common/lib/libc/hash/sha2 [netbsd-4]: sha2.c

 Log Message:
 Pull up following revision(s) (requested by joerg in ticket #1381):
 	common/lib/libc/hash/sha2/sha2.c: revision 1.20
 Fix unaligned access as reported in PR port-sparc/42273


 To generate a diff of this commit:
 cvs rdiff -u -r1.2.4.5 -r1.2.4.6 src/common/lib/libc/hash/sha2/sha2.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42273 CVS commit: [netbsd-4] src/common/lib/libc/hash/sha2
Date: Wed, 27 Jan 2010 21:09:14 +0000

 Module Name:	src
 Committed By:	bouyer
 Date:		Wed Jan 27 21:09:14 UTC 2010

 Modified Files:
 	src/common/lib/libc/hash/sha2 [netbsd-4]: sha2.c

 Log Message:
 Pull up following revision(s) (requested by joerg in ticket #1382):
 	common/lib/libc/hash/sha2/sha2.c: revision 1.21
 Fix unaligned access in *_Final for SHA224/SHA256/SHA384.
 Remaining part of PR 42273. Tested by snj.


 To generate a diff of this commit:
 cvs rdiff -u -r1.2.4.6 -r1.2.4.7 src/common/lib/libc/hash/sha2/sha2.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Soren Jacobsen <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42273 CVS commit: [netbsd-5] src/common/lib/libc/hash/sha2
Date: Sat, 30 Jan 2010 19:32:29 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Sat Jan 30 19:32:29 UTC 2010

 Modified Files:
 	src/common/lib/libc/hash/sha2 [netbsd-5]: sha2.c

 Log Message:
 Pull up following revision(s) (requested by joerg in ticket #1275):
 	common/lib/libc/hash/sha2/sha2.c: revision 1.20
 Fix unaligned access as reported in PR port-sparc/42273.


 To generate a diff of this commit:
 cvs rdiff -u -r1.7.10.1 -r1.7.10.2 src/common/lib/libc/hash/sha2/sha2.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Soren Jacobsen <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42273 CVS commit: [netbsd-5] src/common/lib/libc/hash/sha2
Date: Sat, 30 Jan 2010 19:34:44 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Sat Jan 30 19:34:44 UTC 2010

 Modified Files:
 	src/common/lib/libc/hash/sha2 [netbsd-5]: sha2.c

 Log Message:
 Pull up following revision(s) (requested by 1276):
 	common/lib/libc/hash/sha2/sha2.c: revision 1.21
 Fix unaligned access in *_Final for SHA224/SHA256/SHA384.
 Remaining part of PR 42273. Tested by snj.


 To generate a diff of this commit:
 cvs rdiff -u -r1.7.10.2 -r1.7.10.3 src/common/lib/libc/hash/sha2/sha2.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: analyzed->closed
State-Changed-By: snj@NetBSD.org
State-Changed-When: Sat, 30 Jan 2010 19:38:29 +0000
State-Changed-Why:
Fixes committed, pulled up to netbsd-4 and netbsd-5, and regression test
added.


From: Soren Jacobsen <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42273 CVS commit: [netbsd-5-0] src/common/lib/libc/hash/sha2
Date: Sat, 30 Jan 2010 20:35:58 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Sat Jan 30 20:35:57 UTC 2010

 Modified Files:
 	src/common/lib/libc/hash/sha2 [netbsd-5-0]: sha2.c

 Log Message:
 Pull up following revision(s) (requested by joerg in ticket #1275):
 	common/lib/libc/hash/sha2/sha2.c: revision 1.20
 Fix unaligned access as reported in PR port-sparc/42273


 To generate a diff of this commit:
 cvs rdiff -u -r1.7.14.1 -r1.7.14.2 src/common/lib/libc/hash/sha2/sha2.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Soren Jacobsen <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42273 CVS commit: [netbsd-5-0] src/common/lib/libc/hash/sha2
Date: Sat, 30 Jan 2010 20:38:44 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Sat Jan 30 20:38:43 UTC 2010

 Modified Files:
 	src/common/lib/libc/hash/sha2 [netbsd-5-0]: sha2.c

 Log Message:
 Pull up following revision(s) (requested by joerg in ticket #1276):
 	common/lib/libc/hash/sha2/sha2.c: revision 1.21
 Fix unaligned access in *_Final for SHA224/SHA256/SHA384.
 Remaining part of PR 42273. Tested by snj.


 To generate a diff of this commit:
 cvs rdiff -u -r1.7.14.2 -r1.7.14.3 src/common/lib/libc/hash/sha2/sha2.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.