Received: by 10.223.185.111 with SMTP id b44csp910619wrg; Fri, 9 Mar 2018 16:38:13 -0800 (PST) X-Google-Smtp-Source: AG47ELscpr6iU5nGdYSAsfXcFRq3yXxfDoSjJJZQbmOqOBIAyWGR0hBaSaRMP9m85AZvVK8mVllF X-Received: by 10.99.159.10 with SMTP id g10mr276077pge.407.1520642293147; Fri, 09 Mar 2018 16:38:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520642293; cv=none; d=google.com; s=arc-20160816; b=Jf23T24AIFilxQLocLnh80H6Rl8V7PhpcFKSVfszxri/vSMhOF3j2qJSDHqRcVnXJw GkjviExSHBSjiWjc+5tYRcZtwtR8qu3hCXvT33JaKDcdhOhnFJjgsfQDm8YncfInnULB zsMQ+ejDqYqinWOoVA6+3nFASaFZaxXgdB79n3GYSBBLtolYjOxw45r1KdiJ4+09ntk0 g9OIPg5UjvrFpHovvOdzOPLb4rgRsxnDJOPm0lH3zhICvamCYgm+vNt9IIo4a186x+HX 49kVPvSN/vaAE9alEPnmxsiLxaccEL0SZsXEBoAB+KyOhsGYE+aQoF+QaqKha8iZqZMl 5j2g== 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=a/tRkKPUy6LvprJ2had3wjgvBGpmzSysWDNuaqiNcG8=; b=DI+OeiCg0vPQL6FkdcKjr/YWWndckLH2aqlxzZFhQNqR07ke8ng4XTB4Hm+L1GHRR+ aXXmgYllQvKgUb3lSSNjJKAjcVaqGkyaVxUK7xUPWwwJJM3ep8bvPasthxLO6uiIputB DRPuQJnJtJhGVbivy7Hq9jDvN9v9mwsEGw8D5UuMmP/1cAdIkDZR9Pk+IDFEJEG0wuKu 5devEAZfZgCYGzWRiOfddEriV7umPVlxnf/dkXZ5MZIwFuU2Z13Ii5XxOsS+UGVWbwPu cmsBeUjZmKwbLZpVGc2957X6TYFLcXvr//1S96Z0/p7k7uG0J5Roq0obcY3Q17vliwQQ +9nA== 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 y9si1459087pgp.800.2018.03.09.16.37.58; Fri, 09 Mar 2018 16:38:13 -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 S933763AbeCJAVx (ORCPT + 99 others); Fri, 9 Mar 2018 19:21:53 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:39756 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932369AbeCJAVr (ORCPT ); Fri, 9 Mar 2018 19:21:47 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 2C7811167; Sat, 10 Mar 2018 00:21:47 +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.9 33/65] bridge: check brport attr show in brport_show Date: Fri, 9 Mar 2018 16:18:33 -0800 Message-Id: <20180310001827.580920633@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001824.927996722@linuxfoundation.org> References: <20180310001824.927996722@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.9-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 @@ -230,6 +230,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); }