Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1932200ybl; Tue, 3 Dec 2019 15:13:27 -0800 (PST) X-Google-Smtp-Source: APXvYqyMNmoApzeeLvV6yMZhGp7jrV8FWoArHkw0UtGctYwL+IFpYXkWUA0iBt3s84EFoU/U1+DQ X-Received: by 2002:a9d:1295:: with SMTP id g21mr279013otg.301.1575414807234; Tue, 03 Dec 2019 15:13:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575414807; cv=none; d=google.com; s=arc-20160816; b=ujSCr74LhWeMsVeBJXxFlrIiW24zHpG/I0kfBfhaH1QmxfBprDUOHdNhzSF9spl83Y dsTMc74KWsrWoFb+Gr3Xx4LQOPTCjYISh1W+xC0gKm7rFDX1ij3YdZ+J8NcVqTXbQ6hl nZqelbHT2w2DZJET9u01muaWQxWsnHCEIBUhISIMnYaAdOLVgAykqi6UN3nxmhViUn2X MSoeCPkw8nt2tYlYepFbTNpk9fCaRK7Z07/Z5bBsNkS6cpsM2fidL+sO5m+nm2bLkZWf eTRf6RKX41evFp0691e8dtSkMiRYNv7+cElmgGdcFCoc3DGQ8Xt+aYycpVnIo9Csobi/ q6kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=h0RjTPJ3QEfecodvq/1E1Oq6gMwpVc2sdNfhDEW7jMI=; b=aRfHZg/xy7szCTln/PNzvizgVHbYYGmycTNJ7zCDe4OgricxbTl4IubJCemjHdb4nU Xx2COqAnfJe66kbBad2i/+FPRB+nlt73EmW9nkctgTLvKGcp76BMEzpVwTcOCmh+B7a6 4hfxIpSK+qetLUJ02ZbQiKEdOPPv4LhIeNRK1uwcQS63Cwo0vFP1uLnDoWr098T8F0C8 iIjfSl3QQHRe9xNAdzhvBix1a3f3BXoQNp3sBLVoM5+BA43YKW81cd4DV/Dl7m2HI0Q8 nWNPoUpdWHK92hc5OfhgjPZvPNxu1x8BcYzK/QB6Ig+FhA0laFHuDCpFBYu+IHQRHzNs RJPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J31A196h; 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 b18si1918280otl.202.2019.12.03.15.13.14; Tue, 03 Dec 2019 15:13:27 -0800 (PST) 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=@kernel.org header.s=default header.b=J31A196h; 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 S1728546AbfLCWlZ (ORCPT + 99 others); Tue, 3 Dec 2019 17:41:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:55814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727652AbfLCWlX (ORCPT ); Tue, 3 Dec 2019 17:41:23 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5724820862; Tue, 3 Dec 2019 22:41:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575412882; bh=N3z5o1CiS7er7wCtOiJuMZ6Yhejg/AUtOZVEhphwnGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J31A196hIdEkfGwO3kJIv0ecLAF2Ei1VL6jFm2g9CvyPFDKSi+ft63sVuwGQ9FGgD ZMD3BY5/zlxWHnbavshXgwSTNXCAMhlxn4p2SIROApW+PdoD7+ewO2qyXrB5xIhmYH 6Y2Oh4UlQTDjPpGsZiBh2cGB7NOw+vTRZhvDZdRU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.3 054/135] can: rx-offload: can_rx_offload_offload_one(): do not increase the skb_queue beyond skb_queue_len_max Date: Tue, 3 Dec 2019 23:34:54 +0100 Message-Id: <20191203213020.278645264@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191203213005.828543156@linuxfoundation.org> References: <20191203213005.828543156@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Kleine-Budde [ Upstream commit a2dc3f5e1022a5ede8af9ab89a144f1e69db8636 ] The skb_queue is a linked list, holding the skb to be processed in the next NAPI call. Without this patch, the queue length in can_rx_offload_offload_one() is limited to skb_queue_len_max + 1. As the skb_queue is a linked list, no array or other resources are accessed out-of-bound, however this behaviour is counterintuitive. This patch limits the rx-offload skb_queue length to skb_queue_len_max. Fixes: d254586c3453 ("can: rx-offload: Add support for HW fifo based irq offloading") Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- drivers/net/can/rx-offload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c index d1c8634099450..bdc27481b57f9 100644 --- a/drivers/net/can/rx-offload.c +++ b/drivers/net/can/rx-offload.c @@ -115,7 +115,7 @@ static struct sk_buff *can_rx_offload_offload_one(struct can_rx_offload *offload int ret; /* If queue is full or skb not available, read to discard mailbox */ - if (likely(skb_queue_len(&offload->skb_queue) <= + if (likely(skb_queue_len(&offload->skb_queue) < offload->skb_queue_len_max)) skb = alloc_can_skb(offload->dev, &cf); -- 2.20.1