Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp85139imm; Tue, 24 Jul 2018 14:31:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe02ZLvF6SLbqS+2OqWbwsRbCaHPjw1I+s1cB5vM88inJbWCqSRfHTSB8OQ3WnztQn0gjXt X-Received: by 2002:a62:b612:: with SMTP id j18-v6mr19469438pff.199.1532467881206; Tue, 24 Jul 2018 14:31:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532467881; cv=none; d=google.com; s=arc-20160816; b=cb+aZFg19kZ/OFlUWqrxz4sjsuQj+pTD0Xg9RlzW4qbnU4H3FrChXBWQkYQCPwAjAg hejweNOST/uO3q/f/G/ip5OWm4YWVrKJXGGvNXFRljtF1u+S/bjf50c3X5d10RXCoDrQ tiMhnENsFOLPRHVmrsXiCW3K6e9H5/ktLnwwO00NeQHNP/3SNnPUrsfJ7IAdSt53sp/s m5YxbvonFpDLRcr6yyEfnFDx9Nkc4oWhUfT8jsE32K+lZkHEniQlPFxEkgzo0sSiHn92 QYm6EYhZDOnUfJATq74pttecexmDGM3GZkAoWJhz1b2x2kNnI/NnVryXdLZW6musyXm4 Uw0Q== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=UU/0xWEHIUkOhj0we32UQ14kiXiUuNUhFKrsnUN5Y3o=; b=FjLc7tvCAqufF0IOQxKrcyJuHnbTcID157vlJtsf8Tg8U3uewza5mTbwZfUVeafPfU M3frQ5CGsjUxxClAZhsV7KngwZXgQ4pWK0mgDhISvtoH0cP4jfTqFn5o3Aq/vv+YkSKn E39kmst8AlKOR/HM9gmh382gDYqwHjrCKV0LM0fI2YrEs86xrLQDXeIdfFBqP95xgbnR NzfWf9i76VXeXI7M+eP/oV9NyCiEVcTnblDF5uCz45y0h/G7v7gAace97e6Rz9hU7lC3 8VLiZ6ln5F0EjVEcBUMl6+k6Wzg4VIrGDM6jeoetHvMXOZBD3bR+8OVHeDSeuTpNIR8d rgsQ== 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 f9-v6si6624879pgi.12.2018.07.24.14.31.05; Tue, 24 Jul 2018 14:31:21 -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 S2388664AbeGXWif (ORCPT + 99 others); Tue, 24 Jul 2018 18:38:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:60370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388543AbeGXWif (ORCPT ); Tue, 24 Jul 2018 18:38:35 -0400 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (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 AE7C320856; Tue, 24 Jul 2018 21:30:10 +0000 (UTC) Date: Tue, 24 Jul 2018 17:30:08 -0400 From: Steven Rostedt To: Tom Zanussi Cc: Masami Hiramatsu , Ingo Molnar , Shuah Khan , Hiraku Toyooka , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 1/3] [BUGFIX] tracing: Fix double free of event_trigger_data Message-ID: <20180724173008.454cdf10@gandalf.local.home> In-Reply-To: <20180724164959.3cbc1422@gandalf.local.home> References: <153149923649.11274.14970833360963898112.stgit@devbox> <153149926702.11274.12489440326560729788.stgit@devbox> <20180723221006.60cc7aa9@vmware.local.home> <20180725000909.6c8b2f3881ee75c4f6bd466b@kernel.org> <20180724164959.3cbc1422@gandalf.local.home> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 24 Jul 2018 16:49:59 -0400 Steven Rostedt wrote: > > Hmm it seems we should review the register_trigger() implementation. > > It should return the return value of trace_event_trigger_enable_disable(), > > shouldn't it? > > > > Yeah, that's not done well. I'll fix it up. > > Thanks for pointing it out. Tom, register_trigger() is messed up. I should have caught this when it was first submitted, but I'm totally confused. The comments don't match the code. First we have this: ret = cmd_ops->reg(glob, trigger_ops, trigger_data, file); /* * The above returns on success the # of functions enabled, * but if it didn't find any functions it returns zero. * Consider no functions a failure too. */ Which looks to be total BS. As we have this: /** * register_trigger - Generic event_command @reg implementation * @glob: The raw string used to register the trigger * @ops: The trigger ops associated with the trigger * @data: Trigger-specific data to associate with the trigger * @file: The trace_event_file associated with the event * * Common implementation for event trigger registration. * * Usually used directly as the @reg method in event command * implementations. * * Return: 0 on success, errno otherwise */ static int register_trigger(char *glob, struct event_trigger_ops *ops, struct event_trigger_data *data, struct trace_event_file *file) { struct event_trigger_data *test; int ret = 0; list_for_each_entry_rcu(test, &file->triggers, list) { if (test->cmd_ops->trigger_type == data->cmd_ops->trigger_type) { ret = -EEXIST; goto out; } } if (data->ops->init) { ret = data->ops->init(data->ops, data); if (ret < 0) goto out; } list_add_rcu(&data->list, &file->triggers); ret++; update_cond_flag(file); if (trace_event_trigger_enable_disable(file, 1) < 0) { list_del_rcu(&data->list); update_cond_flag(file); ret--; } out: return ret; } Where the comment is total wrong. It doesn't return 0 on success, it returns 1. And if trace_event_trigger_enable_disable() fails it returns zero. And that can fail with the call->class->reg() return value, which could fail for various strange reasons. I don't know why we would want to return 0 when it fails? I don't see where ->reg() would return anything but 1 on success. Maybe I'm missing something. I'll look some more, but I'm thinking of changing ->reg() to return zero on all success, and negative on all errors and just check those results. -- Steve