Re: Length of wmesg for condvar?
On Sun, 8 Aug 2010 17:23:23 -0700 (PDT) Paul Goyette p...@whooppee.com wrote: Should these be changed? Are there any adverse effects from having a wmesg longer than 8 characters? It seems to me that the exporter of those use strncpy() (i.e. kern/init_sysctl.c) and that the structures use WMESGLEN and KI_WMESGLEN both defined as 8. So other than inadvertently truncated names it at least should not cause corruption, but I think that truncated names could also be problematic when trying to distinguish two strings starting with the same 8 characters (is that likely now)? Especially when the only thing that differs between two states is some suffix like rd and rw... After all, those are intended for humans :) -- Matt
Re: Length of wmesg for condvar?
On Mon, Aug 09, 2010 at 02:38:32AM -0400, Matthew Mondor wrote: On Sun, 8 Aug 2010 17:23:23 -0700 (PDT) Paul Goyette p...@whooppee.com wrote: Should these be changed? Are there any adverse effects from having a wmesg longer than 8 characters? It seems to me that the exporter of those use strncpy() strncpy() is unlikely to do what is expected of it. strlcpy() is probably rather better. David -- David Laight: da...@l8s.co.uk
Re: Length of wmesg for condvar?
On Mon, 9 Aug 2010, Matthew Mondor wrote: On Sun, 8 Aug 2010 17:23:23 -0700 (PDT) Paul Goyette p...@whooppee.com wrote: Should these be changed? Are there any adverse effects from having a wmesg longer than 8 characters? It seems to me that the exporter of those use strncpy() (i.e. kern/init_sysctl.c) and that the structures use WMESGLEN and KI_WMESGLEN both defined as 8. So other than inadvertently truncated names it at least should not cause corruption, but I think that truncated names could also be problematic when trying to distinguish two strings starting with the same 8 characters (is that likely now)? Especially when the only thing that differs between two states is some suffix like rd and rw... After all, those are intended for humans :) Does anyone object to my going through and coming up with shorter names (= 8 chars) for these condvars? I'll leave changing the exporters from strncpy() to strlcpy() for another day. - | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com| | Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net | | Kernel Developer | | pgoyette at netbsd.org | -
re: Length of wmesg for condvar?
On Mon, Aug 09, 2010 at 02:38:32AM -0400, Matthew Mondor wrote: On Sun, 8 Aug 2010 17:23:23 -0700 (PDT) Paul Goyette p...@whooppee.com wrote: Should these be changed? Are there any adverse effects from having a wmesg longer than 8 characters? It seems to me that the exporter of those use strncpy() strncpy() is unlikely to do what is expected of it. strlcpy() is probably rather better. these are not (stored) as normal C-strings. if they're the full 8 chars, they'll have no nul. .mrg.
Re: Length of wmesg for condvar?
On Mon, 9 Aug 2010 22:21:02 +0100 David Laight da...@l8s.co.uk wrote: On Mon, Aug 09, 2010 at 02:02:51PM -0700, Paul Goyette wrote: Does anyone object to my going through and coming up with shorter names (= 8 chars) for these condvars? It is worth chcking whether they are displayed with a %.8s format (or similar) so that they don't need to be 0 terminated. Otherwise the names must be strictly less than 8 bytes. David -- David Laight: da...@l8s.co.uk That is worthy of concern, so I checked top and ps: top uses char wmesg[KI_WMESGLEN + 1]; strlcpy(wmesg, pp-p_wmesg, sizeof(wmesg)); ps uses strprintorsetwidth(v, l-l_wmesg, mode); v-width = min(v-width, KI_WMESGLEN); Thanks, -- Matt
Length of wmesg for condvar?
The condvar(9) man page states The wmesg argument specifies a string of no more than 8 characters... yet there is at least one instance in the kernel sources where we have a wmesg long than 8 characters! In src/sys/kern/kern_module.c in routine module_init() we have cv_init(module_thread_cv, modunload); There appear to be several other similar violations in various places: src/sys/arch/x86/x86/ipmi.c src/sys/arch/xen/xen/balloon.c src/sys/dev/isa/fd.c src/sys/dev/tprof/tprof.c src/sys/dist/ipf/netinet/ip_auth.c src/sys/dist/ipf/netinet/ip_log.c src/sys/dist/ipf/netinet/ip_sync.c src/sys/fs/nilfs/nilfs_subr.c src/sys/fs/nilfs/nilfs_vfsops.c src/sys/kern/sys_pipe.c src/sys/net/agr/if_agr.c src/sys/opencrypto/crypto.c src/sys/rump/librump/rumpkern/sysproxy_socket.c Should these be changed? Are there any adverse effects from having a wmesg longer than 8 characters? - | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com| | Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net | | Kernel Developer | | pgoyette at netbsd.org | -