Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1679098pxu; Sun, 6 Dec 2020 03:49:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJylRLW8+dQYT0TrZb/r8mD3T7l9UYc74rhPXRrvolKRnktyUeO5rFh9iuTSxLtnFpIWSO8B X-Received: by 2002:a17:906:451:: with SMTP id e17mr14342313eja.228.1607255342981; Sun, 06 Dec 2020 03:49:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607255342; cv=none; d=google.com; s=arc-20160816; b=Tt2M80P1r7FXAjXBwdw2H3yRGM9i3G491OfSztz53E6Slk+D1ba2OePgz7QV8m5e7k 0Q4uN4uI0AesipjTyqE0PX9qkjtP0OVYwU4UTaN0fg3euWyOhMOnT4jICByBKY4IOPxj 5bZfzwlrYVyJD1I2RlUaHnGuOCuEc4F+TZT/FPLhSbA+St3HhIIbih38R+S/68kBw8GK +nvn/GtAdbchg/w2eGiA9YlCeX9+hbJMt/F2dtSJZmeUJusMexDGl4jfcuRVvxXOKA0R pKDqa38o+nPYdTaMHFfe/yHjt/578fKUSHLNOSFnMiEX8wX1QoMUup/03TBLNfPlMeHH yesQ== 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=y+faxYUPy1JcaeIv+OZUKdfBNlvrDvCDPf3LfBiZVSk=; b=0F3ZZbUQWKIEHCKXYHUnOC63G7LmHLsGmK2KJbrkypaWfMDRlyZ6Jm8e1CGiiLyLmU bGaOgXeZdtXGLwGrsCXPtG0vj0l650TwHbUzDqblIyO1jR6LrapAuQKtYgUYzeI9cltm C57HcKlGk+Mh4o0FWLYrMzo0ayS6Je/Jk1qtZ4jNSmVAWJvkqIO8JbkK0a3FWsSygy+6 llY+KwTWpSty/SzLqOzPLABQEmOr30By5vXxE4J+RMRhH+Q+bERnsjLhOaYm6mVPxy1A /FsElmR86s4XrvMEVPyPqPPGl9DcQKJRLwzuf8HlHQTr+GdajYpWPghJy7MWcPGc17V5 MLjg== 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 bf17si1690560edb.344.2020.12.06.03.48.40; Sun, 06 Dec 2020 03:49:02 -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 S1729080AbgLFLr0 (ORCPT + 99 others); Sun, 6 Dec 2020 06:47:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:42556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729078AbgLFLnM (ORCPT ); Sun, 6 Dec 2020 06:43:12 -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 5.4 06/39] rose: Fix Null pointer dereference in rose_send_frame() Date: Sun, 6 Dec 2020 12:17:10 +0100 Message-Id: <20201206111554.977320232@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201206111554.677764505@linuxfoundation.org> References: <20201206111554.677764505@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 @@ -96,10 +96,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 {