Received: by 10.223.185.111 with SMTP id b44csp917143wrg; Fri, 9 Mar 2018 16:48:57 -0800 (PST) X-Google-Smtp-Source: AG47ELvVTv55Xulkt/1Lx95+MBhvZ1/RkJcA8m1oNHpsjf5LFT3oN+On1YknfL8T8/OZ4ZbL0+x/ X-Received: by 10.99.0.207 with SMTP id 198mr326924pga.364.1520642937662; Fri, 09 Mar 2018 16:48:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520642937; cv=none; d=google.com; s=arc-20160816; b=CzcOWmGxqqtssfsLzrVtdvha/G5cWxZK8TyeASNTLEK4M/GBbAB0oKJQ+yU5LsoLEX UhwYDQ+CW3ctaxVPFQ1W/evpo7xxwht61N+GrO5G+xvALea4dp2GmwtdRszF0cFVQq0d J/AVDFQbQ+fl/O8iMISedxfdirKmuyeS67aFkOKLtmH1tsrqfdgcBvQAFGGaSIbb8UUq dm+r9FK9NcaYqsrl+lV0se9YTf1NJt9AF2Iz26/u6A5fKt/O4ejtfEXVeSIfe/C0yLk0 7LA5UazAOKaRPV6fR/6Esed1MqMXLtkcSb7kGT76Ju/2F+kDOtx16NIXgXkdhlzPvvhd BGLg== 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=nuyAestoZpZgVQheSAUCjU/XYWrWvjBxWzelSddtmog=; b=UUcZ54f+2PlrXoH4Em/Qx4xtQait06YVNBJBS3GgtB3CXy4eH/LMKlo3w/L0pKMSsA DiImS+ch3yBdR/fFmnnbPXyK9kIvmf02BGZAykmTDdopcWqW8lpJbY783d2DMBUmkRzy Lddtuyq5J5bWhVcExQwfp2lPE9wW0rPKXx6Q7EpnP+cJUgS5UXl/2FB220IIuZqvnmVz kZk0sSvRNjJ3Nrt+56BanQ5DK1B785XXoPgAwVZXiRZHusjUH39hZiA4+o1yzdKvYalC ZkjcT6+OmXNad6JD/4PYWQe5dutkhNrErdy4x3NodI3hO98W/KMpPheQrEXUAQprGZxH QkMQ== 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 z96-v6si1774804plh.35.2018.03.09.16.48.43; Fri, 09 Mar 2018 16:48:57 -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 S933237AbeCJAri (ORCPT + 99 others); Fri, 9 Mar 2018 19:47:38 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38926 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933187AbeCJAT4 (ORCPT ); Fri, 9 Mar 2018 19:19:56 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A7092F99; Sat, 10 Mar 2018 00:19:55 +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.4 18/36] bridge: check brport attr show in brport_show Date: Fri, 9 Mar 2018 16:18:34 -0800 Message-Id: <20180310001808.337030039@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001807.213987241@linuxfoundation.org> References: <20180310001807.213987241@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.4-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 @@ -229,6 +229,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); }