Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2720615rdb; Tue, 12 Sep 2023 10:01:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEebPqySeEbspQ23c+IG6VSdwqC+4dZexr+ZraARJVVTjj9vnJwUXKSbvcOECQf512TXCS5 X-Received: by 2002:a17:903:2303:b0:1c3:4361:ca18 with SMTP id d3-20020a170903230300b001c34361ca18mr394369plh.5.1694538112086; Tue, 12 Sep 2023 10:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694538112; cv=none; d=google.com; s=arc-20160816; b=hkWc0GTGyVboPJvLnSIwiJAAv/46y5D3FgtsjydeE40CdXXI+dzBMkEjM2fKIgo+jc ZhcAVFDjFSQNaw2C0XjYGC7L823ykv+1UDBk20rXFjklsUnH0/TiAyuKP7beU/RqYZn0 tdnbFH9EV8qJEe55MlDN1/lZls03rouPkQw+8fEzFBVPtHMv1m98mSCEAEs+SMkVtR1c uA8Fbx08mb26InBb81e95fXsH3jliRQBpAcaGliKXPUT8B9pGzAmlIUfdk3m4lv5GJMY lBa5gXNcV87+BzdMtwdYp7PGglYP5ojac/+EO7blPvz5B8zdt7BdCm1N6cUi4nsBY1Vp xWkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=KyBRNaYAj1FKVpZu9HTV7I7nxJWl2NPUn/LfwzF1WeI=; fh=JwP5VvDyf1JAao0QMwAt2ZX7BAA1s9TgtKSbSwpFvZ8=; b=Cm/iqIbzXTn4KaurVLiLAC2COdNSuQ9OTXd0CMXONH74sXHFeMygGCkrpQydRSec7q DSMZSQypdOdewRRAVpsm7f/PszgkuQyGKhzGokL6uC4kxYbZJlijo2ZHyNY3JKKljMt9 i9TXTHUqnz848bZr8DmeFEOJ7bN1CZQP4ArsTblnZ2hAsjSKsF2FmWjlqBLZ2t6epT32 rxLGAXgklBt8+2zD+PMhB56KfBT9sW8P7N0UZB/6vU/sxUviVdlQXQnZEIkxpL8Rbf0N 1pUEPzvKADUlceyfOCKMfAJPiAfYEUlyRRffw1lY0JHwwfL6B23J48VP7h3h5ZwmTmMU X5DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=eW1YZYxL; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=yKM33t8E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id k66-20020a632445000000b0054ff717395dsi8179554pgk.691.2023.09.12.10.01.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:01:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=eW1YZYxL; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=yKM33t8E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 7271580811EF; Tue, 12 Sep 2023 01:50:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232880AbjILIu3 (ORCPT + 99 others); Tue, 12 Sep 2023 04:50:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232650AbjILIu2 (ORCPT ); Tue, 12 Sep 2023 04:50:28 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CA78E79 for ; Tue, 12 Sep 2023 01:50:24 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 56B191F85D; Tue, 12 Sep 2023 08:50:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1694508623; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=KyBRNaYAj1FKVpZu9HTV7I7nxJWl2NPUn/LfwzF1WeI=; b=eW1YZYxLFqxyWkULT6ZYZrK3h/QcYe+vuzo+A5rmti1vihVjukYpzwz0+Gr0kPWGrXx3JG BowZ6Sad+tkbiDlYbYRAm9A/v1FpfJwMVJFhNrlEl4klsuFKV72hurstQMIPAWAT1CCfEM Nh1QDJVu1KqrOnUilB/A4vuQ99gKOK4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1694508623; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=KyBRNaYAj1FKVpZu9HTV7I7nxJWl2NPUn/LfwzF1WeI=; b=yKM33t8EHd+XHmiR+zbPECsds0tfw8Jgv5kxkR4URSa4w32uf1pdsQsVeebl9tVtyHy3N3 cFYGvoKjbVnhduDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 19703139DB; Tue, 12 Sep 2023 08:50:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 5+cNBU8mAGWhJgAAMHmgww (envelope-from ); Tue, 12 Sep 2023 08:50:23 +0000 Date: Tue, 12 Sep 2023 10:50:22 +0200 Message-ID: <87o7i77p2p.wl-tiwai@suse.de> From: Takashi Iwai To: Ma Ke Cc: perex@perex.cz, tiwai@suse.com, cujomalainey@chromium.org, maciej.szmigiero@oracle.com, clecigne@google.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: control: do not access controls without possession of r_w lock In-Reply-To: <20230912084530.3307329-1-make_ruc2021@163.com> References: <20230912084530.3307329-1-make_ruc2021@163.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 12 Sep 2023 01:50:34 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email On Tue, 12 Sep 2023 10:45:30 +0200, Ma Ke wrote: > > we should not access any of its memory when we don't ensure possession of > a read/write lock. Otherwise we risk a use after free access, which allows > local users to cause a denial of service and obtain sensitive information > from kernel memory. This function is called always under card->controls_rwsem. So it should be OK as is. thanks, Takashi > > Signed-off-by: Ma Ke > --- > sound/core/control.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/sound/core/control.c b/sound/core/control.c > index 59c8658966d4..98782cc68ee1 100644 > --- a/sound/core/control.c > +++ b/sound/core/control.c > @@ -590,7 +590,8 @@ static int __snd_ctl_remove(struct snd_card *card, > remove_hash_entries(card, kcontrol); > > card->controls_count -= kcontrol->count; > - for (idx = 0; idx < kcontrol->count; idx++) > + count = kcontrol->count; > + for (idx = 0; idx < count; idx++) > snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_REMOVE, kcontrol, idx); > snd_ctl_free_one(kcontrol); > return 0; > -- > 2.37.2 >