From patchwork Wed May 28 19:09:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 4256971 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 52C8B9F358 for ; Wed, 28 May 2014 19:09:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8CF98202E6 for ; Wed, 28 May 2014 19:09:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 74A78202F8 for ; Wed, 28 May 2014 19:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754888AbaE1TJo (ORCPT ); Wed, 28 May 2014 15:09:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43257 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751338AbaE1TJm (ORCPT ); Wed, 28 May 2014 15:09:42 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4SJ9Yad020870 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 May 2014 15:09:34 -0400 Received: from smallhat.boston.devel.redhat.com (smallhat.boston.devel.redhat.com [10.19.60.65]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4SJ9Xle017600; Wed, 28 May 2014 15:09:34 -0400 From: Steve Dickson To: Libtirpc-devel Mailing List Cc: Linux NFS Mailing list Subject: [PATCH v3] Avoid buffer overruns by allocating buffer in svcauth_gss_validate() Date: Wed, 28 May 2014 15:09:31 -0400 Message-Id: <1401304171-12231-1-git-send-email-steved@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Steve Dickson Reviewed-by: Chuck Lever --- src/svc_auth_gss.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/svc_auth_gss.c b/src/svc_auth_gss.c index 601a691..26c1065 100644 --- a/src/svc_auth_gss.c +++ b/src/svc_auth_gss.c @@ -286,21 +286,19 @@ svcauth_gss_validate(struct svc_rpc_gss_data *gd, struct rpc_msg *msg) struct opaque_auth *oa; gss_buffer_desc rpcbuf, checksum; OM_uint32 maj_stat, min_stat, qop_state; - u_char rpchdr[128]; + u_char *rpchdr; int32_t *buf; gss_log_debug("in svcauth_gss_validate()"); - memset(rpchdr, 0, sizeof(rpchdr)); - /* XXX - Reconstruct RPC header for signing (from xdr_callmsg). */ oa = &msg->rm_call.cb_cred; if (oa->oa_length > MAX_AUTH_BYTES) return (FALSE); - - /* 8 XDR units from the IXDR macro calls. */ - if (sizeof(rpchdr) < (8 * BYTES_PER_XDR_UNIT + - RNDUP(oa->oa_length))) + + rpchdr = (u_char *)calloc(((8 * BYTES_PER_XDR_UNIT) + + RNDUP(oa->oa_length)), 1); + if (rpchdr == NULL) return (FALSE); buf = (int32_t *)rpchdr; @@ -325,6 +323,8 @@ svcauth_gss_validate(struct svc_rpc_gss_data *gd, struct rpc_msg *msg) maj_stat = gss_verify_mic(&min_stat, gd->ctx, &rpcbuf, &checksum, &qop_state); + free(rpchdr); + if (maj_stat != GSS_S_COMPLETE) { gss_log_status("gss_verify_mic", maj_stat, min_stat); return (FALSE);