From patchwork Tue Mar 31 08:59:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 228655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13682C43331 for ; Tue, 31 Mar 2020 09:10:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA80E20675 for ; Tue, 31 Mar 2020 09:10:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645807; bh=i54h0PpoMrZjEXGvANY6FaJbACna+TsoRHILdEn6CI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=sf360WVP77BeXkpURVg9W0EuApJHVoJKu/yAxoF0p7Ndc80WBAXKUUREFYnXjHjrY ncpEdVAi1H6KFf//izbNnfyTLvC6eVSEHsOD5XyZH9cCn/VASRPzoMDEXM/hFF2Mvw HBget2KuwNMe3U9cYYFaweTHa7d5zphP1ojQaeik= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730626AbgCaJKD (ORCPT ); Tue, 31 Mar 2020 05:10:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:53622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731558AbgCaJKD (ORCPT ); Tue, 31 Mar 2020 05:10:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 39E9720675; Tue, 31 Mar 2020 09:10:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645802; bh=i54h0PpoMrZjEXGvANY6FaJbACna+TsoRHILdEn6CI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VHgnBh0C2mMKcnEmQIhXvB422yfh6EGALtxEmtLXzSgQZMYXHmOHJ2Jf/vcPqf1KY jfiiugSz8CFzcVEDpYMOlU1XEF25M+/xG1cDwWVlTb/QYuln4Z9BsJr2bmghXLSKOQ aRb6r7KtJq9wcwdDgBZoEpg7MrO/I31mHjCfQySM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dafna Hirschfeld , Ezequiel Garcia , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.5 170/170] media: v4l2-core: fix a use-after-free bug of sd->devnode Date: Tue, 31 Mar 2020 10:59:44 +0200 Message-Id: <20200331085440.662743229@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dafna Hirschfeld commit 6990570f7e0a6078e11b9c5dc13f4b6e3f49a398 upstream. sd->devnode is released after calling v4l2_subdev_release. Therefore it should be set to NULL so that the subdev won't hold a pointer to a released object. This fixes a reference after free bug in function v4l2_device_unregister_subdev Fixes: 0e43734d4c46e ("media: v4l2-subdev: add release() internal op") Cc: stable@vger.kernel.org Signed-off-by: Dafna Hirschfeld Reviewed-by: Ezequiel Garcia Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/v4l2-core/v4l2-device.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/media/v4l2-core/v4l2-device.c +++ b/drivers/media/v4l2-core/v4l2-device.c @@ -179,6 +179,7 @@ static void v4l2_subdev_release(struct v if (sd->internal_ops && sd->internal_ops->release) sd->internal_ops->release(sd); + sd->devnode = NULL; module_put(owner); }