From owner-freebsd-hackers@FreeBSD.ORG Mon Jan 21 03:55:11 2013 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5A09C3E0; Mon, 21 Jan 2013 03:55:11 +0000 (UTC) (envelope-from yuri@rawbw.com) Received: from shell0.rawbw.com (shell0.rawbw.com [198.144.192.45]) by mx1.freebsd.org (Postfix) with ESMTP id 438747CB; Mon, 21 Jan 2013 03:55:11 +0000 (UTC) Received: from eagle.yuri.org (stunnel@localhost [127.0.0.1]) (authenticated bits=0) by shell0.rawbw.com (8.14.4/8.14.4) with ESMTP id r0L3tAnp075930; Sun, 20 Jan 2013 19:55:10 -0800 (PST) (envelope-from yuri@rawbw.com) Message-ID: <50FCBC1D.4070905@rawbw.com> Date: Sun, 20 Jan 2013 19:55:09 -0800 From: Yuri User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130112 Thunderbird/17.0.2 MIME-Version: 1.0 To: mdf@freebsd.org Subject: Re: How to validate the variable size memory block in ioctl handler? References: <50FC7767.4050207@rawbw.com> <50FCACEC.8000100@rawbw.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jan 2013 03:55:11 -0000 On 01/20/2013 19:15, mdf@freebsd.org wrote: > This would be fine for a local patch but it breaks existing (valid) > uses that have exactly 8191 bytes of data, so it wouldn't be suitable > for the main FreeBSD repository. Also, in general one wants to have > limits on syscalls that can force a kernel malloc of any size, as it > leads to denial of service attacks or crashes by requesting the kernel > over-allocate memory. Both problems are easily fixable. Current len range can be preserved by encoding this case into an 'inout' parameter of _IOC instead. IOC_VOID is only used when no IOC_IN/IOC_OUT is set, so all 3 bits would mean _IORWE. And arbitrarily high parameter size can be explicitly limited in sys_generic.c to IOCPARM_MAX. Yuri