Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp845444yba; Wed, 24 Apr 2019 10:31:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSDXV/9Tw+JZoJZi2ohT7VGFzqn2TiNrUFULZb7WTwJJAafmZjVxWRy3qcII4pROKoNfyu X-Received: by 2002:a62:424b:: with SMTP id p72mr33644457pfa.167.1556127085715; Wed, 24 Apr 2019 10:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556127085; cv=none; d=google.com; s=arc-20160816; b=FiUYe8gdeTxoYOJKWBc0SFHFYQ0gZ/Zj48imJa4bgQmrRCviYkJCOw/fbVoNZtcXPl eeUF5tjuTE7LiAVL+Dw/H57Kl288T5YCh8A7OMcbRHbJaepSaLOSqXV4NHRfGDQhTLun CEUaQw1Nirox7PYIWjL5u+yRFuHKe0CEhWfUNXtZ3sWKajE78G9gvuWlWKITCJ3t+XW8 RECFbTBH6bzth4VKei+d461vLGdOt+onkNWi8AYZ5tVXtExnDuutRnNdJT+jdOusF9iZ O0/wbYs4jNT/mIJ2H/VJmfLE2DyPhTUXet0c6oMwhpLpBbKG0Cr5S2CmnUpRMwmLtf2H qU/Q== 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=WBNAZQSWRBAOfuIOglcyuXf00dqDNqPE/370ghNdaUA=; b=NzakQv3UO4uGpbsnbDP+LQ4khlPYVlF6yJe/buG+g1uwjnM04Mq+rwrTkfcGFhmGRp VTjLpcX3cxXyXg7ISeiG5AlbXnFvxpc+Nm9SSl3pIPAf+/pvTFs5OPi9FwvXyRYGxN7Y a3qS3Gmiq5WShkXti+61QIOV2g15nozRDW5dLOLmb6bp6WaxckjF42rY02E7FzwEs7rH Hg7UqD78djjWs8w1Met9XAg8m/5tKij/8+2TTJjc2lQC2KMLO+RcrQja+rkCwe7/K16g E+zGA/IWjIWOGtAgZ3HSWvcHpN0zZBZqOvRVvaQ4HteYEtw6YSqaaOR034it9rl7pnCa fPCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Wa0+NNB/"; 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 v9si3643531pgq.527.2019.04.24.10.31.09; Wed, 24 Apr 2019 10:31:25 -0700 (PDT) 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="Wa0+NNB/"; 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 S2390830AbfDXR3c (ORCPT + 99 others); Wed, 24 Apr 2019 13:29:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:55806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390803AbfDXR3b (ORCPT ); Wed, 24 Apr 2019 13:29:31 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (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 1C8802054F; Wed, 24 Apr 2019 17:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126970; bh=Z5sPNhUHWDF416TEjZmpdxcjJ8RQfnHxWRVnAn9Fx/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wa0+NNB//P5rEcP0R1BcKvxkiWHPZTojZK9DZYBz3gtYtoMQ76Ubj1PpUBQA8VeGh qLcCAOWxjHP6rUNHZvHOPK9vY2vX9F7PpOtHbp/Iah8UgDEbjjQgRdwiowXjZKS/82 NncyZyBhYnQN83Qz6u/IEYuHDjFMGmSx3dsp55Mo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , Stephen Suryaputra , "David S. Miller" Subject: [PATCH 4.19 13/96] ipv4: ensure rcu_read_lock() in ipv4_link_failure() Date: Wed, 24 Apr 2019 19:09:18 +0200 Message-Id: <20190424170920.679059660@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170919.829037226@linuxfoundation.org> References: <20190424170919.829037226@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Eric Dumazet [ Upstream commit c543cb4a5f07e09237ec0fc2c60c9f131b2c79ad ] fib_compute_spec_dst() needs to be called under rcu protection. syzbot reported : WARNING: suspicious RCU usage 5.1.0-rc4+ #165 Not tainted include/linux/inetdevice.h:220 suspicious rcu_dereference_check() usage! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 1 1 lock held by swapper/0/0: #0: 0000000051b67925 ((&n->timer)){+.-.}, at: lockdep_copy_map include/linux/lockdep.h:170 [inline] #0: 0000000051b67925 ((&n->timer)){+.-.}, at: call_timer_fn+0xda/0x720 kernel/time/timer.c:1315 stack backtrace: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.1.0-rc4+ #165 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x172/0x1f0 lib/dump_stack.c:113 lockdep_rcu_suspicious+0x153/0x15d kernel/locking/lockdep.c:5162 __in_dev_get_rcu include/linux/inetdevice.h:220 [inline] fib_compute_spec_dst+0xbbd/0x1030 net/ipv4/fib_frontend.c:294 spec_dst_fill net/ipv4/ip_options.c:245 [inline] __ip_options_compile+0x15a7/0x1a10 net/ipv4/ip_options.c:343 ipv4_link_failure+0x172/0x400 net/ipv4/route.c:1195 dst_link_failure include/net/dst.h:427 [inline] arp_error_report+0xd1/0x1c0 net/ipv4/arp.c:297 neigh_invalidate+0x24b/0x570 net/core/neighbour.c:995 neigh_timer_handler+0xc35/0xf30 net/core/neighbour.c:1081 call_timer_fn+0x190/0x720 kernel/time/timer.c:1325 expire_timers kernel/time/timer.c:1362 [inline] __run_timers kernel/time/timer.c:1681 [inline] __run_timers kernel/time/timer.c:1649 [inline] run_timer_softirq+0x652/0x1700 kernel/time/timer.c:1694 __do_softirq+0x266/0x95a kernel/softirq.c:293 invoke_softirq kernel/softirq.c:374 [inline] irq_exit+0x180/0x1d0 kernel/softirq.c:414 exiting_irq arch/x86/include/asm/apic.h:536 [inline] smp_apic_timer_interrupt+0x14a/0x570 arch/x86/kernel/apic/apic.c:1062 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:807 Fixes: ed0de45a1008 ("ipv4: recompile ip options in ipv4_link_failure") Signed-off-by: Eric Dumazet Reported-by: syzbot Cc: Stephen Suryaputra Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/route.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1187,14 +1187,20 @@ static struct dst_entry *ipv4_dst_check( static void ipv4_link_failure(struct sk_buff *skb) { - struct rtable *rt; struct ip_options opt; + struct rtable *rt; + int res; /* Recompile ip options since IPCB may not be valid anymore. */ memset(&opt, 0, sizeof(opt)); opt.optlen = ip_hdr(skb)->ihl*4 - sizeof(struct iphdr); - if (__ip_options_compile(dev_net(skb->dev), &opt, skb, NULL)) + + rcu_read_lock(); + res = __ip_options_compile(dev_net(skb->dev), &opt, skb, NULL); + rcu_read_unlock(); + + if (res) return; __icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0, &opt);