From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754763AbcASNYS (ORCPT ); Tue, 19 Jan 2016 08:24:18 -0500 Received: from helcar.hengli.com.au ([209.40.204.226]:47511 "EHLO helcar.hengli.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751051AbcASNYG (ORCPT ); Tue, 19 Jan 2016 08:24:06 -0500 Date: Tue, 19 Jan 2016 21:23:57 +0800 From: Herbert Xu To: Dmitry Vyukov Cc: "David S. Miller" , linux-crypto@vger.kernel.org, LKML , syzkaller , Kostya Serebryany , Alexander Potapenko , Sasha Levin , Eric Dumazet , Tadeusz Struk Subject: Re: crypto: GPF in scatterwalk_start Message-ID: <20160119132357.GA10447@gondor.apana.org.au> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 19, 2016 at 09:30:40AM +0100, Dmitry Vyukov wrote: > > The following program causes GPF in scatterwalk_start. > > Herbert, I am on commit 5807fcaa9bf7dd87241df739161c119cf78a6bc4 with > all your fixes applied, including the fix for out-of-bounds in > skcipher_recvmsg. OK this is an off-by-one bug in skcipher_sendmsg. ---8<--- Subject: crypto: algif_skcipher - sendmsg SG marking is off by one We mark the end of the SG list in sendmsg and sendpage and unmark it on the next send call. Unfortunately the unmarking in sendmsg is off-by-one, leading to an SG list that is too short. Fixes: 0f477b655a52 ("crypto: algif - Mark sgl end at the end of data") Cc: stable@vger.kernel.org Signed-off-by: Herbert Xu diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c index 76ecb40..38c1aa8 100644 --- a/crypto/algif_skcipher.c +++ b/crypto/algif_skcipher.c @@ -392,7 +392,8 @@ static int skcipher_sendmsg(struct socket *sock, struct msghdr *msg, sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list); sg = sgl->sg; - sg_unmark_end(sg + sgl->cur); + if (sgl->cur) + sg_unmark_end(sg + sgl->cur - 1); do { i = sgl->cur; plen = min_t(size_t, len, PAGE_SIZE); -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt