Date: Wed, 20 May 2009 19:19:42 +0000 (UTC) From: Kip Macy <kmacy@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r192464 - user/kmacy/releng_7_2_fcs/sys/kern Message-ID: <200905201919.n4KJJgK8041094@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kmacy Date: Wed May 20 19:19:41 2009 New Revision: 192464 URL: http://svn.freebsd.org/changeset/base/192464 Log: merge 192144 Revert r192094. The revision caused problems for sysctl(3) consumers that expect that oldlen is filled with required buffer length even when supplied buffer is too short and returned error is ENOMEM. Redo the fix for kern.proc.filedesc, by reverting the req->oldidx when remaining buffer space is too short for the current kinfo_file structure. Also, only ignore ENOMEM. We have to convert ENOMEM to no error condition to keep existing interface for the sysctl, though. Reported by: ed, Florian Smeets <flo kasimir com> Tested by: pho Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c Modified: user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c Wed May 20 18:58:07 2009 (r192463) +++ user/kmacy/releng_7_2_fcs/sys/kern/kern_descrip.c Wed May 20 19:19:41 2009 (r192464) @@ -2872,6 +2872,7 @@ sysctl_kern_proc_filedesc(SYSCTL_HANDLER struct file *fp; struct proc *p; int vfslocked; + size_t oldidx; name = (int *)arg1; if ((p = pfind((pid_t)name[0])) == NULL) @@ -3036,14 +3037,26 @@ sysctl_kern_proc_filedesc(SYSCTL_HANDLER strlen(kif->kf_path) + 1; kif->kf_structsize = roundup(kif->kf_structsize, sizeof(uint64_t)); + oldidx = req->oldidx; error = SYSCTL_OUT(req, kif, kif->kf_structsize); - if (error) + if (error) { + if (error == ENOMEM) { + /* + * The hack to keep the ABI of sysctl + * kern.proc.filedesc intact, but not + * to account a partially copied + * kinfo_file into the oldidx. + */ + req->oldidx = oldidx; + error = 0; + } break; + } } FILEDESC_SUNLOCK(fdp); fddrop(fdp); free(kif, M_TEMP); - return (0); + return (error); } static SYSCTL_NODE(_kern_proc, KERN_PROC_FILEDESC, filedesc, CTLFLAG_RD,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905201919.n4KJJgK8041094>