Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1676773pxu; Sun, 6 Dec 2020 03:43:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJx28e7q9WtoNggqbZ7LMrRqw065WgTm81DdC/wbKrf0EYrMyl/3RZmQ2RE5cyElSMwe9qWp X-Received: by 2002:a17:906:b79a:: with SMTP id dt26mr14320324ejb.337.1607255001615; Sun, 06 Dec 2020 03:43:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607255001; cv=none; d=google.com; s=arc-20160816; b=1KgGI7jILo5PMbHxJ8wc5BGUswBl4lzFbey5akS4bfEGfntiutfsQHTwIuGabdpmsT yt2UDPO/fhAHua92h0+MitPgILyy6oCYzDwfYhQcqRMOUsRkcfpeWKMVMZA+Q0HZknQv K1lXkgf25piERHQfdgxJuwwJsZhP/trG5TE5z8LG/iMedoDEo8Id2wIjINkYaQzPs5ny PIh6l9PdCDCOpdrMjxf4Ob7pli1fFOdsxY7ZWV+5Ntqj7FSGHKUNVM7mBDQADGd2qzfP bqyNW42/Gf5i6Hh6Lm09xfXe8mBqn9swxL5jl+7/xNF2f2lv6YlDTsfTRkobnVBo9NbQ 6jww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=tSJrqfn8nw6php3dAcaa/BUORmAp5lpAjFtp0oT6hrc=; b=GQdhxi73PV77GAaNJNLAnpqskZxJyJSsax2s+LPHOuq863aiL3glf9sDDlUmn2iYhW oAV987Uy/9f8ABV9PWzukcrrVZeFS4DyZFxoYvcAiDwTsSQKNB7l9Srcpevn8BvwOjES i9v/Zq/GLzAn1u4qKf+lpdwGVDHEFivnEHSivLJAC6KOKGWnaN58djYVyodKdEGCbJ2E iYmqyE4QRzwHerC/qfhYrNcw6LP6uIbsvAHd7aNxG9dFbCfWUo7vJFwgQ0LQxBExcEai iC9VW9y2rEektF7WeubUYC2XrM49a1/6uxhUsISdFz5+qnWhNVUsIIwHT9nWgTdbXeR0 p68g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n6si6548704edb.575.2020.12.06.03.42.59; Sun, 06 Dec 2020 03:43:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728236AbgLFLjx (ORCPT + 99 others); Sun, 6 Dec 2020 06:39:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:35898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727425AbgLFLjl (ORCPT ); Sun, 6 Dec 2020 06:39:41 -0500 From: Greg Kroah-Hartman Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakub Kicinski , syzbot+a1c743815982d9496393@syzkaller.appspotmail.com, Anmol Karn Subject: [PATCH 4.19 04/32] rose: Fix Null pointer dereference in rose_send_frame() Date: Sun, 6 Dec 2020 12:17:04 +0100 Message-Id: <20201206111555.995574474@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201206111555.787862631@linuxfoundation.org> References: <20201206111555.787862631@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anmol Karn [ Upstream commit 3b3fd068c56e3fbea30090859216a368398e39bf ] rose_send_frame() dereferences `neigh->dev` when called from rose_transmit_clear_request(), and the first occurrence of the `neigh` is in rose_loopback_timer() as `rose_loopback_neigh`, and it is initialized in rose_add_loopback_neigh() as NULL. i.e when `rose_loopback_neigh` used in rose_loopback_timer() its `->dev` was still NULL and rose_loopback_timer() was calling rose_rx_call_request() without checking for NULL. - net/rose/rose_link.c This bug seems to get triggered in this line: rose_call = (ax25_address *)neigh->dev->dev_addr; Fix it by adding NULL checking for `rose_loopback_neigh->dev` in rose_loopback_timer(). Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Suggested-by: Jakub Kicinski Reported-by: syzbot+a1c743815982d9496393@syzkaller.appspotmail.com Tested-by: syzbot+a1c743815982d9496393@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?id=9d2a7ca8c7f2e4b682c97578dfa3f236258300b3 Signed-off-by: Anmol Karn Link: https://lore.kernel.org/r/20201119191043.28813-1-anmol.karan123@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/rose/rose_loopback.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) --- a/net/rose/rose_loopback.c +++ b/net/rose/rose_loopback.c @@ -99,10 +99,19 @@ static void rose_loopback_timer(struct t } if (frametype == ROSE_CALL_REQUEST) { - if ((dev = rose_dev_get(dest)) != NULL) { - if (rose_rx_call_request(skb, dev, rose_loopback_neigh, lci_o) == 0) - kfree_skb(skb); - } else { + if (!rose_loopback_neigh->dev) { + kfree_skb(skb); + continue; + } + + dev = rose_dev_get(dest); + if (!dev) { + kfree_skb(skb); + continue; + } + + if (rose_rx_call_request(skb, dev, rose_loopback_neigh, lci_o) == 0) { + dev_put(dev); kfree_skb(skb); } } else {