From owner-freebsd-bugs Wed Dec 26 12: 0: 7 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 0E45C37B405 for ; Wed, 26 Dec 2001 12:00:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id fBQK01k86881; Wed, 26 Dec 2001 12:00:01 -0800 (PST) (envelope-from gnats) Date: Wed, 26 Dec 2001 12:00:01 -0800 (PST) Message-Id: <200112262000.fBQK01k86881@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Bruce Evans Subject: Re: kern/33201: net/net_osdep.c:if_name is broken Reply-To: Bruce Evans Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR kern/33201; it has been noted by GNATS. From: Bruce Evans To: Robert Watson Cc: Subject: Re: kern/33201: net/net_osdep.c:if_name is broken Date: Thu, 27 Dec 2001 06:53:18 +1100 (EST) On Wed, 26 Dec 2001, Robert Watson wrote: > Slight update on this: I misread the function, it's evil due to its > use of MAXNUMBUF rather than its use of stack space. Comments about > IFNAMSIZE still apply. If we want to formally maintain an interface name The multiple static buffer hack is even worse than a single static buffer in threaded and/or interruptible environments. inet_ntoa() in the kernel an example of an old BAD interface that is implemented using the latter. I think if_name() and inet_ntoa() are only used in kernel printfs, so the effects of races are somewhat limited. With a static buffer that always has a NUL at the end, the buffer contents may be garbage. With the multiple static buffer hack, there are also races bumping the buffer index, but for if_name() the buffer index is bumped in a fairly fail-safe way which might prevent it becoming invalid if the compiler doesn't do too many optimizations. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message