Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp312781imu; Fri, 25 Jan 2019 02:48:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN6B9YA4S8B25miuBFBI5JNqhf6/yFAOW5g4AvLx5kxthh9+97FdJ4JC9yQ03DG5plgO0vDh X-Received: by 2002:a17:902:a601:: with SMTP id u1mr10439360plq.77.1548413302497; Fri, 25 Jan 2019 02:48:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548413302; cv=none; d=google.com; s=arc-20160816; b=aco1bA/sftPOq+nsAC0p37522nMKMqArz+uKA6Ur9kMZwJXrXMo88kus+lPXeEFZCU buQbxLJwMX3MLUv8oonU8CviVd9Lgixw1lv2CsWLbm25kV9A9yukqgClbsyW6qS49nik xBWpNgbIDEahz+8r+4yQR0pgO6jOko94YmPFB9K8zy3LIbyhCCGpl3VjViOznNzu+YU3 VqX0MfPLUPa42WPtKJHNp5h2QMeBHC+buMRmqA+B3gHDO5tYfALHnAnbtiYDWL1UZl82 sqJK0OELiSqms5eqycrysq4kAWMYHQJUYMZEq6Ht86+A/dAc3Mr18baWrTk4c4oTPyTC t1DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=mQI/+sNPW3cWviJBz4RvXI4WSmKJyJbGpq6y4etWi2Y=; b=A1vc10XT76MuNorYjLhFXyFzq2vHQFoCNlM2ZhMZi2MjSC7fhpdpJBUqnd9+Gqn3kG h4pNmZ0v1o0NUqciYhW9YWit2MOzkThP4Meq3Sew29DLpqtfbrPOuvqiHd6Xu1Tn5Wq4 SxY76VonEvsOMz1jMx/aIc6IBMrMbQh1hXmki1NMR/DL8u57LNdfoXd0PMGwfD4y3LKT zc0XLZEN2EN6sW18q4v9KXOkOlDbjIOwJQo29HFW2rAC1crSPMM0PPvO0K/U7Nlz7hWN LNDnQIt9dkXvV25JQBD31DJ+8SvImRpTIUhfw1JSv5mr/lYrm9QvNLPGpmyAsO242rA7 Aevg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R6fRiCEu; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n18si24856924pfj.30.2019.01.25.02.48.07; Fri, 25 Jan 2019 02:48:22 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R6fRiCEu; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727914AbfAYKqp (ORCPT + 99 others); Fri, 25 Jan 2019 05:46:45 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42154 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbfAYKqp (ORCPT ); Fri, 25 Jan 2019 05:46:45 -0500 Received: by mail-wr1-f67.google.com with SMTP id q18so9746985wrx.9; Fri, 25 Jan 2019 02:46:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mQI/+sNPW3cWviJBz4RvXI4WSmKJyJbGpq6y4etWi2Y=; b=R6fRiCEuCyQwDdzgt9pkpz7iWPI1TjhhMLsrRoPbonYIHYVWgR6uCRYlvhoM+rbbRT M3q/elgkTOO/0brKEt3inLz4VoRCNWhZoErk1fa3VGwAoe+2DkAFFRfl3c1E3MjK/yEC LDo7U4brlqh5tErhSwJfU4AYq9Dh3379H5ZKNyoGL/j8WdfV7MCZzfU9iMK+TqymtLJQ z4CXIF8OC0absicNccaQdDDbMqM+kwcD5AMIwIi+LBODu1UbppGOpvZZkTm3H+37P39X mFKmAoaEnDPiK2zqxzAoaESS8e0F73AuZZ/yeBH/Sh4F+YX0MFDFHQAJ9HUpdu39972q nlqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mQI/+sNPW3cWviJBz4RvXI4WSmKJyJbGpq6y4etWi2Y=; b=rBpV/v51yXr9SYf/xdYgnsb8QD6DO+ym/enfDpeUoaumaBrqzjpDwB9fB8eqwhMSAr zO8NqI7AQBruEXFTyfyyRPz4g3NydYqfM05VhqkB9kVD+K+fzPVW/xncin4LMkwZJ33b 6A6cItpw9G0gSWcRFduzCcYy/j4608UWUKuQzEhcApIhycof5pkbZR8RRKl2sGPCGGor fkQOLOYjOpmfBbM3Vk8GaIichdIXmk2+uA7k4SpOzDFqaJ1CrCktr+r7xad91vCvDF4X fjYlQP8bRuZU9TfedfOtn2o6CtrCoyFmYkfiVE+TAf8smWciwn3hotgbZ1bRZkoOOy4m Wbsw== X-Gm-Message-State: AJcUukeYKzyI0UHVOga2/aDrImUJRryxGGXpLmt6eLTB7hOuKbgltZnB 7lp04RWFCAFD3ovLh5/0Jbw= X-Received: by 2002:a5d:6549:: with SMTP id z9mr10629625wrv.116.1548413203577; Fri, 25 Jan 2019 02:46:43 -0800 (PST) Received: from dvyukov-desk.muc.corp.google.com ([2a00:79e0:15:13:4c1a:d2d1:436c:979b]) by smtp.gmail.com with ESMTPSA id 143sm135792993wml.14.2019.01.25.02.46.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Jan 2019 02:46:42 -0800 (PST) From: Dmitry Vyukov To: f6bvp@free.fr, davem@davemloft.net, linux-hams@vger.kernel.org, netdev@vger.kernel.org Cc: Dmitry Vyukov , syzbot+1a2c456a1ea08fa5b5f7@syzkaller.appspotmail.com, Ralf Baechle , linux-kernel@vger.kernel.org Subject: [PATCH] net/rose: fix NULL ax25_cb kernel panic Date: Fri, 25 Jan 2019 11:46:40 +0100 Message-Id: <20190125104640.253862-1-dvyukov@gmail.com> X-Mailer: git-send-email 2.20.1.495.gaa96b0ce6b-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bernard Pidoux When an internally generated frame is handled by rose_xmit(), rose_route_frame() is called: if (!rose_route_frame(skb, NULL)) { dev_kfree_skb(skb); stats->tx_errors++; return NETDEV_TX_OK; } We have the same code sequence in Net/Rom where an internally generated frame is handled by nr_xmit() calling nr_route_frame(skb, NULL). However, in this function NULL argument is tested while it is not in rose_route_frame(). Then kernel panic occurs later on when calling ax25cmp() with a NULL ax25_cb argument as reported many times and recently with syzbot. We need to test if ax25 is NULL before using it. Testing: Built kernel with CONFIG_ROSE=y. Signed-off-by: Bernard Pidoux Acked-by: Dmitry Vyukov Reported-by: syzbot+1a2c456a1ea08fa5b5f7@syzkaller.appspotmail.com Cc: "David S. Miller" Cc: Ralf Baechle Cc: Bernard Pidoux Cc: linux-hams@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- net/rose/rose_route.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c index 77e9f85a2c92..f2ff21d7df08 100644 --- a/net/rose/rose_route.c +++ b/net/rose/rose_route.c @@ -850,6 +850,7 @@ void rose_link_device_down(struct net_device *dev) /* * Route a frame to an appropriate AX.25 connection. + * A NULL ax25_cb indicates an internally generated frame. */ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25) { @@ -867,6 +868,10 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25) if (skb->len < ROSE_MIN_LEN) return res; + + if (!ax25) + return rose_loopback_queue(skb, NULL); + frametype = skb->data[2]; lci = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF); if (frametype == ROSE_CALL_REQUEST && -- 2.20.1.495.gaa96b0ce6b-goog