Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp44620imm; Thu, 7 Jun 2018 13:30:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIXpMNo5SIVexELtM0n4WGo7nuxPX/lFkdhLvl+0g/6flUKAVtvrRQ3mr/4Xz/6fvKIVv0g X-Received: by 2002:a17:902:d716:: with SMTP id w22-v6mr3412018ply.98.1528403417963; Thu, 07 Jun 2018 13:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528403417; cv=none; d=google.com; s=arc-20160816; b=buXlfqxRB59bwcjDQ5ZYz1V5Ts8p6TYpXf0uH9dLj07AXK6Sv5A5YHSGHI2DwWqHMC UIDS/mCTfuOUOPtySH36khi8EEiV2jYwKt/Dbh8di5rEAVXzmJCJtI7pUxXDE2ZmLtFb TSLL5OiJicnucClamBLKq2fv3T/bMDqad2NFsSYCs6wzEVLt79+ByvPPFuSBNzUH+UCa Umg5pOhgQpgi1NyIlrpRQmq/Q3VYcN1uqk/TryifI4gnGLy/FVVbNwOwbM1qisWK5oEr 1laJzqenaq8yHfNT1DBYk184ewU3IAyiZ38c0Y0fjZiL34OLIOgg5m7ai3syI3/pTaWe r+wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=92TvZsl494ypeys0WXaV5Ta4QMESlp1LXmzzwDQAXIE=; b=hICCxrAbSb0F22LF3+s0g2s8Llqaigckwgagq9umYkz1jR2e7SNguWyPQxLB4crjfM 9WYQ3obn5yPim58DgIzqOwQwNyu7cjcqZgvu3U0J/7MckLJxtCAhT8iSgvkmbNsKLYGB MF2ZB7JjRon2xIanyuOeMGV4chqXK5D1xGqa5nObVFf265kLgxcHSGKU7PZj/AVDM7fG N4OTn3Fe2DrT/YA1qEUtYb06HV8nkT1SLymT+Di5U7CPgKUXx6p33R7OFbyRk3mOjOcJ Mi/u8fhiW3wHrHCIPveZFq9VkNTG4ejf18xUIVxfDwT28Y0loWu6kwX2lRqJRimNhx7q Gn1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=K+RmU80A; 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 q3-v6si1105523plb.238.2018.06.07.13.30.01; Thu, 07 Jun 2018 13:30:17 -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; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=K+RmU80A; 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 S932219AbeFGU2e (ORCPT + 99 others); Thu, 7 Jun 2018 16:28:34 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34762 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753103AbeFGU2c (ORCPT ); Thu, 7 Jun 2018 16:28:32 -0400 Received: by mail-pf0-f195.google.com with SMTP id a63-v6so5470339pfl.1 for ; Thu, 07 Jun 2018 13:28:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho-ws.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=92TvZsl494ypeys0WXaV5Ta4QMESlp1LXmzzwDQAXIE=; b=K+RmU80AU4LXSIoCjIvyKcu7x25t+n0qbxkZPLVn5sPqNQz/J66x3GlKIBi51v+e+9 Cz20QYXZmLXkPGJrlQnyeWOmoU0Dy28F9GrM+RPyfGJXlPdYMR5fZUxUu84LLBQC4W7a m1r5LLiH0ukeRBCBI2XE8R2wZDoiGfYkK7Qt/eRpHRS1yRVVdQMpnm/geIZY+or4A+XI NUF6bFfc9OEh9sRMeglHHKbeUTJRcTifIZsf3+HyDjfd1hwU0YN4gkx+S2OQZGZVTVUY sVM0BaQ1VAQ/m2LUxb4jckYuFfVwsECKnykyEwmfO1+pfxCq0dsEgQOjwdJmF2Y1i79w MHhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=92TvZsl494ypeys0WXaV5Ta4QMESlp1LXmzzwDQAXIE=; b=rduZ0JPmV+zUJzT9vSOSVbwo2iySHKHUtwoTIpNSH+EZRhpX6KajMx2TZhAvTLuZ/+ GhBADEDCkzIJMiOoRPFoCycpoMiHBN7NOVYwtBsgEwCkQWUihMnNba+1ch7yiqJuZJHk /fQPpahEGBunNwitnzTdT+rKWKXNHhXOD5HYcjL/mfU0qjB5xP7SWGu62uuX80fo5zQY fnFgAhYHwXOZBoWpr5xddTtqoF1KdXd1aqD/GHQGh0h9amyuYhYOAZl2jYuK+RY3RzeM 4Pa0U9aCWlEnZocStu0V6QLxVMvR0w1sIPoMlC8CwZfvf36sMSgq05nf9JX/uFiH9ofR kcSg== X-Gm-Message-State: APt69E3emkuA30Vh0zJX5VMK6CMLnTWTHpclPuSRiK1z62F/ts5ZEyvX hQp2JALq03+qmXsNJDRHKu7w9i5kdLA= X-Received: by 2002:a65:53cc:: with SMTP id z12-v6mr2764381pgr.350.1528403311720; Thu, 07 Jun 2018 13:28:31 -0700 (PDT) Received: from cisco ([128.107.241.177]) by smtp.gmail.com with ESMTPSA id r26-v6sm72405546pfj.180.2018.06.07.13.28.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Jun 2018 13:28:30 -0700 (PDT) Date: Thu, 7 Jun 2018 14:28:31 -0600 From: Tycho Andersen To: Eric Biggers Cc: David Howells , James Morris , keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Kees Cook , Stephan Mueller , Eric Biggers Subject: Re: [PATCH] dh key: fix rounding up KDF output length Message-ID: <20180607202831.GG9999@cisco> References: <0000000000009c221d056e0cf53a@google.com> <20180607191201.97080-1-ebiggers3@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180607191201.97080-1-ebiggers3@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 07, 2018 at 12:12:01PM -0700, 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. > > Reported-by: syzbot+486f97f892efeb2075a3@syzkaller.appspotmail.com > Reported-by: syzbot+29d17b7898b41ee120a5@syzkaller.appspotmail.com > Reported-by: syzbot+8a608baf8751184ec727@syzkaller.appspotmail.com > Reported-by: syzbot+d04e58bd384f1fe0b112@syzkaller.appspotmail.com > Fixes: 383203eff718 ("dh key: get rid of stack allocated array") > Signed-off-by: Eric Biggers Arg, thanks. Acked-by: Tycho Andersen