Subject: kern/5892: sbcratecontrol() is not compatible with CMSG_LEN() in some architecture
To: None <gnats-bugs@gnats.netbsd.org>
From: Jun-ichiro Itojun Itoh <itojun@hoge.kame.net>
List: netbsd-bugs
Date: 08/01/1998 11:12:46
>Number: 5892
>Category: kern
>Synopsis: sbcratecontrol() is not compatible with CMSG_LEN() in some architecture
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people (Kernel Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Aug 1 02:20:01 1998
>Last-Modified:
>Originator: Jun-ichiro itojun Itoh
>Organization:
itojun.org
>Release: NetBSD 1.3 and NetBSD 1.3.2
>Environment:
System: NetBSD hoge.kame.net 1.3 NetBSD 1.3 (HOGE.v6) #1: Sat Aug 1 08:01:15 PDT 1998 itojun@hoge:/usr/home/itojun/hyd/sys/arch/i386/compile/HOGE.v6 i386
>Description:
sbcreatecontrol() and CMSG_LEN() assumes different thing in
computing the size to be passed into cmsg_len.
sbcreatecontrol() puts sizeof(struct cmsghdr) + x into cmsg_len().
CMSG_LEN computes it by ALIGN(sizeof(struct cmsghdr)) + x.
Due to the difference, CMSG_LEN(sizeof(int)) returns 20 in
NetBSD/sparc. However, sbcreatecontrol() sets 16 into cmsg_len.
This problem appears in architectures which has ALIGN() aligns
structure into 8 bytes (such as Sun sparc port).
Confirmed in NetBSD 1.3. NetBSD 1.3.2 seems to have the same problem
(after looking into the source code).
>How-To-Repeat:
>Fix:
change sbcreatecontrol(), or CMSG_LEN(), or ALIGN().
I dunno which is the best way.
>Audit-Trail:
>Unformatted: