From patchwork Tue Jul 4 11:44:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 106946 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp897749qge; Tue, 4 Jul 2017 04:44:42 -0700 (PDT) X-Received: by 10.98.147.19 with SMTP id b19mr14850728pfe.145.1499168682740; Tue, 04 Jul 2017 04:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499168682; cv=none; d=google.com; s=arc-20160816; b=mt/rimzHaG3n1h+sC9JK26aLaob4gDkdaJ4jP7CnMq+ikDDmcZZ0h2OUEyHAPQX9xg 16v7BL7UXNfTmNqZu3bbXvLVQcTJsU93V84CPH/bHY9okb/8ti2lmRpC8uZdR1KALf1L WDo7D+ZoWtX+pqbiesJE+ziQumScOLXnoConwFf/5kkDavgyWGbatvV1+kSIxVela86Q QoFYloFi64nGVuiqmAKkK9xh+znV4TzTrhYOv92tPwKkd7dXYFSFDZ10m5n0uWKkAr33 8ReBBom0+j44896LORUoNBQHJA25SZzUpJC6nOJZevFnYXARzWYYJTDOzWi45/rpDlfB yctw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=PJLSpsO8fwCL6ypS0E99+/SHl2JItQcRvQmx2mM0Eic=; b=dXPJ5Tv4wap+TpDL0OasmFLLdavWEgbbU9BdAKa6zqMJ2yJKYPjC00VljFSV/2Qlu0 PAYZnUA6aJ7yAfEYFXGpWqV/UO5qXC+tjafac38aOwXJvbamFA2vro/kNwNdBmWJobTJ k+DPgDIBxSbhK1td6qgHK109ZhxrFBtR/PepP9V10FSU0HZcbkCpyifgFbFrpsMp6bIM dV6/Wzt5dDOHvo8K26JvRFTDlwmG9WBRz0R3CL8TJdsJzhDADP0vA/zS44VqkeoE8xsO LNrfXMz+MUvbunsFJ+kKaJPGIKCHJAi+VKV8QV34C26gmIbcjoV/UDz7QW8i6V3Ir45d Y8Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=WF3Snln6; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x10si14416295pfi.192.2017.07.04.04.44.42; Tue, 04 Jul 2017 04:44:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.b=WF3Snln6; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752067AbdGDLom (ORCPT + 6 others); Tue, 4 Jul 2017 07:44:42 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:34216 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752040AbdGDLol (ORCPT ); Tue, 4 Jul 2017 07:44:41 -0400 Received: by mail-pf0-f171.google.com with SMTP id q85so951045pfq.1 for ; Tue, 04 Jul 2017 04:44:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PJLSpsO8fwCL6ypS0E99+/SHl2JItQcRvQmx2mM0Eic=; b=WF3Snln6FeIianh2+KX8F4LOIZvsRym5UYb7MgTm0PJxkmQOTcn7sSsBoRVK/KS8Me qVkhLkUsWP4WMFQt77a+u8Guckf/NSMImSrRzsIJwvmtRYqRvjjN0gMO8wPaCOKFJsWY QvGcMtOuBx/Emqt1ELRhNOh8egUs/mxbeTAGU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PJLSpsO8fwCL6ypS0E99+/SHl2JItQcRvQmx2mM0Eic=; b=Mg9TkhY4GSTKBq0t+I7LMxo7GO0TEDHU8s04fmuX1Zfo0iWZNoo0X36wXgUuQuucmb O82IVQv++ybyRA1FfGgR9ZaUttXshjFOULAT2xi13wu68eS7klc5RofCSzDw12FlLsXG 5lCzFLhM1Uu5AHDD11ogcrUPlW8h7s8hRAnzR+fL9gM3ayoDIiWQh4vW0KuuHUR2uoR/ yjsukhzrCSKiH7zOGFWyKce2+KNq6C7qpHgbjmYZfuYd9aNq1E34YUF0YsCWSmhXqnq9 q8CDZ7xt5xXahqYiIXYQ8G0KSgOuD9c41dYFO2dYng7kk7zC2Bs/+vCxeO5mRjb51H1W tdIg== X-Gm-Message-State: AIVw111m1pzdLZpUx02JMjSLuPC11nP7kZgdIEWkdNupxNKeLB1tONYh CgcrA+Ki+L1DaqX5 X-Received: by 10.98.43.80 with SMTP id r77mr14741429pfr.92.1499168680738; Tue, 04 Jul 2017 04:44:40 -0700 (PDT) Received: from localhost.localdomain ([106.51.234.165]) by smtp.gmail.com with ESMTPSA id t83sm39782750pfg.91.2017.07.04.04.44.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Jul 2017 04:44:39 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Felix Fietkau , "David S . Miller" Subject: [PATCH for-3.18 2/5] bgmac: add check for oversized packets Date: Tue, 4 Jul 2017 17:14:21 +0530 Message-Id: <1499168664-25980-3-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499168664-25980-1-git-send-email-amit.pundir@linaro.org> References: <1499168664-25980-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Felix Fietkau commit 6a6c708469c9e10fd87adcc3abff164270538d62 upstream. In very rare cases, the MAC can catch an internal buffer that is bigger than it's supposed to be. Instead of crashing the kernel, simply pass the buffer back to the hardware Signed-off-by: Felix Fietkau Signed-off-by: David S. Miller Signed-off-by: Amit Pundir --- drivers/net/ethernet/broadcom/bgmac.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c index 7f34d91acdb9..54a7da860a2d 100644 --- a/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c @@ -373,6 +373,13 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, break; } + if (len > BGMAC_RX_ALLOC_SIZE) { + bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n", + ring->start); + put_page(virt_to_head_page(buf)); + break; + } + /* Omit CRC. */ len -= ETH_FCS_LEN;