Re: [kitten] New Version Notification for draft-kaduk-kitten-gss-loop-02.txt (fwd)

Russ Allbery <eagle@eyrie.org> Sat, 18 January 2014 01:40 UTC

Return-Path: <eagle@eyrie.org>
X-Original-To: kitten@ietfa.amsl.com
Delivered-To: kitten@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 86D1B1AC4A3 for <kitten@ietfa.amsl.com>; Fri, 17 Jan 2014 17:40:14 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.2
X-Spam-Level:
X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WsDjXYGHj4x4 for <kitten@ietfa.amsl.com>; Fri, 17 Jan 2014 17:40:13 -0800 (PST)
Received: from smtp.stanford.edu (smtp2.Stanford.EDU [171.67.219.82]) by ietfa.amsl.com (Postfix) with ESMTP id 07BE71A1F74 for <kitten@ietf.org>; Fri, 17 Jan 2014 17:40:13 -0800 (PST)
Received: from smtp.stanford.edu (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id 96CB434118D; Fri, 17 Jan 2014 17:40:00 -0800 (PST)
Received: from windlord.stanford.edu (windlord.Stanford.EDU [171.67.225.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.stanford.edu (Postfix) with ESMTPS id 714B9341184; Fri, 17 Jan 2014 17:39:59 -0800 (PST)
Received: by windlord.stanford.edu (Postfix, from userid 1000) id 55D6D2F808; Fri, 17 Jan 2014 17:39:58 -0800 (PST)
From: Russ Allbery <eagle@eyrie.org>
To: Nico Williams <nico@cryptonector.com>
In-Reply-To: <CAK3OfOiMs3GUK34HuzxLHiktjFNJQV9n1pr_S1GW2eNk=8kaeA@mail.gmail.com> (Nico Williams's message of "Fri, 17 Jan 2014 19:18:17 -0600")
Organization: The Eyrie
References: <52D99B63.3040005@mit.edu> <20140118010111.326F31ABB3@ld9781.wdf.sap.corp> <CAK3OfOiMs3GUK34HuzxLHiktjFNJQV9n1pr_S1GW2eNk=8kaeA@mail.gmail.com>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
Date: Fri, 17 Jan 2014 17:39:58 -0800
Message-ID: <8761pikqz5.fsf@windlord.stanford.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Cc: "kitten@ietf.org" <kitten@ietf.org>
Subject: Re: [kitten] New Version Notification for draft-kaduk-kitten-gss-loop-02.txt (fwd)
X-BeenThere: kitten@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Common Authentication Technologies - Next Generation <kitten.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/kitten>, <mailto:kitten-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/kitten/>
List-Post: <mailto:kitten@ietf.org>
List-Help: <mailto:kitten-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/kitten>, <mailto:kitten-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 18 Jan 2014 01:40:14 -0000

Nico Williams <nico@cryptonector.com> writes:

> The C bindings release/delete functions generally take a pointer to a
> variable that holds the thing being released precisely so they can set
> that variable to the appropriate GSS_C_NO_* value.

I think Martin's point is that the following is not safe:

    gss_buffer_desc buf1, buf2;
    gss_OID oid;
    gss_name_t name;
    OM_uint32 major, minor;

    /* ... */

    major = gss_display_name(&minor, name, &buf1, &oid);
    buf2 = buf1;
    gss_release_buffer(&minor, &buf1);
    gss_release_buffer(&minor, &buf2);

Similar sorts of code work with other GSS-API objects.  It doesn't really
matter whether the variable type is actually a struct or a pointer; either
way, once you start making copies, double frees are still a risk.

Now, obviously, you generally should avoid doing that sort of thing in
GSS-API code precisely because it's not safe.  But saying that it's
permissible to pass the same buffer to gss_release_buffer multiple times
implies that this sort of thing is safe, and I'm pretty sure it isn't.

-- 
Russ Allbery (eagle@eyrie.org)              <http://www.eyrie.org/~eagle/>