Received: by 10.223.185.116 with SMTP id b49csp5483300wrg; Wed, 7 Mar 2018 12:33:06 -0800 (PST) X-Google-Smtp-Source: AG47ELvgVERME6lEssRQBs6gMH6vBmzhrTfG2g2hdeW0aRnTIID+bEXuRPzIVonfMWBDCbvyDXQH X-Received: by 10.99.173.71 with SMTP id y7mr18900373pgo.432.1520454786258; Wed, 07 Mar 2018 12:33:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520454786; cv=none; d=google.com; s=arc-20160816; b=LIedVq/YeSZFuW0BHD950O7mtDa7WylI2zx/KI/tWrIDEHFpCCrLrwvt0boltC05OF fdpF1CeeUsr8rJkHhHjJhXAKMmcmfkWPSpZK9u7thCDEskSCopuiALbTRPFeFMEeDDTH rIbNmh/svc06SLJGb3/86RgXnDT1LlKQEKsVLWdZjYHO5OXaeeobimUqKTjG6wPAucSP FA6we+TfpI3bFI5AFqsXa/C4WYgE9R7vOM1ge0roKn56OYc2MeqVrZADQaX6HQ4NSTZ2 HRDKwd/cc3RyljIY46hyEj5CF5IfRQQVNsLT9Ww8QTjYo4oeUA/uqervph7o1UetbeOq AMAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=uU1Ajy3k9uLWnUK23EGbSk0FZbHSHjKE2EjdDvNFRaU=; b=m6Duh27yh0lMM8IGAUBzChSnxGedc3LWM7Ql6CTq4/KnKgH6DzXkljGd9OdApGNVa9 BPsVAU+AtNRo3/ThtX0Z5roBSgl0SIosM5zDdI/WraLW+6olonoR2lNN1CwMezZ0wDNP eWymwAZIFJIJpdP6ozMLJ+g+ImDNWL/Ou/OLvsynh+09SW69LuTKJlAxu7qr6Ptfhe8n fdrdJvnP/ErIE+sBhvesamkjcnn8O9aA9xKtlgpZ+Iv2t4ZXjPFKDr+waIOMR/Q4UjLM AQVJnt3d5Ow0YRmGB2OksW0tiwh6EYIitBBaiVO/cAHEFdOP4R8t0+7sbXN+dtIIM6CE NjuQ== ARC-Authentication-Results: i=1; mx.google.com; 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 bd7-v6si660612plb.474.2018.03.07.12.32.51; Wed, 07 Mar 2018 12:33:06 -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; 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 S964869AbeCGUcF (ORCPT + 99 others); Wed, 7 Mar 2018 15:32:05 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:42148 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934866AbeCGTmS (ORCPT ); Wed, 7 Mar 2018 14:42:18 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5F4241084; Wed, 7 Mar 2018 19:42:13 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiong Zhou , Xin Long , "David S. Miller" Subject: [PATCH 4.15 039/122] bridge: check brport attr show in brport_show Date: Wed, 7 Mar 2018 11:37:31 -0800 Message-Id: <20180307191734.729830899@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180307191729.190879024@linuxfoundation.org> References: <20180307191729.190879024@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xin Long [ Upstream commit 1b12580af1d0677c3c3a19e35bfe5d59b03f737f ] Now br_sysfs_if file flush doesn't have attr show. To read it will cause kernel panic after users chmod u+r this file. Xiong found this issue when running the commands: ip link add br0 type bridge ip link add type veth ip link set veth0 master br0 chmod u+r /sys/devices/virtual/net/veth0/brport/flush timeout 3 cat /sys/devices/virtual/net/veth0/brport/flush kernel crashed with NULL a pointer dereference call trace. This patch is to fix it by return -EINVAL when brport_attr->show is null, just the same as the check for brport_attr->store in brport_store(). Fixes: 9cf637473c85 ("bridge: add sysfs hook to flush forwarding table") Reported-by: Xiong Zhou Signed-off-by: Xin Long Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/bridge/br_sysfs_if.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/bridge/br_sysfs_if.c +++ b/net/bridge/br_sysfs_if.c @@ -255,6 +255,9 @@ static ssize_t brport_show(struct kobjec struct brport_attribute *brport_attr = to_brport_attr(attr); struct net_bridge_port *p = to_brport(kobj); + if (!brport_attr->show) + return -EINVAL; + return brport_attr->show(p, buf); }