Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp764890imm; Wed, 10 Oct 2018 04:04:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV63zjI76LjG59No5r5QL0id0ui/ETQhBYKUq3VdPa9fwR8+Db+uA5pcYkoCrplE8BTz52G2g X-Received: by 2002:a65:609a:: with SMTP id t26-v6mr28721172pgu.41.1539169481195; Wed, 10 Oct 2018 04:04:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539169481; cv=none; d=google.com; s=arc-20160816; b=hjX+68FrcxM5crgSKoVeu3Ou3fpDI2doY5tRjvmgx0D7tOXbgdK8N7bPo4IJmALP5e 6u5xyZR6HSc1iW6TB723S8yRT2NbZHlYdhl2AsBIbsXLWaQvp4vS+femlbrmQmJPoOei 2Nka5E7GGs38sIWxpRxNmVAw4rIIg6o6W1K6LxW81pZ1RXhBExNzIQjZDrAzoLC/wNPf RXoufLqaOWGRcc7QiDsXYFYajOyCyPToZ7CHpjghju++IQp+6aKAuFHW3Y4VPu4q2QkO xZT5uUh+9/mn5ESCULyTIDN06IYAaN6w/r96G6rJKLeSvXBBNHMImjvyPLabbLjKnVtP jtOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=/W3vajcyx02f/8aqS03QE9CAvwoOaYhEd9bB2j9umJo=; b=NdzC/4u50N9sGbAV4KwA/GrtMW3BuN8O5TigOsb+qRhijoGITJrjl27EsPdOCaSV7R OiOO9t1BkYV9uTf+peWav/Woual6bl8c0ewSSENY5azsSHxultZ1DdwV7B7xhyKJHtnh 9qTGiZm0LWq2HZMozfJw4MVGSAXMJtscGaSB83lvgVWphxbCUUIsYAGeSTcuBuPu0Frp kJb+4dhnswxRb/H0p57UJk/Zyo8aPMr9CjD5S87Wzy6GqGLEp7Wb9zUybFuritddwDPJ vbi1FMCK1bOKqBkHgQa4AUHxxxOYcW9866pbmgg8dca1YAaAZ8iV5viGFC78FUFOQCD7 Zscg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=pHFPpBRQ; 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 x2-v6si20816698pgr.432.2018.10.10.04.04.26; Wed, 10 Oct 2018 04:04:41 -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=@agner.ch header.s=dkim header.b=pHFPpBRQ; 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 S1726871AbeJJSX5 (ORCPT + 99 others); Wed, 10 Oct 2018 14:23:57 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:59900 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726479AbeJJSX5 (ORCPT ); Wed, 10 Oct 2018 14:23:57 -0400 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 08E975C0578; Wed, 10 Oct 2018 13:02:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1539169337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/W3vajcyx02f/8aqS03QE9CAvwoOaYhEd9bB2j9umJo=; b=pHFPpBRQzaaDMFLMNmnyqKFeCUxiAjfcDXbG94FmLZHhrrT+UTZ0wEaJvydUUrtA0iyG0m 0Oadv1rBySpM8dMb+mzd6Tqp7G2WiPTATuiZQy1RZUfVF0+yqbGO9LYS1IuBibYPSX0S/9 0gdj68ENcOMEVUWVxWfUJDtFrMl2JXA= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Wed, 10 Oct 2018 13:02:16 +0200 From: Stefan Agner To: Russell King - ARM Linux , Lucas Stach Cc: p.zabel@pengutronix.de, airlied@linux.ie, gregkh@linuxfoundation.org, rafael@kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] drm/imx: make sure to cleanup DRM before unbinding components In-Reply-To: <20181010103829.GN30658@n2100.armlinux.org.uk> References: <83a28282a3f745a4cd4ca77d0593ad2e61359a5d.1539120077.git.stefan@agner.ch> <20181010103829.GN30658@n2100.armlinux.org.uk> Message-ID: <11a452de8e6b39c80ae8ff6b2cdc4cc8@agner.ch> X-Sender: stefan@agner.ch User-Agent: Roundcube Webmail/1.3.7 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [adding Lucas] On 10.10.2018 12:38, Russell King - ARM Linux wrote: > On Tue, Oct 09, 2018 at 11:30:49PM +0200, Stefan Agner wrote: >> In situations where a component fails to bind, a previously >> successfully bound component might already registered itself >> with the DRM framework (e.g. an encoder). When the master >> component then calls drm_mode_config_cleanup, we end up in a >> use after free sitution. >> >> Use the cleanup callback to make sure all framework level >> cleanup is done by the time we unbind components. > > I'm not sure about this approach - the idea about the component bind > and unbind callbacks is that unbind undoes _everything_ that bind has > done, so everything is correctly ordered. If bind registers something, > unbind should unregister it. > > What seems to be going on is that imx is registering stuff in bind() > but not unregistering it in unbind(). Yes indeed, if that can be fixed this seems to be the better approach to me. > > Since imx was one of the drivers that the component helper was > created for, if it's now crashing, that's a regression in the imx > driver. Looking at the commit log, I'd say: > > commit 8e3b16e2117409625b89807de3912ff773aea354 > Author: Lucas Stach > Date: Thu Aug 11 11:18:49 2016 +0200 > > drm/imx: don't destroy mode objects manually on driver unbind > > Instead let drm_mode_config_cleanup() do the work when taking down > the master device. This requires all cleanup functions to be > properly hooked up to the mode object .destroy callback. > > Signed-off-by: Lucas Stach > Signed-off-by: Philipp Zabel > > is probably responsible for introducing this problem, since the > explicit calls were added by me when imx was stuck in staging due to > the problems that the component helper solved. The commit above does not revert cleanly today, but a quick fixing seemed to resolve the problem I am seeing... > > I think what we have here are different opinions on how cleanup > should be handled. In the regular case using the framework cleanup function before calling component_unbind_all() works fine. Its really only the case where a subcomponent fails to bind where unbind happens before calling drm_mode_config_cleanup(drm). I guess Lucas was not aware of that special case...? I can send a patch which properly reverts the above commit. -- Stefan