From owner-svn-src-head@freebsd.org Tue Apr 25 10:29:10 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15F15D4FEBD; Tue, 25 Apr 2017 10:29:10 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DA89D397; Tue, 25 Apr 2017 10:29:09 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3PAT8QU017326; Tue, 25 Apr 2017 10:29:08 GMT (envelope-from dfr@FreeBSD.org) Received: (from dfr@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3PAT8tw017325; Tue, 25 Apr 2017 10:29:08 GMT (envelope-from dfr@FreeBSD.org) Message-Id: <201704251029.v3PAT8tw017325@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dfr set sender to dfr@FreeBSD.org using -f From: Doug Rabson Date: Tue, 25 Apr 2017 10:29:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r317402 - head/lib/librpcsec_gss X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Apr 2017 10:29:10 -0000 Author: dfr Date: Tue Apr 25 10:29:08 2017 New Revision: 317402 URL: https://svnweb.freebsd.org/changeset/base/317402 Log: Fix a potential problem where we might try to shift by more than 31 bits CID: 1198859 Modified: head/lib/librpcsec_gss/svc_rpcsec_gss.c Modified: head/lib/librpcsec_gss/svc_rpcsec_gss.c ============================================================================== --- head/lib/librpcsec_gss/svc_rpcsec_gss.c Tue Apr 25 09:08:44 2017 (r317401) +++ head/lib/librpcsec_gss/svc_rpcsec_gss.c Tue Apr 25 10:29:08 2017 (r317402) @@ -913,7 +913,9 @@ svc_rpc_gss_update_seq(struct svc_rpc_gs { int offset, i, word, bit; uint32_t carry, newcarry; + uint32_t* maskp; + maskp = client->cl_seqmask; if (seq > client->cl_seqlast) { /* * This request has a sequence number greater @@ -923,28 +925,29 @@ svc_rpc_gss_update_seq(struct svc_rpc_gs * number) */ offset = seq - client->cl_seqlast; - while (offset > 32) { + while (offset >= 32) { for (i = (SVC_RPC_GSS_SEQWINDOW / 32) - 1; i > 0; i--) { - client->cl_seqmask[i] = client->cl_seqmask[i-1]; + maskp[i] = maskp[i-1]; } - client->cl_seqmask[0] = 0; + maskp[0] = 0; offset -= 32; } - carry = 0; - for (i = 0; i < SVC_RPC_GSS_SEQWINDOW / 32; i++) { - newcarry = client->cl_seqmask[i] >> (32 - offset); - client->cl_seqmask[i] = - (client->cl_seqmask[i] << offset) | carry; - carry = newcarry; + if (offset > 0) { + carry = 0; + for (i = 0; i < SVC_RPC_GSS_SEQWINDOW / 32; i++) { + newcarry = maskp[i] >> (32 - offset); + maskp[i] = (maskp[i] << offset) | carry; + carry = newcarry; + } } - client->cl_seqmask[0] |= 1; + maskp[0] |= 1; client->cl_seqlast = seq; } else { offset = client->cl_seqlast - seq; word = offset / 32; bit = offset % 32; - client->cl_seqmask[word] |= (1 << bit); + maskp[word] |= (1 << bit); } }