Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4134175ybb; Mon, 23 Mar 2020 14:15:18 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuS9npfUJd3ZwbT6MZ1f4QQSoAZ8oqAR++hRMsBOulJmsXoQi8APZgHV84eRsSIs95Ornb9 X-Received: by 2002:a05:6830:1c7:: with SMTP id r7mr9853790ota.58.1584998117808; Mon, 23 Mar 2020 14:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584998117; cv=none; d=google.com; s=arc-20160816; b=bkNF+XAesxxD8drTKBm+OaD5HhhUCUGfjHxmJHtR7G/aFbPvLMi0/pUaZWmEnO98X3 6lOAC8M8zYkBK7lL7owpDzBhQnVGyTWF79iJlhqN2y7iXmXNAtA3w6aOBu9PQzDkhO0f MdQhCpcssrz6rcE+Z0p/ZBzow2C3VAJtJlHKGuQ7spXMzkfq67aW67pq+F5YMAKfagf+ Snusa39Nu9yIR9T4I0OkD+jAPEZuTOQldBvnXvbL4rgCSH2MbDmdZzs8rg+Xjn/14vVB BTsPt05FnTfxsXcrywVk/13YglHQi5onEBLw+pm/XyQ3hhSApWVjpJkFHZpJPD6kE3W8 WlnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=Iv6RkIx9wCF83Sx96nnnuNIrxrS4tZBUxBkAvBBLz8g=; b=Cib9PjKip/HaYtjJ/5mCU82g5HhmVQ5N1oCtSDJ3Zbc0Gy38e7ea6dXDSVd/Sy2RlZ cfx9svdGOMxX8+nVZnThr8wg9n2IQZtNhQkHVjgFt5aLbgoNBfTTGLGM8Usvlyr/4r4H dNfiWtT2i+nZO7sXul5d3rmhld35hEQu/pcDqgKxAIP/M4SqC5vztKQb6j6Q877tru28 pt9IlJp0I/Vle6Hj9yRmUX0F4rsipMqCD/IpphZLp5mwp4PvrjH4bEybfPsPf2OW2e9d TmzmSywuRfH+R4j+a2Ad/dWOws8q+q7On6TuubfnDpu2gg3AWzr1ZIiROWGK2n3ytFJF 5yNQ== 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 l14si349929ooe.48.2020.03.23.14.15.04; Mon, 23 Mar 2020 14:15:17 -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 S1727046AbgCWVOR (ORCPT + 99 others); Mon, 23 Mar 2020 17:14:17 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:42841 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726618AbgCWVOR (ORCPT ); Mon, 23 Mar 2020 17:14:17 -0400 Received: from p5de0bf0b.dip0.t-ipconnect.de ([93.224.191.11] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jGUOa-0007Jk-Ch; Mon, 23 Mar 2020 22:14:04 +0100 Received: by nanos.tec.linutronix.de (Postfix, from userid 1000) id C404A1040AA; Mon, 23 Mar 2020 22:14:03 +0100 (CET) From: Thomas Gleixner To: Cong Wang Cc: syzbot , David Miller , Jamal Hadi Salim , Jiri Pirko , Jakub Kicinski , LKML , Linux Kernel Network Developers , syzkaller-bugs Subject: Re: WARNING: ODEBUG bug in tcindex_destroy_work (3) In-Reply-To: References: <000000000000742e9e05a10170bc@google.com> <87a74arown.fsf@nanos.tec.linutronix.de> Date: Mon, 23 Mar 2020 22:14:03 +0100 Message-ID: <87ftdypyec.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain 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 Cong Wang writes: > On Sat, Mar 21, 2020 at 3:19 AM Thomas Gleixner wrote: >> > ------------[ cut here ]------------ >> > ODEBUG: free active (active state 0) object type: work_struct hint: tcindex_destroy_rexts_work+0x0/0x20 net/sched/cls_tcindex.c:143 >> ... >> > __debug_check_no_obj_freed lib/debugobjects.c:967 [inline] >> > debug_check_no_obj_freed+0x2e1/0x445 lib/debugobjects.c:998 >> > kfree+0xf6/0x2b0 mm/slab.c:3756 >> > tcindex_destroy_work+0x2e/0x70 net/sched/cls_tcindex.c:231 >> >> So this is: >> >> kfree(p->perfect); >> >> Looking at the place which queues that work: >> >> tcindex_destroy() >> >> if (p->perfect) { >> if (tcf_exts_get_net(&r->exts)) >> tcf_queue_work(&r-rwork, tcindex_destroy_rexts_work); >> else >> __tcindex_destroy_rexts(r) >> } >> >> ..... >> >> tcf_queue_work(&p->rwork, tcindex_destroy_work); >> >> So obviously if tcindex_destroy_work() runs before >> tcindex_destroy_rexts_work() then the above happens. > > We use an ordered workqueue for tc filters, so these two > works are executed in the same order as they are queued. The workqueue is ordered, but look how the work is queued on the work queue: tcf_queue_work() queue_rcu_work() call_rcu(&rwork->rcu, rcu_work_rcufn); So after the grace period elapses rcu_work_rcufn() queues it in the actual work queue. Now tcindex_destroy() is invoked via tcf_proto_destroy() which can be invoked from preemtible context. Now assume the following: CPU0 tcf_queue_work() tcf_queue_work(&r->rwork, tcindex_destroy_rexts_work); -> Migration CPU1 tcf_queue_work(&p->rwork, tcindex_destroy_work); So your RCU callbacks can be placed on different CPUs which obviously has no ordering guarantee at all. See also: https://mirrors.edge.kernel.org/pub/linux/kernel/people/paulmck/Answers/RCU/RCUCBordering.html Disabling preemption would "fix" it today, but that documentation explicitely says that it is an implementation detail, but not guaranteed by design. Thanks, tglx