Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2550199imm; Thu, 7 Jun 2018 12:33:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKwfdFrUuUxF7A4Yus62Jav+iqqh8x+1vtm99/pUHXyxveT/TAE+nPUW+b9Qv6xiIdjzxGG X-Received: by 2002:a17:902:6b8b:: with SMTP id p11-v6mr3286494plk.212.1528400037683; Thu, 07 Jun 2018 12:33:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528400037; cv=none; d=google.com; s=arc-20160816; b=ov3czSq2yNtGYGm3Ot481+Rr5g3crkNJ0KCVt9HNCVV0Mg4X1BzuXaVAkniSD5STor g8KOxjqdfvSJ4neSshbjtQE+9VJq3ArFc5ElKsLlrrS+/WSeNVU2YYO3lfJ2DozBWBxK N00rvZ8hSLuAhLNv9AxmI9CZrAWirevCoq0flV2Q1bziaH0qgTG8RGFd+VD7/QFFAANL khcQ0Hk2mwIMdxDeBzTFi9Ky/nFLrMzVKuMYd27ZJYwsTOlieIzMseiopycAy20pA0j6 Sle+DIWh7NVLdezho1ER5Wves8GwoUFbNYrnUtomfynUTFOIgeOaOqlueQJYBXWtfYlw fBYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=/R4DHh2zAKgvDvT4F49cg8dunBckxmDTXY4rYjhGHjw=; b=FDi7RtNmgYlL5YteRGpStsQvDA/ApVuoV28SPNu6M69VyHnr5SzOgp+Q3rZkvvvYX5 j1b/kiIa6zlioZXSnD7vINPN6cNBRQZjXGpOnn681f1EXEmopSVej0cGFjIhgZ5d7ydu VEIqe1A1H38Eei8d2ckDIAsQFCKK9cr05z+FlAsqMMrjEl46uJL1yRcsIkw5qzdZhE49 LV1ufmifZH3ZnsF/gyrlhxNLouiNfo7akFA6Z2K1j+heoI5Og5885zZ1GFB2flOXgo+t d1KyPzBTKF9yzL5H/JX1acQ98H+KiuOMOQg0V+05+Y/2F2Vi/J3bgOkIWZBS2w4/6Ru2 +4Ew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i1-v6si52457810pld.152.2018.06.07.12.32.57; Thu, 07 Jun 2018 12:33:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753156AbeFGT2R (ORCPT + 99 others); Thu, 7 Jun 2018 15:28:17 -0400 Received: from namei.org ([65.99.196.166]:58522 "EHLO namei.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751037AbeFGT2Q (ORCPT ); Thu, 7 Jun 2018 15:28:16 -0400 Received: from localhost (localhost [127.0.0.1]) by namei.org (8.14.4/8.14.4) with ESMTP id w57JS1dr007551; Thu, 7 Jun 2018 19:28:01 GMT Date: Fri, 8 Jun 2018 05:28:01 +1000 (AEST) From: James Morris To: Kees Cook cc: Eric Biggers , David Howells , keyrings@vger.kernel.org, linux-security-module , linux-crypto , LKML , syzkaller-bugs@googlegroups.com, Tycho Andersen , Stephan Mueller , Eric Biggers Subject: Re: [PATCH] dh key: fix rounding up KDF output length In-Reply-To: Message-ID: References: <0000000000009c221d056e0cf53a@google.com> <20180607191201.97080-1-ebiggers3@gmail.com> User-Agent: Alpine 2.21 (LRH 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 7 Jun 2018, Kees Cook wrote: > On Thu, Jun 7, 2018 at 12:12 PM, Eric Biggers wrote: > > From: Eric Biggers > > > > Commit 383203eff718 ("dh key: get rid of stack allocated array") changed > > kdf_ctr() to assume that the length of key material to derive is a > > multiple of the digest size. The length was supposed to be rounded up > > accordingly. However, the round_up() macro was used which only gives > > the correct result on power-of-2 arguments, whereas not all hash > > algorithms have power-of-2 digest sizes. In some cases this resulted in > > a write past the end of the 'outbuf' buffer. > > > > Fix it by switching to roundup(), which works for non-power-of-2 inputs. > > round_up() vs roundup(). Wow, that's not confusing. :( I wonder if we > should rename the former to roundup_pow2() or something? Good idea, in a separate patch(set). -- James Morris