Received: from pch.mit.edu (PCH.MIT.EDU [18.7.21.90]) by krbdev.mit.edu (8.12.9) with ESMTP id m21HDdHW001288; Sat, 1 Mar 2008 12:13:39 -0500 (EST) Received: from pch.mit.edu (pch.mit.edu [127.0.0.1]) by pch.mit.edu (8.13.6/8.12.8) with ESMTP id m21HDYEQ005728; Sat, 1 Mar 2008 12:13:34 -0500 Received: from fort-point-station.mit.edu (FORT-POINT-STATION.MIT.EDU [18.7.7.76]) by pch.mit.edu (8.13.6/8.12.8) with ESMTP id m1TKareL009969 for ; Fri, 29 Feb 2008 15:36:55 -0500 Received: from mit.edu (W92-130-BARRACUDA-2.MIT.EDU [18.7.21.223]) by fort-point-station.mit.edu (8.13.6/8.9.2) with ESMTP id m1TKaglL001143 for ; Fri, 29 Feb 2008 15:36:44 -0500 (EST) Received: from arioch.imrryr.org (arioch.imrryr.org [38.117.134.205]) by mit.edu (Spam Firewall) with ESMTP id 883A2D0136E for ; Fri, 29 Feb 2008 15:36:21 -0500 (EST) Received: from imrryr.org (localhost [127.0.0.1]) by arioch.imrryr.org (Postfix) with ESMTP id 85C3E3718B for ; Fri, 29 Feb 2008 15:36:20 -0500 (EST) To: krb5-bugs@mit.edu Subject: mutex locking issues in memory ccaches Organization: None to speak of... User-Agent: nmh-1.0.4 (NetBSD/alpha) X-Copyright: Copyright 2005, R. C. Dowdeswell. All Rights Reserved. X-Window-System: Release 6.3 Date: Fri, 29 Feb 2008 15:36:20 -0500 From: Roland Dowdeswell Message-ID: <20080229203620.85C3E3718B@arioch.imrryr.org> X-Spam-Score: 0.00 X-Spam-Flag: NO X-Scanned-BY: MIMEDefang 2.42 X-Mailman-Approved-At: Sat, 01 Mar 2008 12:13:32 -0500 X-Beenthere: krb5-bugs-incoming@mailman.mit.edu X-Mailman-Version: 2.1.6 Precedence: list Sender: krb5-bugs-incoming-bounces@PCH.MIT.EDU Errors-To: krb5-bugs-incoming-bounces@PCH.MIT.EDU X-RT-Original-Encoding: iso-8859-1 Content-Length: 1314 There are two mutex locking issues that I've noticed in the memory ccache. The first one is in cc_memory.c:krb5_mcc_initialize(). When it is free(3)ing the existing credentials it does not lock the data structures and hence two separate threads can run into issues. I attach a proposed patch for this issue. I think though, that krb5_mcc_destroy() will also have the same issue but I haven't provided a patch. Thanks, -- Roland C. Dowdeswell Index: cc_memory.c =================================================================== RCS file: /ms/dev/kerberos/mitkrb5/cvs-dirs/mitkrb5-1.4/mitkrb5/src/lib/krb5/ccache/cc_memory.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -u -r1.2 -r1.3 --- cc_memory.c 29 Feb 2008 20:23:23 -0000 1.2 +++ cc_memory.c 29 Feb 2008 20:24:30 -0000 1.3 @@ -118,10 +118,18 @@ krb5_mcc_initialize(krb5_context context, krb5_ccache id, krb5_principal princ) { krb5_error_code ret; + krb5_error_code err; + krb5_mcc_data *d; + + d = id->data; + err = k5_mutex_lock(&d->lock); + if (err) + return err; krb5_mcc_free(context, id); ret = krb5_copy_principal(context, princ, &((krb5_mcc_data *)id->data)->prin); + k5_mutex_unlock(&d->lock); if (ret == KRB5_OK) krb5_change_cache(); return ret;