bin/120994: alignment violation in chap module of ppp(8) causes bus error on ARM

Joerg Wallerich joerg at net.t-labs.tu-berlin.de
Sat Feb 23 15:00:08 UTC 2008


>Number:         120994
>Category:       bin
>Synopsis:       alignment violation in chap module of ppp(8) causes bus error on ARM
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Feb 23 15:00:07 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Joerg Wallerich
>Release:        RELENG_7
>Organization:
>Environment:
FreeBSD avila 7.0-PRERELEASE FreeBSD 7.0-PRERELEASE #12: Sat Feb 23 05:03:12 CET 2008     root at sulaco:/usr/obj/arm/usr/src/sys/AVILA.router  arm

>Description:
The chap code in ppp(8) provides a target buffer to MD5Final()
that is not word aligned. This leads to a bus error in libmd while
computing a response to the CHAP challenge string.
>How-To-Repeat:
Authenticate a ppp/pppoe session unsing CHAP
>Fix:
Provide a temporary word aligned buffer to store the MD5 hash
and copy the hash into the CHAP response string using memcpy().

Patch attached with submission follows:

Index: chap.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/ppp/chap.c,v
retrieving revision 1.86
diff -c -r1.86 chap.c
*** chap.c	5 Sep 2004 01:46:51 -0000	1.86
--- chap.c	23 Feb 2008 14:51:45 -0000
***************
*** 130,135 ****
--- 130,136 ----
                  )
  {
    char *result, *digest;
+   char *tmpbuf;
    size_t nlen, klen;
  
    nlen = strlen(name);
***************
*** 232,237 ****
--- 233,239 ----
      /* Normal MD5 stuff */
      MD5_CTX MD5context;
  
+     tmpbuf = malloc(nlen + 17);
      digest = result;
      *digest++ = 16;				/* value size */
  
***************
*** 239,247 ****
      MD5Update(&MD5context, &id, 1);
      MD5Update(&MD5context, key, klen);
      MD5Update(&MD5context, challenge + 1, *challenge);
!     MD5Final(digest, &MD5context);
  
      memcpy(digest + 16, name, nlen);
      /*
       *           ---- -------- ------
       * result = | 16 | digest | name |
--- 241,251 ----
      MD5Update(&MD5context, &id, 1);
      MD5Update(&MD5context, key, klen);
      MD5Update(&MD5context, challenge + 1, *challenge);
!     MD5Final(tmpbuf, &MD5context);
  
+     memcpy(digest, tmpbuf, 16);
      memcpy(digest + 16, name, nlen);
+     free(tmpbuf);
      /*
       *           ---- -------- ------
       * result = | 16 | digest | name |


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list