From patchwork Fri May 6 09:43:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 16100 X-Patchwork-Delegate: mareklindner@neomailbox.ch Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 8755081A64; Fri, 6 May 2016 11:43:46 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=narfation.org Authentication-Results: open-mesh.org; dkim=fail reason="verification failed; unprotected key" header.d=narfation.org header.i=@narfation.org header.b=SZV++9a1; dkim-adsp=fail (unprotected policy); dkim-atps=neutral Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=79.140.41.39; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=pass header.from=narfation.org Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id B356881990 for ; Fri, 6 May 2016 11:43:44 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p200300C593C4FDFD0000000000002E16.dip0.t-ipconnect.de [IPv6:2003:c5:93c4:fdfd::2e16]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 0D6ED1C8001; Fri, 6 May 2016 11:43:43 +0200 (CEST) Authentication-Results: v3-1039.vlinux.de; dmarc=none header.from=narfation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1462527824; bh=G2pIcYDeSbLlHapKQNPhu34jybHEapD4xZA6+EOLr4k=; h=From:To:Cc:Subject:Date:From; b=SZV++9a1G9r02hIfliVcLl8HAzFQJhm9Jl4Q7ray2my+x9Y1XwDv2nnb0R3iEicJA oEqcZJ67dZqRgx5PS0jlm82WdjjDFTWrpmtEPRFp5eWthLTtfZVM14w/u9HhRgcfGF UGBZfn/entRQwqrjeYNn0R+ylYiatilhTIBxOp90= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Fri, 6 May 2016 11:43:38 +0200 Message-Id: <1462527819-11907-1-git-send-email-sven@narfation.org> X-Mailer: git-send-email 2.8.1 Subject: [B.A.T.M.A.N.] [PATCH v2 1/2] batman-adv: Avoid nullptr derefence in batadv_v_neigh_is_sob X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" batadv_neigh_ifinfo_get can return NULL when it cannot find (even when only temporarily) anymore the neigh_ifinfo in the list neigh->ifinfo_list. This has to be checked to avoid kernel Oopses when the ifinfo is dereferenced. This a situation which isn't expected but is already handled by functions like batadv_v_neigh_cmp. The same kind of warning is therefore used before the function returns without dereferencing the pointers. Fixes: b05bbab5e1fc ("batman-adv: B.A.T.M.A.N. V - implement neighbor comparison API calls") Signed-off-by: Sven Eckelmann --- v2: Add patch to reduce the reference counter of these functions net/batman-adv/bat_v.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c index 927d405..f271ae8 100644 --- a/net/batman-adv/bat_v.c +++ b/net/batman-adv/bat_v.c @@ -286,6 +286,9 @@ static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1, ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1); ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2); + if (WARN_ON(!ifinfo1 || !ifinfo2)) + return false; + threshold = ifinfo1->bat_v.throughput / 4; threshold = ifinfo1->bat_v.throughput - threshold;