Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1947846AbdD1Ll5 (ORCPT ); Fri, 28 Apr 2017 07:41:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49642 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164125AbdD1Llg (ORCPT ); Fri, 28 Apr 2017 07:41:36 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 02344C04D2B7 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=queasysnail.net Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=sd@queasysnail.net DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 02344C04D2B7 Date: Fri, 28 Apr 2017 13:41:31 +0200 From: Sabrina Dubroca To: "Jason A. Donenfeld" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David.Laight@aculab.com, kernel-hardening@lists.openwall.com, davem@davemloft.net Subject: Re: [PATCH v6 3/5] rxrpc: check return value of skb_to_sgvec always Message-ID: <20170428114131.GA31833@bistromath.localdomain> References: <20170425155215.4835-1-Jason@zx2c4.com> <20170425184734.26563-1-Jason@zx2c4.com> <20170425184734.26563-3-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170425184734.26563-3-Jason@zx2c4.com> User-Agent: Mutt/1.8.2 (2017-04-18) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 28 Apr 2017 11:41:34 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1168 Lines: 45 2017-04-25, 20:47:32 +0200, Jason A. Donenfeld wrote: > Signed-off-by: Jason A. Donenfeld > --- > net/rxrpc/rxkad.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c > index 4374e7b9c7bf..dcf46c9c3ece 100644 > --- a/net/rxrpc/rxkad.c > +++ b/net/rxrpc/rxkad.c [...] > @@ -429,7 +432,8 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb, > } > Adding a few more lines of context: sg = _sg; if (unlikely(nsg > 4)) { sg = kmalloc(sizeof(*sg) * nsg, GFP_NOIO); if (!sg) goto nomem; } > sg_init_table(sg, nsg); > - skb_to_sgvec(skb, sg, offset, len); > + if (unlikely(skb_to_sgvec(skb, sg, offset, len) < 0)) > + goto nomem; You're leaking sg when nsg > 4, you'll need to add this: if (sg != _sg) kfree(sg); BTW, when you resubmit, please Cc: the maintainers of the files you're changing for each patch, so that they can review this stuff. And send patch 1 to all of them, otherwise they might be surprised that we even need <0 checking after calls to skb_to_sgvec. You might also want to add a cover letter. -- Sabrina