Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp611137rwb; Wed, 16 Nov 2022 05:30:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf71Ltv2LNVWmolu7Fafdyy3Byage63eL+tyYQZeQ7z5S12enJIDwQkneQ+Q5y3NZYaNJ5fh X-Received: by 2002:aa7:82cc:0:b0:572:30f2:af50 with SMTP id f12-20020aa782cc000000b0057230f2af50mr12441874pfn.24.1668605431252; Wed, 16 Nov 2022 05:30:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668605431; cv=none; d=google.com; s=arc-20160816; b=juk7UI8pnhO4Qgo/xCl0qlfxQbFFF85DhbkBXOwum+Fv/CyDFgzlJJ7kxr6vuABir/ AQypiQS7XMwCEeQj+kyi/bdoa1z0KQdnOvi87ciP66mkCmBd807xnGvIOtsC7gkyjLny 166GB2ArW0YW2XIz29vUwS2kBUvLaeukgYLuI7DQR+uldNOM7HYIAoSkmmrITaTNrlJ0 FK2zBsmPjkwhqB4lfbb23YgZNwwu6Iot3TF8YMnfHpt2FLXIEbhgkypWr7R+zrSr5lkn oilNqsPjdSBsqSfJvnL9m97BOTByqhMqF4muJ3UaERORtUV/LqWBg6j+lsQ/atLJy3zx 5ysw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fpqKb4lhf4Ox3aXbS6ZVbIYbgJNdN32hGzbeNBKgyKo=; b=dlTjX7jw38nE4NApV4jmetkSc1e6eiNz5q9ivXxtJND+LDhx4x4dZ0cDyqd6Yd1jQC j0bAaKJZCWcpeEyFDBlyXq9itwDSU7I9k2+CBDJP4yoAAJeyANG2aZErI1O5xK49zIEV fl5V+0GOSf0osPZ+1VpRxII+EX+X89fp/9U4br2oewO06ByIQWogjprYRz5SpTJ0XFlQ lP/VTH8WfxlGXkvP4HAcK0cp1Jf0Y33kbERQZdEWwGKFaXsq9zwV5o7N2jHFZ7Rcd77L gq38q4Wc4FnxKsEc3EBMB0VgQYzfgpFqrVeb4LDk1KQCVWiG5r+CiRVPcl+QJUYWqBSl +SnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="H7X/Ph3K"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o6-20020a17090ad20600b00205f49b70fdsi1757266pju.127.2022.11.16.05.30.18; Wed, 16 Nov 2022 05:30:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="H7X/Ph3K"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233381AbiKPNTh (ORCPT + 91 others); Wed, 16 Nov 2022 08:19:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230411AbiKPNTf (ORCPT ); Wed, 16 Nov 2022 08:19:35 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D03E017421; Wed, 16 Nov 2022 05:19:33 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id p21so16393634plr.7; Wed, 16 Nov 2022 05:19:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=fpqKb4lhf4Ox3aXbS6ZVbIYbgJNdN32hGzbeNBKgyKo=; b=H7X/Ph3K8hi9qxqMrkAU+OPdQ+wgInpmZ4tDynQUM1wiGAEqzDDX4ZyZrKtKdK7FSu Aw3kgSlmvqJMBENX3K9foSEeXv2MSrXszIFk8b8THbmYibbVSudEtB+NSRzP6GGHZFai w9khhfwcvwTpAvIsq2nPHJfZFDiV1neEASz1asDGoocEzXc8SyNi1UOPzA5Z2Hge6y+C XL7dCVSEQWm+gCrMFCbGnb/yaTXp8uDRN9EeTnoav3UYBbApRq4tdv9da4ylrnykNQlm oyFHamJyCLdWaqJFTsEYE++8a0qLxopgIQFC779jEVVcEOX8RG7KDu8zVlonDF5RuzzO trfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fpqKb4lhf4Ox3aXbS6ZVbIYbgJNdN32hGzbeNBKgyKo=; b=PRdyYVqUFTwBTy5tCiQ4HXDJ67Ek+i1YyOTMwq7TxW+PfkWSYbka7Q404RlXbfJrBl 7icN4yw3zjrUl/3E4azUKC8BjiINgzjP+i8T+HmdctZC0q+EFC7Nr0pH7Eo7mrQhhFhy qdnhJZwP2sHuJgbi7l9pe3ddnxKFXEdx/VGUv0njf4zjdKKVENOoKd7Se4L0GqIpQJ7b Pzoe96nG3Ev9ImLw8iy3o6M3Bdl3UTYMAfi+Vl06GO7nxSlOyivdjEAYAMsa9xGIkwZ4 +skP95UJIMcp42gdMXyeTG5u121cSq3E+bXEHLwy69wvdf8gai2kyZz/zF1EbLMSGigC P55g== X-Gm-Message-State: ANoB5plF5rFL3yvFe1O+XEE+ZK9jh19JUGaltyuFlswH5thR8FD2cVSt bTQknQ6YeydKsR3/NlLMepE= X-Received: by 2002:a17:902:a586:b0:188:5681:4dc7 with SMTP id az6-20020a170902a58600b0018856814dc7mr9117157plb.97.1668604773213; Wed, 16 Nov 2022 05:19:33 -0800 (PST) Received: from ubuntu ([175.124.254.119]) by smtp.gmail.com with ESMTPSA id rj6-20020a17090b3e8600b00217cdc4b0a5sm1533616pjb.16.2022.11.16.05.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 05:19:32 -0800 (PST) Date: Wed, 16 Nov 2022 05:19:28 -0800 From: Hyunwoo Kim To: Salvatore Bonaccorso Cc: Takashi Iwai , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, imv4bel@gmail.com Subject: Re: [PATCH] media: dvb-core: Fix UAF due to refcount races at releasing Message-ID: <20221116131928.GA7144@ubuntu> References: <20220908132754.30532-1-tiwai@suse.de> <87sfklgozd.wl-tiwai@suse.de> <87k056dekm.wl-tiwai@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, Nov 16, 2022 at 12:08:03PM +0100, Salvatore Bonaccorso wrote: > Hi, > > On Tue, Oct 11, 2022 at 09:06:33AM +0200, Takashi Iwai wrote: > > On Wed, 21 Sep 2022 09:34:30 +0200, > > Takashi Iwai wrote: > > > > > > On Thu, 08 Sep 2022 15:27:54 +0200, > > > Takashi Iwai wrote: > > > > > > > > The dvb-core tries to sync the releases of opened files at > > > > dvb_dmxdev_release() with two refcounts: dvbdev->users and > > > > dvr_dvbdev->users. A problem is present in those two syncs: when yet > > > > another dvb_demux_open() is called during those sync waits, > > > > dvb_demux_open() continues to process even if the device is being > > > > closed. This includes the increment of the former refcount, resulting > > > > in the leftover refcount after the sync of the latter refcount at > > > > dvb_dmxdev_release(). It ends up with use-after-free, since the > > > > function believes that all usages were gone and releases the > > > > resources. > > > > > > > > This patch addresses the problem by adding the check of dmxdev->exit > > > > flag at dvb_demux_open(), just like dvb_dvr_open() already does. With > > > > the exit flag check, the second call of dvb_demux_open() fails, hence > > > > the further corruption can be avoided. > > > > > > > > Also for avoiding the races of the dmxdev->exit flag reference, this > > > > patch serializes the dmxdev->exit set up and the sync waits with the > > > > dmxdev->mutex lock at dvb_dmxdev_release(). Without the mutex lock, > > > > dvb_demux_open() (or dvb_dvr_open()) may run concurrently with > > > > dvb_dmxdev_release(), which allows to skip the exit flag check and > > > > continue the open process that is being closed. > > > > > > > > Reported-by: Hyunwoo Kim > > > > Cc: > > > > Signed-off-by: Takashi Iwai > > > > > > Any review on this? > > > > > > FWIW, now CVE-2022-41218 is assigned for those bugs as a security > > > issue. > > > > A gentle ping again. > > > > Or if any other fix for this security issue is already available, > > please let me know. > > is this correct, the fix is yet missing (or was it fixed by other > means?). This patch has been re-send and has been missing for a long time: https://lore.kernel.org/linux-media/20221031100245.23702-1-tiwai@suse.de/ However, I noticed yesterday that the status of the re-send patch changed to 'accpet': https://patchwork.linuxtv.org/project/linux-media/patch/20221031100245.23702-1-tiwai@suse.de/ But there was no other feedback. Regards, Hyunwoo Kim