Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3346184pxv; Sun, 4 Jul 2021 16:10:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvz3bCeuc3vO3JuwAQhAqxE0hRQ6UosbJg0SluNEpLwA7ab1vtJd20O9ZJCjNr4d4ArTgW X-Received: by 2002:a17:907:96aa:: with SMTP id hd42mr3227516ejc.51.1625440234023; Sun, 04 Jul 2021 16:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440234; cv=none; d=google.com; s=arc-20160816; b=bGH+gF8KwZmH8Zzux/4VL3S57vd1l8XE7Zw4frLIvAogQzEY4dgaR2GsgLk0kaAy8o Q0RexeXX8kZbtgLEUE6WM8ecoGQbvQv+9JpOpr2zD9513PA0INFQyrnP9ms89NrYC1RU 06C9ixEg/GGgE8pTne1n2Y14L9OPm/kpqQLAp4A4KIZ3s01LFRzKot2us51gt7k5VyMM HJXFPquvnv4wssb8x9FooLxnVZpf9HgZJItB6Wwb2I/xLue4nn2nqN8j5V/uu1oPrdUc gGBUCTm2Ht0MEfyrlFGeXs8PHiymYOC40i/6iR4d6dyXvbTjl74WzWzEjcPSfvL1zXKZ hQuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=M2x/1hTnQGddwq5W6ViFuxsWF24XpzSwDdauj6cByBc=; b=nHnSx9xDoJ4NwtqWoQTaKZAnCuG939tQrPrrL2AeX1BiZT90NEI4VdvKoKGCU9jufB xG/8nY3Q0LzbCWGaQmaxoIp0MGFOTuDZo5aRen4wbP6RHfJHWfr9DeG6PUnFKrPY8Ryq S2ejg/uohe+BpaPDbPuxxRMXoJ34rHuGrvmpW2gkMx/8wTfE/aLTNRzvUCqCTH6xSrui 6ax5/epWkno6cQQ/32qmiQskGR5CcqCRABajBUAoF84lpvAEY5eJAv+Z0EhhneTmsgy7 QamFuR5ydiNOU/QmMM/4e1m4+PSSzQjPZe5tHlSnSidNnO90HzWNErDeE8FcHPs5XafK nJxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lnWBoOGy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x18si9710100edd.477.2021.07.04.16.10.11; Sun, 04 Jul 2021 16:10:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lnWBoOGy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229811AbhGDXLl (ORCPT + 99 others); Sun, 4 Jul 2021 19:11:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:49312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232116AbhGDXKC (ORCPT ); Sun, 4 Jul 2021 19:10:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BEB3D613FB; Sun, 4 Jul 2021 23:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625440034; bh=LYo60E9hzNfnIeU6O7W5VONI9WogMKheLf5JCQtvhwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lnWBoOGyV9S34JqkTpK0vUTkfrckgaMz9hFpmsNoaDkO6M535u9D21UNJFWxAFXXf gfR66+FP9Pnme16FfA/LHkFxQjuSH+IrOJVvWfBDuqe2jbyiCtxMGheYcY4CEDrVP3 nNlwSdyUSCMcq1Hz1yfQ20jVPIuAFfEK4L7WLwfcYbsdAFGDct1B5wsi/FTIFw68Gg pQ54+NjQlBLdGORc7UBu3IE3pLBMDivEmo82qkPP60kjWVHC94LpWwgCLuvUggrCKG /iUfeTkL1Xpr55KBRlHIKq+2i6+L+OeFseMrfSyStbdPfXnzZgLraVvzP+++XhgNqf Zuu0srW+6wOjA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lv Yunlong , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.12 42/80] media: v4l2-core: Avoid the dangling pointer in v4l2_fh_release Date: Sun, 4 Jul 2021 19:05:38 -0400 Message-Id: <20210704230616.1489200-42-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230616.1489200-1-sashal@kernel.org> References: <20210704230616.1489200-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lv Yunlong [ Upstream commit 7dd0c9e547b6924e18712b6b51aa3cba1896ee2c ] A use after free bug caused by the dangling pointer filp->privitate_data in v4l2_fh_release. See https://lore.kernel.org/patchwork/patch/1419058/. My patch sets the dangling pointer to NULL to provide robust. Signed-off-by: Lv Yunlong Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/v4l2-core/v4l2-fh.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c index 684574f58e82..90eec79ee995 100644 --- a/drivers/media/v4l2-core/v4l2-fh.c +++ b/drivers/media/v4l2-core/v4l2-fh.c @@ -96,6 +96,7 @@ int v4l2_fh_release(struct file *filp) v4l2_fh_del(fh); v4l2_fh_exit(fh); kfree(fh); + filp->private_data = NULL; } return 0; } -- 2.30.2