Received: by 10.213.65.68 with SMTP id h4csp712669imn; Fri, 23 Mar 2018 14:13:42 -0700 (PDT) X-Google-Smtp-Source: AG47ELvbZ8omMFu4AQzwFsDiRDdFuk2wBHYUDceOFUTrdGvooRHir7Ovd+hGuq2tTBaLZGOJTJSd X-Received: by 2002:a17:902:24c:: with SMTP id 70-v6mr30863086plc.384.1521839622827; Fri, 23 Mar 2018 14:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521839622; cv=none; d=google.com; s=arc-20160816; b=tLSXs3De92L82mZnpYENfOs5TFHIe8gRAalMGuxfaX34NBVo/7biRuKPQOp+XeuosJ c+BOQKcb18ywq6rtwMRXt5UDLEgl7H5INkA7v1SdkRWncco+9K5/E3/4yXOo16FWoGS2 /6gKZ8GuPPH4nW775IpK/04fwJQ3DovvMDYqBGPkg82KIMu8b4qcpNxu1fAMZFVclyDL G6q3o0jYfqE0F9WUo2MfqKNNn4lcetQlsdc4gBhcbokSLOPZ8DDHG2TQkSf8EiCFBvxg emKrvYvFpdCQ5UaI3JklM3wC0f0Z5ImhRuBxlDIohWrS0fO21G2mhvuwnLTdPinZuFFA tZbA== 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:message-id :subject:cc:to:from:date:arc-authentication-results; bh=5uor6OD8msx8KjTAAdcFZsid/ArkwMgCLUZAFPcIFpg=; b=kABsMK4ni8n7f1rFu66t2Cs2X6kuzMgDZzmKRYNWmr1LKlTCrnDhepE/Pi82e+OHeo Y0Bb4rF3e9WiOAR8GMqwFxB3hKYcf+P2KmVzjUsqq3FPpIoc1VNgsvq0y9niNfl8QMIl Hmpoo+yqS5a88SgkMmaN8sA6TWdRabDGjnfeRh8zoC7JlF28S//MwKErs7uRgbyT77gk XVkzI0kHN8Lkjw/HZXkFLwaEjF+sz62PjcbWvXeulnI6/JKjkB3PjzdEpETs+jr7UTv2 b64pZ8Var4oe2r+SIDtlMIj1/J9ciFtGl4nIofjza9yCWF8dsZ8P9gg1QmqlQXvP+WQc +jLA== 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 i3-v6si9321961pli.274.2018.03.23.14.13.28; Fri, 23 Mar 2018 14:13:42 -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; 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 S1752112AbeCWVM3 (ORCPT + 99 others); Fri, 23 Mar 2018 17:12:29 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:42371 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751504AbeCWVM2 (ORCPT ); Fri, 23 Mar 2018 17:12:28 -0400 Received: from p4fea5f09.dip0.t-ipconnect.de ([79.234.95.9] helo=nanos.glx-home) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1ezTz6-0003Ah-U3; Fri, 23 Mar 2018 22:12:25 +0100 Date: Fri, 23 Mar 2018 22:12:24 +0100 (CET) From: Thomas Gleixner To: LKML cc: "Paul E. McKenney" , Peter Zijlstra , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes Subject: rcu: Add might_sleep() check to synchronize_rcu() Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Subject: rcu: Add might_sleep() check to synchronize_rcu() From: Thomas Gleixner Date: Fri, 23 Mar 2018 22:02:18 +0100 Joel reported a debugobjects warning which is triggered by a RCU callback invoking synchronize_rcu(). RCU callbacks run in softirq context, so calling synchronize_rcu() is a bad idea as it might sleep. debugobjects triggers because __wait_rcu_gp() uses on stack objects and invokes debug_object_init_on_stack(). That function checks the object address against current's task stack, which fails because the code runs on the softirq stack. synchronize_rcu() lacks a might_sleep() check which would have caught that issue way earlier because it would trigger with the minimal debug options enabled. Add a might_sleep() check to catch such cases. Reported-by: Joel Fernandes Signed-off-by: Thomas Gleixner Cc: "Paul E. McKenney" Cc: Josh Triplett Cc: Steven Rostedt Cc: Mathieu Desnoyers Cc: Lai Jiangshan --- kernel/rcu/tree_plugin.h | 1 + 1 file changed, 1 insertion(+) --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -753,6 +753,7 @@ void synchronize_rcu(void) "Illegal synchronize_rcu() in RCU read-side critical section"); if (rcu_scheduler_active == RCU_SCHEDULER_INACTIVE) return; + might_sleep(); if (rcu_gp_is_expedited()) synchronize_rcu_expedited(); else