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

Benjamin Kaduk <kaduk@MIT.EDU> Tue, 21 January 2014 20:34 UTC

Return-Path: <kaduk@mit.edu>
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 D24431A0241 for <kitten@ietfa.amsl.com>; Tue, 21 Jan 2014 12:34:26 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.136
X-Spam-Level:
X-Spam-Status: No, score=-3.136 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RP_MATCHES_RCVD=-0.535, SPF_PASS=-0.001] 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 gQNMsxYPEVfr for <kitten@ietfa.amsl.com>; Tue, 21 Jan 2014 12:34:24 -0800 (PST)
Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu [18.9.25.15]) by ietfa.amsl.com (Postfix) with ESMTP id 909621A0221 for <kitten@ietf.org>; Tue, 21 Jan 2014 12:34:24 -0800 (PST)
X-AuditID: 1209190f-f790b6d000000c3a-c6-52ded9d04a6a
Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) (using TLS with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP id AE.E5.03130.0D9DED25; Tue, 21 Jan 2014 15:34:24 -0500 (EST)
Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s0LKYNIE001288 for <kitten@ietf.org>; Tue, 21 Jan 2014 15:34:23 -0500
Received: from multics.mit.edu (system-low-sipb.mit.edu [18.187.2.37]) (authenticated bits=56) (User authenticated as kaduk@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s0LKYLKC012615 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for <kitten@ietf.org>; Tue, 21 Jan 2014 15:34:23 -0500
Received: (from kaduk@localhost) by multics.mit.edu (8.12.9.20060308) id s0LKYLu6008205; Tue, 21 Jan 2014 15:34:21 -0500 (EST)
Date: Tue, 21 Jan 2014 15:34:21 -0500
From: Benjamin Kaduk <kaduk@MIT.EDU>
To: kitten@ietf.org
In-Reply-To: <1390319809.31766.158.camel@minbar.fac.cs.cmu.edu>
Message-ID: <alpine.GSO.1.10.1401211518000.27579@multics.mit.edu>
References: <17375_1390266669_s0L1B8NX017524_20140121011057.C21EE1ABBD@ld9781.wdf.sap.corp> <1390319809.31766.158.camel@minbar.fac.cs.cmu.edu>
User-Agent: Alpine 1.10 (GSO 962 2008-03-14)
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; format="flowed"; charset="US-ASCII"
X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBIsWRmVeSWpSXmKPExsUixCmqrHvh5r0gg4XrOCyObl7F4sDosWTJ T6YAxigum5TUnMyy1CJ9uwSujGenCguOSVfMbvrC2MD4QbSLkZNDQsBEYtu5bywQtpjEhXvr 2boYuTiEBGYzSRycfxbKOc4oMWXxO3YI5waTxOmWLiYIp4FRYu+lf+wg/SwC2hL7709nBLHZ BFQkZr7ZyAZiiwgIS+ze+o4ZxBYWiJW439cDFucUsJc49+gKWJxXwFGi/9h9VoihfYwSSzf1 soIkRAV0JFbvn8ICUSQocXLmEzCbWcBS4t/aX6wTGAVmIUnNQpJawMi0ilE2JbdKNzcxM6c4 NVm3ODkxLy+1SNdELzezRC81pXQTIzgAJfl3MH47qHSIUYCDUYmHN2DXvSAh1sSy4srcQ4yS HExKoryVN4BCfEn5KZUZicUZ8UWlOanFhxglOJiVRHgNdwDleFMSK6tSi/JhUtIcLErivDc5 7IOEBNITS1KzU1MLUotgsjIcHEoSvD9AhgoWpaanVqRl5pQgpJk4OEGG8wANvwlSw1tckJhb nJkOkT/FqCglzssCjHEhAZBERmkeXC8sQbxiFAd6RZhXCKSKB5hc4LpfAQ1mAhocvQVscEki QkqqgXHuud/ar21vT/XclXHwUHZm/umpW+KmSnj/4BO22vpHZzJ3wy6zubYP+lVPBSVGvbQS rhXjPehW9eOs5g6mR3N1mRe8/dDD/PPWpO4rFW3N1S9Pd6bmLnVbO09R/N/mZXEpHkd+Pohx /7bnttnXy1zCrKYK235GqUelyC9TqKorllQ5emrJ9Q1KLMUZiYZazEXFiQAthvcZ6wIAAA==
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: Tue, 21 Jan 2014 20:34:27 -0000

Sorry for the long silence from me; I was doing a lot of non-computer 
things over the weekend and didn't really catch up all the way.

I think we've basically found agreement, more inline.

On Tue, 21 Jan 2014, Jeffrey Hutzelman wrote:

> On Tue, 2014-01-21 at 02:10 +0100, Martin Rex wrote:
>> Jeffrey Hutzelman wrote:
>>> On Mon, 2014-01-20 at 20:32 +0100, Martin Rex wrote:
>>>> Nico Williams wrote:
>>>>>
>> With that in mind, a comment like
>>
>>>
>>> /* It is safe to call gss_release_buffer twice on the same buffer. */
>>
>> is ambiguous and wrong.
>
> It's not ambiguous, unless you willfully misinterpret it.
> It _is_ wrong, which is what started this discussion.

By the spec it is wrong, yes...

> I think we've beat this issue into the ground.
> I think we have something resembling consensus that the example code
> should avoid double-releasing, even though what it _actually does_
> happens to be safe with current major GSS implementations.  Therefore,
> we should stop arguing about it.

...even though it is safe in all known implementations.
So, I agree that we should stop arguing about it.

>> What should be safe is calling gss_release_buffer() with an empty
>> buffer.  So the important guidance would be to *ALWAYS* create
>> gss_buffer_desc structures initialized with {0, 0} in C.
>
> The spec doesn't say this is safe.  In fact, the only sorts of buffers
> for which gss_release_buffer is defined are those returned as outputs
> from other GSS-API routines.  It is not explicitly safe to use it on
> empty buffers, and it is clearly not safe to use it on buffers where the
> value is memory allocated by the caller or by some other library.

I had previously had the impression that Martin conveyed in his reply, 
namely that GSS_C_EMPTY_BUFFER was special and was required to be handled 
correctly by gss_release_buffer(); however, a quick search through rfc 
2744 does not find anything to support such a claim, so I cannot make it.

As such, I think that the easiest way forward for the sample code is to 
set the buffer to GSS_C_EMPTY_BUFFER after releasing it and check for 
NULL-ness before releasing it...

> I agree that the spec should be amened to require gss_release_buffer()
> to work on empty buffers.

... which is a pretty silly thing for application code to have to do, so I 
agree with this proposal as well.

>
>>   The only sane
>> representation of an empty buffer _output_ value from a gssapi mech
>> is {0, 0}, i.e. be conservative in what you send (=give out).
>
> Also agreed, though in fact I believe the spec is pretty clear that if
> the length is 0 you cannot rely on the pointer to be NULL; it might be
> garbage instead.   However, you _can_ rely on gss_release_buffer to
> work.

I agree.  (As a side note, though 0 is a perfectly fine null pointer 
constant in C99, it is probably nicer to always spell it NULL.)



In summary:
(1) the sample code in -02 is wrong
(2) the sample code in -02 is safe with all known implementations
(3) It would be nice to update 2743/2744 to (a) require that 
gss_release_buffer(GSS_C_EMPTY_BUFFER) is safe, and (b) have 
gss_release_buffer() set the buffer to GSS_C_EMPTY_BUFFER on output 
(instead of just setting the length to 0).  This is probably out of scope 
for draft-kaduk-kitten-gss-loop.
(4) There is ongoing disagreement about empty tokens, zero-length tokens, 
absent tokens, and whether applications (are allowed to) use them.

-Ben