From owner-svn-src-all@FreeBSD.ORG Wed May 27 15:23:13 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 47D511065688; Wed, 27 May 2009 15:23:13 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 35D478FC22; Wed, 27 May 2009 15:23:13 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4RFNDme001263; Wed, 27 May 2009 15:23:13 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4RFND0x001262; Wed, 27 May 2009 15:23:13 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <200905271523.n4RFND0x001262@svn.freebsd.org> From: Andriy Gapon Date: Wed, 27 May 2009 15:23:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192899 - head/sys/compat/linux X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 May 2009 15:23:14 -0000 Author: avg Date: Wed May 27 15:23:12 2009 New Revision: 192899 URL: http://svn.freebsd.org/changeset/base/192899 Log: linux_ioctl_cdrom: reduce stack usage ... by moving two ~2KB structures from stack to heap allocation. I experienced stack overflow in linux emulation on i386 (8K stack) when LINUX_DVD_READ_STRUCT ioctl was performed on atapicam cd device and there was an error that resulted in additional quite heavy stack use in cam layer. Reviewed by: dchagin Approved by: jhb (mentor) Modified: head/sys/compat/linux/linux_ioctl.c Modified: head/sys/compat/linux/linux_ioctl.c ============================================================================== --- head/sys/compat/linux/linux_ioctl.c Wed May 27 15:16:56 2009 (r192898) +++ head/sys/compat/linux/linux_ioctl.c Wed May 27 15:23:12 2009 (r192899) @@ -1556,23 +1556,28 @@ linux_ioctl_cdrom(struct thread *td, str /* LINUX_CDROMAUDIOBUFSIZ */ case LINUX_DVD_READ_STRUCT: { - l_dvd_struct lds; - struct dvd_struct bds; + l_dvd_struct *lds; + struct dvd_struct *bds; - error = copyin((void *)args->arg, &lds, sizeof(lds)); + lds = malloc(sizeof(*lds), M_LINUX, M_WAITOK); + bds = malloc(sizeof(*bds), M_LINUX, M_WAITOK); + error = copyin((void *)args->arg, lds, sizeof(*lds)); if (error) - break; - error = linux_to_bsd_dvd_struct(&lds, &bds); + goto out; + error = linux_to_bsd_dvd_struct(lds, bds); if (error) - break; - error = fo_ioctl(fp, DVDIOCREADSTRUCTURE, (caddr_t)&bds, + goto out; + error = fo_ioctl(fp, DVDIOCREADSTRUCTURE, (caddr_t)bds, td->td_ucred, td); if (error) - break; - error = bsd_to_linux_dvd_struct(&bds, &lds); + goto out; + error = bsd_to_linux_dvd_struct(bds, lds); if (error) - break; - error = copyout(&lds, (void *)args->arg, sizeof(lds)); + goto out; + error = copyout(lds, (void *)args->arg, sizeof(*lds)); + out: + free(bds, M_LINUX); + free(lds, M_LINUX); break; }