Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3646338ima; Mon, 4 Feb 2019 02:44:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IaXiTAQNoZRDMbH+PFNiHzeh/Eim6Cg8qAgYRMwA9AsL/v8zNbDyJ5nJ8Xy2RUPQ9x3nLmh X-Received: by 2002:a65:4142:: with SMTP id x2mr12145909pgp.356.1549277098021; Mon, 04 Feb 2019 02:44:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549277097; cv=none; d=google.com; s=arc-20160816; b=EYQgY4uMJ7abiizvHwdihoVwj9aou5eGM2ccrPg8HSeg4q4oHJ0g9zroJn1zJuywXS 99SBqdjqKBDAz4DZnZS3do1u1ooLU4wc/lbVBRqn953rCvI1TG6CZjIp4izQ2oKy/Ufb UHdzOpsBThBbE2YiI3ir+OGGQNGjv6pcm5ne9CcdKUqqQlR0+a6HrUoevdFGv6BR6mnf bNFL3LIYqwkWdYl0potxPPOlBGWpu0ghbSZYpaPYpG2uqH5OYp2rNAjJC80EH0OdvIFT w4D4sq0MH64i3DgxfOrwErUqSCYGqnjLji7X2D3L3k6hACgcDcQ0cLlFOpGfN7sgdtpA tdZg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lVgX5fbYVSn3jr6qok3eJiTtyNjBGj4fqu3TAluhp00=; b=YEupC9SjgmlIn/wje4AICeZf1URrqajoo4USHW+OiFZDIr5Fgzv6NU+Abe/iEIl6Eq w9egGesO/Sd5I+paMpQ6nQZeDbgy41pEn7O+0KeT9lw7+sAl1dqtW97/LxaA2/iJyKwe qf+U3DFq/S49L/NJCavpa4tMj1CAvbGKvLsR1VA0UiDYkDb8QQgoaTWr5nLzHmcTLjiw 4J/78EBXgatMhs0KNh/6KdfxzkG1vI7KpSUZzelHMXsF1t13wkMNBVkNeH0busKc+bQG yBWe9aJK8yJ/i2XB83MMU4U0eemp6FJyzTvnpBJwstvxKemoS015GgAcqdZLJ4CIb6jc zkLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vFdwiZB7; 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 h3si14246442pgi.391.2019.02.04.02.44.41; Mon, 04 Feb 2019 02:44: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; dkim=pass header.i=@kernel.org header.s=default header.b=vFdwiZB7; 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 S1730832AbfBDKnp (ORCPT + 99 others); Mon, 4 Feb 2019 05:43:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:41516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729957AbfBDKnn (ORCPT ); Mon, 4 Feb 2019 05:43:43 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1115C2070C; Mon, 4 Feb 2019 10:43:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549277022; bh=SkkHZFh0kIQyjBHKzBGSitboX1eLfOM3T4w6Q0mNnZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vFdwiZB7p+NpdpSkbQBRet/KIGvilxu2nB5nWSMJfakkG7BYqyF/Rkm1l/uFIej8s VecoDIxijai1d5Vu6xaM5SFGacmTnHfEA9IwzMYTEX0hDZol5kniPHWhwlcaF7zCi9 TBkox/5v8DeggBiPQ27DpdnGx54+pkHo50GdV5a8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bernard Pidoux , Dmitry Vyukov , syzbot+1a2c456a1ea08fa5b5f7@syzkaller.appspotmail.com, "David S. Miller" , Ralf Baechle , linux-hams@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 4.9 07/30] net/rose: fix NULL ax25_cb kernel panic Date: Mon, 4 Feb 2019 11:36:45 +0100 Message-Id: <20190204103606.690016674@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204103605.271746870@linuxfoundation.org> References: <20190204103605.271746870@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bernard Pidoux [ Upstream commit b0cf029234f9b18e10703ba5147f0389c382bccc ] 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/rose/rose_route.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/net/rose/rose_route.c +++ b/net/rose/rose_route.c @@ -848,6 +848,7 @@ void rose_link_device_down(struct net_de /* * 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) { @@ -865,6 +866,10 @@ int rose_route_frame(struct sk_buff *skb 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 &&