Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp3963274pjo; Tue, 3 Mar 2020 10:10:19 -0800 (PST) X-Google-Smtp-Source: ADFU+vseiJzd4/e8lEGLPk5yyVIj51OOpJ4XgTBTwvCO5nw6y4otXSAs8RXXJpEQlYGrfCti8gks X-Received: by 2002:aca:b9d6:: with SMTP id j205mr3341521oif.179.1583259019379; Tue, 03 Mar 2020 10:10:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583259019; cv=none; d=google.com; s=arc-20160816; b=ziDhIYXYE/X1XA8jEhL9zw87BniG4USPsG4jZYO+92kFl+gNTQp8UZZcHLFNwLh5Hd lUofubKmXeioAcZqKb3iGbioI5wfhOY4myIW8eYUUABkCmsuz6XejhVa1PDHHRGivq6B PSQ/5aU3Y0sZfpjTy0ZJtlfE3IzX3dtca4vRC1n+hTTq2SGleItRbTYMePElJ/ga6Dfd +ftMpZpqZs6VcgLJQwCi/+n/20SalcMdWWZCUnY1tJdvXvZi2fxbXVyZW39nBhM+TRaG xpQC02fvaqNZCXHtmFBqj/nAU8WkRrXX1lqTmvb6nHsfgB745YmcOQhPjnfR6vTSgDu1 WDfw== 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=c2GQoQtdx+Kg/WMisKQYsq6kGip1AXtUM7/sgHcSWgI=; b=bACPM9Gyocv52qtAVAJRNwiu8RH2+uc+W8j3lysJAdZPQ7zgCee5k3EDz7vU31UNHK ouYuvLCWHif3nUvG6cLQW7aUNZ9M8TLFnJmAVN9BEtyIvR0j/xr0yTp1fgTN3NKcF68v y7DAglTPWrOmFfdKUdzrw/ixJ6ZkYay216jn3/vTCjWKbd2hFrYFlBq9ATOKbUOMwjV+ yMCHMLIjf6wa1JzuWSiN5jl3S5Y8FacYhJLMXo2RpDoId6NtU15svQDCS1reUmfppZMq nWvNNnSaCzLhHkX6iR3KIEDXh5lVWI+CP6UN1/uou2LiSAwP6g44aC/okjTvZv6lMszP 4efg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=THojV6H1; 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 t3si8518480oig.25.2020.03.03.10.10.07; Tue, 03 Mar 2020 10:10:19 -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=THojV6H1; 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 S1732168AbgCCRwc (ORCPT + 99 others); Tue, 3 Mar 2020 12:52:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:60880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731400AbgCCRw3 (ORCPT ); Tue, 3 Mar 2020 12:52:29 -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 5867A20728; Tue, 3 Mar 2020 17:52:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583257948; bh=c21TfbwGAmY04joA/5Jg2fRADSeF3iapOKvmXyOEypY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=THojV6H1QZ//0SGx+HqZLKqLy6TocuvfEVNhpsK1kemRx2/eoXG8WwKp80gCC+2q0 5AMBygOf8NF5k8DiMwOLLcp/4hqD7Q3fi7acsUH/b1abQeukSu2hDs0sT1V1kGbcL+ GI0/TLUaU4cgHXl3jfiBCd/UPIql+Xbccucm1q4w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Horatiu Vultur , Alexandre Belloni , "David S. Miller" Subject: [PATCH 5.4 006/152] net: mscc: fix in frame extraction Date: Tue, 3 Mar 2020 18:41:44 +0100 Message-Id: <20200303174303.216257661@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200303174302.523080016@linuxfoundation.org> References: <20200303174302.523080016@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: Horatiu Vultur [ Upstream commit a81541041ceb55bcec9a8bb8ad3482263f0a205a ] Each extracted frame on Ocelot has an IFH. The frame and IFH are extracted by reading chuncks of 4 bytes from a register. In case the IFH and frames were read corretly it would try to read the next frame. In case there are no more frames in the queue, it checks if there were any previous errors and in that case clear the queue. But this check will always succeed also when there are no errors. Because when extracting the IFH the error is checked against 4(number of bytes read) and then the error is set only if the extraction of the frame failed. So in a happy case where there are no errors the err variable is still 4. So it could be a case where after the check that there are no more frames in the queue, a frame will arrive in the queue but because the error is not reseted, it would try to flush the queue. So the frame will be lost. The fix consist in resetting the error after reading the IFH. Signed-off-by: Horatiu Vultur Acked-by: Alexandre Belloni Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mscc/ocelot_board.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/net/ethernet/mscc/ocelot_board.c +++ b/drivers/net/ethernet/mscc/ocelot_board.c @@ -112,6 +112,14 @@ static irqreturn_t ocelot_xtr_irq_handle if (err != 4) break; + /* At this point the IFH was read correctly, so it is safe to + * presume that there is no error. The err needs to be reset + * otherwise a frame could come in CPU queue between the while + * condition and the check for error later on. And in that case + * the new frame is just removed and not processed. + */ + err = 0; + ocelot_parse_ifh(ifh, &info); dev = ocelot->ports[info.port]->dev;