From owner-freebsd-i386@FreeBSD.ORG Thu Jul 5 13:00:11 2007 Return-Path: X-Original-To: freebsd-i386@hub.freebsd.org Delivered-To: freebsd-i386@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DE68216A421 for ; Thu, 5 Jul 2007 13:00:11 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id 70F5213C489 for ; Thu, 5 Jul 2007 13:00:11 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l65D0B8F080352 for ; Thu, 5 Jul 2007 13:00:11 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l65D0Bni080351; Thu, 5 Jul 2007 13:00:11 GMT (envelope-from gnats) Resent-Date: Thu, 5 Jul 2007 13:00:11 GMT Resent-Message-Id: <200707051300.l65D0Bni080351@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-i386@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Fabien THOMAS Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2B49816A421 for ; Thu, 5 Jul 2007 12:55:16 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [69.147.83.33]) by mx1.freebsd.org (Postfix) with ESMTP id 1D40C13C489 for ; Thu, 5 Jul 2007 12:55:16 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l65CtFlj011419 for ; Thu, 5 Jul 2007 12:55:15 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id l65CtFZ5011418; Thu, 5 Jul 2007 12:55:15 GMT (envelope-from nobody) Message-Id: <200707051255.l65CtFZ5011418@www.freebsd.org> Date: Thu, 5 Jul 2007 12:55:15 GMT From: Fabien THOMAS To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.0 Cc: Subject: i386/114331: VIA padlock freesession bug X-BeenThere: freebsd-i386@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: I386-specific issues for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jul 2007 13:00:12 -0000 >Number: 114331 >Category: i386 >Synopsis: VIA padlock freesession bug >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-i386 >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jul 05 13:00:10 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Fabien THOMAS >Release: FreeBSD 6.2-p5 >Organization: NETASQ >Environment: >Description: There is a bug in the VIA padlock cryptodev code: When the session are recycled the freed session is not inserted at the good place (head). The resulting bug is if you have one program with cryptodev opened and a second one doing open / close the kernel will continuously grown because the recycling will not occur. Hiden behind this bug a second one that leave the system completly unusable because the session id is cleared and not allocated again on a cached session. >How-To-Repeat: launch one program with an open crypto session. launch a second one periodically (on each run you will loose some KB of memory). >Fix: Find attached a fix for the problem. Another better solution is to rework the session cache by having a free list with an active count and a maximum cached entry. Patch attached with submission follows: --- padlock.c.orig Thu Jul 5 12:26:18 2007 +++ padlock.c Thu Jul 5 12:34:40 2007 @@ -222,6 +222,7 @@ else { TAILQ_REMOVE(&sc->sc_sessions, ses, ses_next); ses->ses_used = 1; + ses->ses_id = sc->sc_sid++; TAILQ_INSERT_TAIL(&sc->sc_sessions, ses, ses_next); } mtx_unlock(&sc->sc_sessions_mtx); @@ -276,7 +277,7 @@ padlock_hash_free(ses); bzero(ses, sizeof(*ses)); ses->ses_used = 0; - TAILQ_INSERT_TAIL(&sc->sc_sessions, ses, ses_next); + TAILQ_INSERT_HEAD(&sc->sc_sessions, ses, ses_next); mtx_unlock(&sc->sc_sessions_mtx); return (0); } >Release-Note: >Audit-Trail: >Unformatted: