Subject: kern/323: panic on long filenames while doingcache=0
To: None <gnats-admin>
From: None <tik@f40.Hanse.DE>
List: netbsd-bugs
Date: 07/05/1994 14:50:05
>Number:         323
>Category:       kern
>Synopsis:       panic on long filenames while doingcache=0
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul  5 14:50:03 1994
>Originator:     Michael Havemester
>Organization:
>Release:        NetBSD 0.9C, -current
>Environment:

System: NetBSD f40.Hanse.DE 0.9C NetBSD 0.9C (F40)

>Description:
	cache_enter panics on long filenames (32 chars and more)
	doingcache=0, DIAGNOSTIC turned on

	cache_enter() (sys/kern/vfs_cache.c) will be called from
        ufs_lookup() (sys/ufs/ufs/ufs_lookup.c), only if
	cnp->cn_flags & MAKEENTRY is true, after a call to cache_lookup().
        MAKEENTRY (from cnp->cn_flags) will be reset inside cache_lookup()
        (sys/kern/vfs_cache.c), if cnp->nc_namelen > NCHNAMLEN, but only
	if doingcache != 0

>How-To-Repeat:
	enable options DIAGNOSTIC in config-File and set
	doingcache to 0 in sys/kern/vfs_cache.c

>Fix:
	test !doingcache in cache_enter() (sys/kern/vfs_cache.c) before
	anything else or modify cache_lookup() (sys/kern/vfs_cache.c) to
	test if cnp->nc_namelen > NCHNAMLEN before testing !doingcache.
	

*** old/vfs_cache.c	Sun Jul  3 13:05:16 1994
--- vfs_cache.c	Tue Jul  5 15:46:36 1994
***************
*** 195,206 ****
  {
  	register struct namecache *ncp, *ncq, **ncpp;
  
  #ifdef DIAGNOSTIC
  	if (cnp->cn_namelen > NCHNAMLEN)
  		panic("cache_enter: name too long");
  #endif
- 	if (!doingcache)
- 		return;
  	/*
  	 * Free the cache slot at head of lru chain.
  	 */
--- 195,206 ----
  {
  	register struct namecache *ncp, *ncq, **ncpp;
  
+ 	if (!doingcache)
+ 		return;
  #ifdef DIAGNOSTIC
  	if (cnp->cn_namelen > NCHNAMLEN)
  		panic("cache_enter: name too long");
  #endif
  	/*
  	 * Free the cache slot at head of lru chain.
  	 */
>Audit-Trail:
>Unformatted:


------------------------------------------------------------------------------