Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp35230pxu; Thu, 10 Dec 2020 17:27:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8/mfHfjNVo0MK1R7DRGpwkZ2a4mMyTrQNG+2rhGYvZaRxHRa2kOH/LtYr5CERB1kSp4Yn X-Received: by 2002:a05:6402:687:: with SMTP id f7mr9506667edy.314.1607650044896; Thu, 10 Dec 2020 17:27:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607650044; cv=none; d=google.com; s=arc-20160816; b=n/EsqukDKfwnGDa4/6JzpQALWRv2tC+++3yOXrLICPWC+SdXVhfAChiVLuwQDzW36d WQwelftSBrBFQ+SNqNNOrWvz+vWGaumQnJEdBiEuD96qeOMQNhMJTOhhKERaDKvS/BKb sNDslsyLtV1Px7sGJPgthuiDsC5C4q+TxJ/zHzAhiSk/FvEVva+5joONk8LJXLdM8mt7 Ycc3lgo178A0taBJ/41r7YeZkz2hQgHTWKuFdGoLsdwXGy5PERN9oVDYJzoxw6CSslH4 fP/5ybjO8vg6T05kvHGasI32Js/iPRtBdmSVb5Vv4EDuV+n3/qLBRx8HqmXZzjiPFff/ +9Mg== 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=loBMzmAky9JyCmy7TwVGJmAz9M+qHlny89kxNDmj+Ko=; b=FkDz5qceDaH8U9TWSXz7pYCJ+pIZho2tP8F6TGEYpmufFBOTMmxchv+A54xQp9ns03 sXohwxxR5zNLZCk6vvWNzy/3F6dopwOKbrXNm0P9RcRWXjYvpAjMh97P6dXwMVGSOsAB aV6x5O3P+a1x6CkZJPptFCvqMLxC2prwPfloaPyCIpOj/n0WSA7pxlgjh5CYQZNSOzZc 5ZvCjq452FjmTj5+sUiUemf4wL3ptZHbQjyWS1voqTLpzIxB1GfAt9L3iczSjWwCzg5r kvlVfEEK1zj4ax/1c2zf1FKW5ntBzAxh1kzCHJS0F0ZVPX2J6dgPDpWQts/meyPu7wId iYIQ== 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 g10si3650744ejf.344.2020.12.10.17.27.02; Thu, 10 Dec 2020 17:27:24 -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 S2390380AbgLJOao (ORCPT + 99 others); Thu, 10 Dec 2020 09:30:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:36422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390206AbgLJO3R (ORCPT ); Thu, 10 Dec 2020 09:29:17 -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.9 02/45] rose: Fix Null pointer dereference in rose_send_frame() Date: Thu, 10 Dec 2020 15:26:16 +0100 Message-Id: <20201210142602.476353973@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201210142602.361598591@linuxfoundation.org> References: <20201210142602.361598591@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(unsigned } 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 {