Re: [kitten] New Version Notification for draft-kaduk-kitten-gss-loop-02.txt (fwd)
Nico Williams <nico@cryptonector.com> Sat, 18 January 2014 06:18 UTC
Return-Path: <nico@cryptonector.com>
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 2C7A31ADE72 for <kitten@ietfa.amsl.com>; Fri, 17 Jan 2014 22:18:54 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.378
X-Spam-Level:
X-Spam-Status: No, score=-1.378 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FM_FORGED_GMAIL=0.622, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=no
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 tk0-tk7jAT4u for <kitten@ietfa.amsl.com>; Fri, 17 Jan 2014 22:18:53 -0800 (PST)
Received: from homiemail-a28.g.dreamhost.com (caiajhbdcbef.dreamhost.com [208.97.132.145]) by ietfa.amsl.com (Postfix) with ESMTP id 1E0601ADEA1 for <kitten@ietf.org>; Fri, 17 Jan 2014 22:18:53 -0800 (PST)
Received: from homiemail-a28.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a28.g.dreamhost.com (Postfix) with ESMTP id 6BA761B4059 for <kitten@ietf.org>; Fri, 17 Jan 2014 22:18:40 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cryptonector.com; h= mime-version:in-reply-to:references:date:message-id:subject:from :to:cc:content-type; s=cryptonector.com; bh=FBHTfudduiowdOC8dc7e ddhGVow=; b=fTANU6DwSvnIXmHVnw/gLLD1lUxY4MiNav7H+oMXORYkj+9hZf4B Ermx7pPxBpaBsWYrVtnw1ejfZOt/+aRvvk6VtuK9RQzFr2wzFqNs9Vk6B4nFwDpy iD3PTwgjHGHZMFawNUT2Rw6+gq8+/TyZgxGsPzhcgtlqvwEsWFw9BiU=
Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: nico@cryptonector.com) by homiemail-a28.g.dreamhost.com (Postfix) with ESMTPSA id EB0671B4058 for <kitten@ietf.org>; Fri, 17 Jan 2014 22:18:39 -0800 (PST)
Received: by mail-wi0-f180.google.com with SMTP id d13so1532053wiw.13 for <kitten@ietf.org>; Fri, 17 Jan 2014 22:18:38 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=JQLvm9oQSJeznJEVuacGx4iHC8O1RM+pO8spH03NZLE=; b=W56tax7SdBRqWOkI/NATfK7wfYqaNuusxqTjgOyESPUT0NAtnmv1oXK8OIkIGM1W8x dJwwijW7I0GDAXEOXc1qPB5IDY1+2FruFwIVhV8PrgwAfmOvXY+IjXr+KuaKyIEDrg56 qNszVcUTKTSeg/1zo8KQZQheqhTfE5PmCseawejAakDwa22bHCjP2TA4dB/y4K0/T9yh SrO4b9YCMYRcCfkinSOqixkthAJsLMmveI3JidEEV4U7meOhLxRnvEMDOsu/WRpx0EoV gTQGcLJXQHeCQ+LbY07q2AYkVsZkn5EsgL7Ipuv2IiVc04vdxu1ZfxsCbBZMEKL9six1 0obw==
MIME-Version: 1.0
X-Received: by 10.180.104.72 with SMTP id gc8mr1558661wib.5.1390025918259; Fri, 17 Jan 2014 22:18:38 -0800 (PST)
Received: by 10.217.108.132 with HTTP; Fri, 17 Jan 2014 22:18:38 -0800 (PST)
In-Reply-To: <8761pikqz5.fsf@windlord.stanford.edu>
References: <52D99B63.3040005@mit.edu> <20140118010111.326F31ABB3@ld9781.wdf.sap.corp> <CAK3OfOiMs3GUK34HuzxLHiktjFNJQV9n1pr_S1GW2eNk=8kaeA@mail.gmail.com> <8761pikqz5.fsf@windlord.stanford.edu>
Date: Sat, 18 Jan 2014 00:18:38 -0600
Message-ID: <CAK3OfOjVKdNW2S+xa=jTY5nzuJr8woDmynDboje1AHe8MCb_gw@mail.gmail.com>
From: Nico Williams <nico@cryptonector.com>
To: Russ Allbery <eagle@eyrie.org>
Content-Type: text/plain; charset="UTF-8"
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 06:18:54 -0000
On Fri, Jan 17, 2014 at 7:39 PM, Russ Allbery <eagle@eyrie.org> wrote:
> 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);
I'm not sure that that's what he meant, but if that's what he meant
then that's fine with me. No matter what sort of type gss_buffer_desc
might be (a struct here, but suppose it was an int or a pointer), and
considering the side-effects of gss_release_buffer(), that could not
possibly be safe.
But I think Martin meant that this is not supposed to be safe:
gss_buffer_desc buf;
gss_OID oid;
gss_name_t name;
OM_uint32 major, minor;
/* ... */
major = gss_display_name(&minor, name, &buf, &oid);
gss_release_buffer(&minor, &buf); /* sets buf to {0, NULL} */
gss_release_buffer(&minor, &buf); /* releasing {0, NULL} is safe,
like free(NULL) */
> 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.
Right, the type could be an integer, a pointer, a struct -- it doesn't matter.
Of course, an implementation could protect against double-release in
some cases. But they aren't and shouldn't be required to.
What I'm saying is that the design of the C bindings' release/delete
functions is meant to set the variable whose pointer is passed in to
the zero/null/empty value. No other interpretation is possible. Why
ever bother taking a pointer to a variable instead of the value
otherwise?
Oh, and see the text in RFC2744, section 3.9.2:
The minor_status parameter will always be set by a GSS-API routine,
even if it returns a calling error or one of the generic API errors
indicated above as fatal, although most other output parameters may
remain unset in such cases. However, output parameters that are
expected to return pointers to storage allocated by a routine must
always be set by the routine, even in the event of an error, although
in such cases the GSS-API routine may elect to set the returned
parameter value to NULL to indicate that no storage was actually
allocated. Any length field associated with such pointers (as in a
gss_buffer_desc structure) should also be set to zero in such cases.
That only leaves the question of whether gss_release_buffer()'s
gss_buffer_t argument is an input/output parameter (it clearly has to
at least be an input parameter, but also clearly no actual output
other than {0, NULL} is intended!).
> 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
Or with just about *any* API. You shouldn't close(2) the same fildes
twice, for example, nor free(3) the same pointer twice, nor munmap(2)
the same address twice, and so on.
> 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.
This is clearly intended to be safe:
gss_buffer_desc buf;
gss_OID oid;
gss_name_t name;
OM_uint32 major, minor;
/* ... */
major = gss_display_name(&minor, name, &buf, &oid);
gss_release_buffer(&minor, &buf); /* sets buf to {0, NULL} */
gss_release_buffer(&minor, &buf); /* releasing {0, NULL} is safe,
like free(NULL) */
Nico
--
- [kitten] New Version Notification for draft-kaduk… Benjamin Kaduk
- Re: [kitten] New Version Notification for draft-k… Greg Hudson
- Re: [kitten] New Version Notification for draft-k… Martin Rex
- Re: [kitten] New Version Notification for draft-k… Nico Williams
- Re: [kitten] New Version Notification for draft-k… Russ Allbery
- Re: [kitten] New Version Notification for draft-k… Greg Hudson
- Re: [kitten] New Version Notification for draft-k… Nico Williams
- Re: [kitten] New Version Notification for draft-k… Nico Williams
- Re: [kitten] New Version Notification for draft-k… Jeffrey Hutzelman
- Re: [kitten] New Version Notification for draft-k… Nico Williams
- Re: [kitten] New Version Notification for draft-k… Martin Rex
- Re: [kitten] New Version Notification for draft-k… Jeffrey Hutzelman
- Re: [kitten] New Version Notification for draft-k… Martin Rex
- Re: [kitten] New Version Notification for draft-k… Jeffrey Hutzelman
- Re: [kitten] New Version Notification for draft-k… Martin Rex
- Re: [kitten] New Version Notification for draft-k… Benjamin Kaduk