Received: by 10.223.185.116 with SMTP id b49csp5463449wrg; Wed, 7 Mar 2018 12:11:34 -0800 (PST) X-Google-Smtp-Source: AG47ELtmuSL7x/iwm3RYixF1F3i6hTqbKf3dwRTTIoHHH/LnoAFiNovV3k6eUnhxSDyvum9ojXOm X-Received: by 2002:a17:902:32a2:: with SMTP id z31-v6mr21988578plb.32.1520453494605; Wed, 07 Mar 2018 12:11:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520453494; cv=none; d=google.com; s=arc-20160816; b=ayEHLMZomgdTKSSfBdSTSieYBcIrM7IjaQkBtI52s9elDyQw51JnmsfePp0+9CI4Wx pTk9g6MCxOiIB9x9Q5H+EWVIYj+B5QpypZ+8ss4N5tQihelBUfsOhTcyrGWfKjbvgC2u Vz/m2TU6dCE+0ODED5RMBpUUoEwGKe3kRtHwvEp5PA16abAAkE9z3NYtgHIADhcyP4NZ 3HG6EB7UK4gvQ/pmxHGcfWAN1pD1766GNrpryT4lGIkq84CoAEEwE0eAFuSbCKtB05J0 3mriCAjdqL1NxObAjwFeVavo4ic5JCyQ7byjJOuVECy6RTh9jOM8Ydi5CsWXfD0DQqCl LTXw== 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=2s8TRWxxKauhm8zCI/Xk6KJFW04RrSX1Pp2N10+UkRo=; b=BH/praNvHgrMw24JuB88mr2jZ+6eAlOItsnBL0sXkQKaW4EIpNTYe8JaRLhUteLBBw 5WxDBAek1U89qcrcDxVtOSIGC4rpENVu6Grjzwj7uISaXOkcvzQ2p5Yll9OKetiYTaA/ 9MipCu1cBLgU4+v7TCU+VbDbH5Mkz2X+p0ffjdBKIlm8rYOMvEHD9Tg1aoYyqW0hi7+h tvctVYDhlXOVYdfCEV/tvMB4rAAV8X23ENmZ5TKSWCbfJ0Ai4eoPBG7AMzymIu2i2M3Q lD/qh5w3Y83pL+OCADf1knEsX8jSVoxdRXk/agScCmutqd2YWh+EVrJ8TrjLIOKqEI9X 7TuQ== 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 s72si3555849pgc.818.2018.03.07.12.11.20; Wed, 07 Mar 2018 12:11:34 -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 S965339AbeCGTpd (ORCPT + 99 others); Wed, 7 Mar 2018 14:45:33 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44190 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964820AbeCGTp2 (ORCPT ); Wed, 7 Mar 2018 14:45:28 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 450DDF30; Wed, 7 Mar 2018 19:45:28 +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.14 034/110] bridge: check brport attr show in brport_show Date: Wed, 7 Mar 2018 11:38:17 -0800 Message-Id: <20180307191044.105042038@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180307191039.748351103@linuxfoundation.org> References: <20180307191039.748351103@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.14-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 @@ -235,6 +235,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); }