Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2239364imm; Thu, 7 Jun 2018 07:32:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL23ZhhK9tr67ah/eRVitV9JIfM9IeMpFMgJCJjrkwVJMmdU+qsLN960xzM9nRZ16HgIoyf X-Received: by 2002:a63:af50:: with SMTP id s16-v6mr1827827pgo.263.1528381973997; Thu, 07 Jun 2018 07:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528381973; cv=none; d=google.com; s=arc-20160816; b=rPo69nRASRBPJlFwF4GjlGJWuAsyshK3A9cnBMZ6/4HNo/vbrC2J1g57fzH9WlKJ1T 6J1V6fv7m3vrPwLxOY81aJAYZXzxFvnhQ6bso/38ctvgl6ybW4PMid+NU2KD4stujKpL XOOAAf4di+T4z8L2bf3F/A46zDTWoGTwhTieBNquKbbr+IMz2HwbRlzBh517t6zUa/I7 4zb5y740rf0pYmMfZFHfFFCg+lZkl+zTX33pbt8xA39CB4Jmt7/OYw5mSZGhd0Z00vY8 NPKYmDOOIjBlUO1NfwZ4WQetoOy+mvwJAtX1WGzTwZ+7QPEqAo/GtHjCNKW+POikFwDg OOvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=3JoP24Z1gcYgKnGRsiAYpkVcVXWxG8HKH0mWrlXouI4=; b=IxIvqpuc9HdAHAl/k3cZK6zHQQpNhvtOH/Gqlm9q0AR9UcjEPSqFK2XlEdu9rHCCOX mmCHKmr1OK3ex6SDMUA7Djaf4stL2KomN5K3RG/vFdjQ69+qrs18v3IKMXj/PqBsFa0P Sl/EXSTMj3P80gf9T8n9RnfVrmE9JC9jnnIUqjsOQjL8k9BXN4SKxqdMeG6W9Awtpgyy xHgR5BXyXkotXY+Arj0AJhxlsihLIZb/OBdP3dtyqnY2y6D049CV+ovMevc9AlgirBqW MbLKjVZgEriLfIExko5HFVnRn/G7O9qQD6KZxvz6ik5BJlZn95uJCPuOEkRiZ2kZobYw JeuQ== 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 z8-v6si53599512plk.539.2018.06.07.07.32.39; Thu, 07 Jun 2018 07:32:53 -0700 (PDT) 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 S933755AbeFGOaW (ORCPT + 99 others); Thu, 7 Jun 2018 10:30:22 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39416 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933063AbeFGOJK (ORCPT ); Thu, 7 Jun 2018 10:09:10 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbA-0005Zp-K2; Thu, 07 Jun 2018 15:09:08 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb7-00032o-5s; Thu, 07 Jun 2018 15:09:05 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Xin Long" , "Xiong Zhou" , "David S. Miller" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 227/410] bridge: check brport attr show in brport_show In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Xin Long commit 1b12580af1d0677c3c3a19e35bfe5d59b03f737f upstream. 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: Ben Hutchings --- 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 @@ -225,6 +225,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); }