From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 AA53BC433DB for ; Mon, 25 Jan 2021 13:46:53 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E707C22240 for ; Mon, 25 Jan 2021 13:46:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E707C22240 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 33DC31811; Mon, 25 Jan 2021 14:45:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 33DC31811 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1611582408; bh=qv6ER03s/vXRq8P86GnTOjLvrlOzf4L7pYE/3Qz8XBI=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=rcMVxGQM4prvC7grYDYDd+Y0IFU+ccVsw/BDj6e9l3kkoZLFqtcoBHEXrALgXnO4A VktyZwV/ARDWX37UJCQdey7W1m5z6wOX8OjNP8PGa3JYCmgbQr/nd31vrx5Yc51TMy MwOhtZsBTQhOa9STW7VDlwEq671mwGTgslVPtm2E= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 96212F80218; Mon, 25 Jan 2021 14:45:57 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 464C8F80259; Mon, 25 Jan 2021 14:45:56 +0100 (CET) Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E381FF8014D for ; Mon, 25 Jan 2021 14:45:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E381FF8014D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="XeBuGdCX"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="U9ckwXdK" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 73F90E0E; Mon, 25 Jan 2021 08:45:44 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 25 Jan 2021 08:45:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=jcnbIZnzrAyhZeu+iL5n+9DJk/q 4Dov63HrOKt1Hkzc=; b=XeBuGdCXGvqdzN20sTHzb18g7T6vxXBRAAzvFKmtrZ3 f3CKAj0ZsqHSGfEY6YpASd6SpqneUl0Nu7sGi07SjHax6sFBliG5ii90PVAopNRQ nap604rcJ+1aWhyuzvauiIP6PhA5yxB4MFIzN616u/SLKUtg7wPHeygyPE3coM2w PcB/O3jlWTiXqhW1zQUk0xeSdvNUTmkHqAfGsz3MymLLE/2q/wjwUa69as2JMxs3 c+SAly97lhDIExFSqwTS2+C0WLhIzOkMs9h/Gvi/6TI9/QjyyNT1GsMj0V3Bf0lh tkq2becnDnQgz4w4DrsNjV/GjY4zgv3lGT0/VmLbjWA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=jcnbIZ nzrAyhZeu+iL5n+9DJk/q4Dov63HrOKt1Hkzc=; b=U9ckwXdK3O1Z3pVS3gmpmN hb2tb8S5HbXCck2219KdKgJJtpmwfkpsKFodA9ZPsQ/VA2ow5o/X3EL/7xWqgc/e OoRGN85btZSxDjkFL8nMH7u492WWV/wFXCYo560NVotKWLOFfu6fG8jb4AhigJxh 8QSGcfzFpM6hGoHfm3ZdP2W7J1xXJMkSlToAyCr6kRpyhCejreK9Rfbi3H3XjArH oQ1/FsZjXx0w48BeBVTU7AaObibFoMBT2378IudREUubVKdgikESfse/EhcOqVod rl4HEQBfZUIDSxX/WbVkL1LhHq0CmdOoZfVBEz+mdRtF43Y+FhII941iXIdo8ZLg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdefgdehfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepvfgrkhgrshhh ihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph eqnecuggftrfgrthhtvghrnheplefhueegvdejgfejgfdukeefudetvddtuddtueeivedt tdegteejkedvfeegfefhnecukfhppeduudekrddvgeefrdejkedrheeknecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihes shgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation (y078058.dynamic.ppp.asahi-net.or.jp [118.243.78.58]) by mail.messagingengine.com (Postfix) with ESMTPA id D4BFC1080063; Mon, 25 Jan 2021 08:45:40 -0500 (EST) Date: Mon, 25 Jan 2021 22:45:38 +0900 From: Takashi Sakamoto To: Dan Carpenter Subject: Re: [PATCH v2 2/2] ALSA: fireface: remove unnecessary condition in hwdep_read() Message-ID: <20210125134538.GA24062@workstation> Mail-Followup-To: Dan Carpenter , Clemens Ladisch , Christophe JAILLET , Jaroslav Kysela , Takashi Iwai , Mark Brown , alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org References: <20210122071354.GI20820@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org, Clemens Ladisch , Takashi Iwai , Mark Brown , Christophe JAILLET X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Hi, On Mon, Jan 25, 2021 at 02:13:44PM +0300, Dan Carpenter wrote: > Smatch complains that "count" is not clamped when "ff->dev_lock_changed" > and it leads to an information leak. Fortunately, that's not actually > possible and the condition can be deleted. > > Signed-off-by: Dan Carpenter > --- > v2: just delet the condition > > sound/firewire/fireface/ff-hwdep.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) Acked-by: Takashi Sakamoto ALSA firewire stack includes some drivers. Although some of them implement unique event as well as the lock event, the others supports the lock event only. The condition statement comes from the former, I guess. ALSA BeBoB, OXFW, and Fireface drivers are the latter. Later I'll post the similar patch for ALSA BeBoB driver. Anyway, thank you to find the issue ;) > diff --git a/sound/firewire/fireface/ff-hwdep.c b/sound/firewire/fireface/ff-hwdep.c > index 4b2e0dff5ddb..ea64a2a41eea 100644 > --- a/sound/firewire/fireface/ff-hwdep.c > +++ b/sound/firewire/fireface/ff-hwdep.c > @@ -35,13 +35,11 @@ static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, > } > > memset(&event, 0, sizeof(event)); > - if (ff->dev_lock_changed) { > - event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS; > - event.lock_status.status = (ff->dev_lock_count > 0); > - ff->dev_lock_changed = false; > + event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS; > + event.lock_status.status = (ff->dev_lock_count > 0); > + ff->dev_lock_changed = false; > > - count = min_t(long, count, sizeof(event.lock_status)); > - } > + count = min_t(long, count, sizeof(event.lock_status)); > > spin_unlock_irq(&ff->lock); > > -- > 2.29.2 Thanks Takashi Sakamoto From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Sakamoto Date: Mon, 25 Jan 2021 13:45:38 +0000 Subject: Re: [PATCH v2 2/2] ALSA: fireface: remove unnecessary condition in hwdep_read() Message-Id: <20210125134538.GA24062@workstation> List-Id: References: <20210122071354.GI20820@kadam> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Dan Carpenter Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org, Clemens Ladisch , Takashi Iwai , Mark Brown , Christophe JAILLET Hi, On Mon, Jan 25, 2021 at 02:13:44PM +0300, Dan Carpenter wrote: > Smatch complains that "count" is not clamped when "ff->dev_lock_changed" > and it leads to an information leak. Fortunately, that's not actually > possible and the condition can be deleted. > > Signed-off-by: Dan Carpenter > --- > v2: just delet the condition > > sound/firewire/fireface/ff-hwdep.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) Acked-by: Takashi Sakamoto ALSA firewire stack includes some drivers. Although some of them implement unique event as well as the lock event, the others supports the lock event only. The condition statement comes from the former, I guess. ALSA BeBoB, OXFW, and Fireface drivers are the latter. Later I'll post the similar patch for ALSA BeBoB driver. Anyway, thank you to find the issue ;) > diff --git a/sound/firewire/fireface/ff-hwdep.c b/sound/firewire/fireface/ff-hwdep.c > index 4b2e0dff5ddb..ea64a2a41eea 100644 > --- a/sound/firewire/fireface/ff-hwdep.c > +++ b/sound/firewire/fireface/ff-hwdep.c > @@ -35,13 +35,11 @@ static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, > } > > memset(&event, 0, sizeof(event)); > - if (ff->dev_lock_changed) { > - event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS; > - event.lock_status.status = (ff->dev_lock_count > 0); > - ff->dev_lock_changed = false; > + event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS; > + event.lock_status.status = (ff->dev_lock_count > 0); > + ff->dev_lock_changed = false; > > - count = min_t(long, count, sizeof(event.lock_status)); > - } > + count = min_t(long, count, sizeof(event.lock_status)); > > spin_unlock_irq(&ff->lock); > > -- > 2.29.2 Thanks Takashi Sakamoto