Subject: kern/29133: Fault in Kernelfunction findsym
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <kessi@teles.de>
List: netbsd-bugs
Date: 01/27/2005 13:54:00
>Number:         29133
>Category:       kern
>Synopsis:       Fault in Kernelfunction findsym
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 27 13:54:00 +0000 2005
>Originator:     Jens Kessmeier
>Release:        2.0
>Organization:
TELES AG
>Environment:
NetBSD iswitch2.teles.de 2.0 NetBSD 2.0 (ISWITCH) #16: Thu Jan 27 11:48:04 2005 admin@COMPILE:/usr2/isdn/NetBSD-2.0/usr/src/sys/arch/i386/compile/ISWITCH i386
>Description:
Loading LKMs with symbols, netstat -inv (/etc/daily) faults in
Kernelfunction findsym (kern_ksyms.c).

After changing the Function (see below, KESSI is not defined), the system is able to netstat -inv. Is this really a Fix?

static Elf_Sym *
findsym(char *name, struct symtab *table, int userreq)
{
	Elf_Sym *start = table->sd_symstart;
	int i, sz = table->sd_symsize/sizeof(Elf_Sym);
	char *np;
#ifdef KESSI
	caddr_t realstart = table->sd_strstart - (userreq ? 0 : table->sd_usroffset);
#else
caddr_t realstart = table->sd_strstart - table->sd_usroffset;
#endif

#ifdef USE_PTREE
	if (table == &kernel_symtab && (i = ptree_find(name)) != 0)
		return &start[i];
#endif

	for (i = 0; i < sz; i++) {
		np = realstart + start[i].st_name;
		if (name[0] == np[0] && name[1] == np[1] &&
		    strcmp(name, np) == 0)
			return &start[i];
	}
	return NULL;
}

>How-To-Repeat:

>Fix: