From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zoltan Kiss Subject: Re: [PATCH net-next v2 6/9] xen-netback: Handle guests with too many frags Date: Tue, 7 Jan 2014 15:23:15 +0000 Message-ID: <52CC1BE3.8080502__45072.248861152$1389108321$gmane$org@citrix.com> References: <1386892097-15502-1-git-send-email-zoltan.kiss@citrix.com> <1386892097-15502-7-git-send-email-zoltan.kiss@citrix.com> <20131213154307.GN21900@zion.uk.xensource.com> <52AF2602.2000409@citrix.com> <20131216180908.GC25969@zion.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1W0YV0-0003LM-9l for xen-devel@lists.xenproject.org; Tue, 07 Jan 2014 15:23:22 +0000 In-Reply-To: <20131216180908.GC25969@zion.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu Cc: xen-devel@lists.xenproject.org, jonathan.davies@citrix.com, ian.campbell@citrix.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org List-Id: xen-devel@lists.xenproject.org On 16/12/13 18:09, Wei Liu wrote: >>>> diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c >>>> index e26cdda..f6ed1c8 100644 >>>> --- a/drivers/net/xen-netback/netback.c >>>> +++ b/drivers/net/xen-netback/netback.c >>>> @@ -906,11 +906,15 @@ static struct gnttab_map_grant_ref *xenvif_get_requests(struct xenvif *vif, >>>> u16 pending_idx = *((u16 *)skb->data); >>>> int start; >>>> pending_ring_idx_t index; >>>> - unsigned int nr_slots; >>>> + unsigned int nr_slots, frag_overflow = 0; >>>> >>>> /* At this point shinfo->nr_frags is in fact the number of >>>> * slots, which can be as large as XEN_NETBK_LEGACY_SLOTS_MAX. >>>> */ >>>> + if (shinfo->nr_frags > MAX_SKB_FRAGS) { >>>> + frag_overflow = shinfo->nr_frags - MAX_SKB_FRAGS; >>>> + shinfo->nr_frags = MAX_SKB_FRAGS; >>>> + } >>>> nr_slots = shinfo->nr_frags; >>>> >>> >>> It is also probably better to check whether shinfo->nr_frags is too >>> large which makes frag_overflow > MAX_SKB_FRAGS. I know skb should be >>> already be valid at this point but it wouldn't hurt to be more careful. >> Ok, I've added this: >> /* At this point shinfo->nr_frags is in fact the number of >> * slots, which can be as large as XEN_NETBK_LEGACY_SLOTS_MAX. >> */ >> + if (shinfo->nr_frags > MAX_SKB_FRAGS) { >> + if (shinfo->nr_frags > XEN_NETBK_LEGACY_SLOTS_MAX) return NULL; >> + frag_overflow = shinfo->nr_frags - MAX_SKB_FRAGS; >> > > What I suggested is > > BUG_ON(frag_overflow > MAX_SKB_FRAGS) Ok, I've changed it. Zoli