Received: by 10.223.185.116 with SMTP id b49csp1080984wrg; Fri, 23 Feb 2018 11:34:29 -0800 (PST) X-Google-Smtp-Source: AH8x22431YnT2HV7COa8oiOs2lTkovnWduhXVVeCI9QZ+X4azSx1S/zyNxBd387omv/ekKfcYB1Q X-Received: by 10.98.149.90 with SMTP id p87mr2783333pfd.28.1519414469359; Fri, 23 Feb 2018 11:34:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519414469; cv=none; d=google.com; s=arc-20160816; b=BgdUuBl4vOr6tgjhqpViE8kVMcAqQ8EnnFNZ8aXTjvcUEP3TZ6IP489m83neHwlkOM tkzQzqSWouS1W3pNwtvgBXkfAmj0sqZi0ECNFc/4u2UG2eNO7nJezUFI9Xs3xIbz2L0+ Fi1n0u+YW/t6JZLTgFVE4fxx+YUWypsq33qeHHYe32ifcao7PBZdYO6oZAOSHKXOdPu3 D3lk7fbXhMPQGAVJChYd2pHW3fCnvRleKrzpzasnpFRC4IBgceURweXuQ3H0Cs8Qn68T irL4URq9YAlffj4q4DZLqHSETghJ5MPLRCO6f7QmRx7vkIm1q2YpR4bnhKLALYiVzyef sEAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=rc149ZYmTO26lYpZbgspMRvs0iC9bWhQ0J0IucxtaxM=; b=IiaUpm2Eap/5U5WYJikZu649GNCcDHdSbIu058FcZ0fIyk71Ui9iz5CyQqjn8hBxSr gjIY/3cavcu7uJhnriinS6N5XK1byZzNa7otjj+v9M4bSQdjih3yYwGwogmICyLCMAVF m6uo4vVq1qmeJVqp1WIQwXW6o8qdicU7BQLUtPDg74FMsI9DEzcWi4rx53Y6jgTOJkxV NCSovQdUvaFZ9m3RaE8hHzqfHz4fnpv1lZ5q4P5qR1zr7zLpLCftS6m87fe5KgK2WTNH L84KAUt7bMOy/fQge+mCrYtI0x3jN83cCmgTKlUMWpe7dRhnCpWLMpLFNaWbkbdxozUI TCUA== ARC-Authentication-Results: i=1; mx.google.com; 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 i11si1862217pgq.332.2018.02.23.11.34.14; Fri, 23 Feb 2018 11:34:29 -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; 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 S934884AbeBWSvI (ORCPT + 99 others); Fri, 23 Feb 2018 13:51:08 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:45924 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934306AbeBWSvF (ORCPT ); Fri, 23 Feb 2018 13:51:05 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CAD5312E2; Fri, 23 Feb 2018 18:51:04 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , Cong Wang , "David S. Miller" Subject: [PATCH 4.14 044/159] net_sched: gen_estimator: fix lockdep splat Date: Fri, 23 Feb 2018 19:25:52 +0100 Message-Id: <20180223170748.719730598@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170743.086611315@linuxfoundation.org> References: <20180223170743.086611315@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet commit 40ca54e3a686f13117f3de0c443f8026dadf7c44 upstream. syzbot reported a lockdep splat in gen_new_estimator() / est_fetch_counters() when attempting to lock est->stats_lock. Since est_fetch_counters() is called from BH context from timer interrupt, we need to block BH as well when calling it from process context. Most qdiscs use per cpu counters and are immune to the problem, but net/sched/act_api.c and net/netfilter/xt_RATEEST.c are using a spinlock to protect their data. They both call gen_new_estimator() while object is created and not yet alive, so this bug could not trigger a deadlock, only a lockdep splat. Fixes: 1c0d32fde5bd ("net_sched: gen_estimator: complete rewrite of rate estimators") Signed-off-by: Eric Dumazet Reported-by: syzbot Acked-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/core/gen_estimator.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/net/core/gen_estimator.c +++ b/net/core/gen_estimator.c @@ -159,7 +159,11 @@ int gen_new_estimator(struct gnet_stats_ est->intvl_log = intvl_log; est->cpu_bstats = cpu_bstats; + if (stats_lock) + local_bh_disable(); est_fetch_counters(est, &b); + if (stats_lock) + local_bh_enable(); est->last_bytes = b.bytes; est->last_packets = b.packets; old = rcu_dereference_protected(*rate_est, 1);