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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8363DC4332F for ; Mon, 21 Nov 2022 10:36:42 +0000 (UTC) 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 BC5A6852; Mon, 21 Nov 2022 11:35:50 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BC5A6852 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669027000; bh=Bxx1T/zA6RqhYiPCuLRzHk+VqnufHL2m6yC24UIOO1w=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=kZKuFjkG/wpR8K2LfIngDCPUyZPRlKSF0FIySRxxBQwpbyjEqAkRszR6oQRGLYwqf aE225i0QhhcLIuU6YIujc3qkGAZayAA9k5YAYRkVkzV293VVd5Tt/qW+Op9QSVJpR7 O2E+AabMrJtjf9XXAGKV3dZFF8Jr9EmWYeoeVRns= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 66198F804B1; Mon, 21 Nov 2022 11:35:50 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DB22FF804D0; Mon, 21 Nov 2022 11:35:48 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CE1EBF800F3 for ; Mon, 21 Nov 2022 11:35:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CE1EBF800F3 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="aehWRd7C"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="2kuXU/hZ" 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-out1.suse.de (Postfix) with ESMTPS id C3506220C8; Mon, 21 Nov 2022 10:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669026941; 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=dDc3A34ZNQMnuC56bsGRqp1Nz34SK07+svCjUl5Hs1A=; b=aehWRd7CYYHc/5yWJDyKtF1Ld5quSLNn1h+UBd9ZnqTgL/Wy5342b1D/7S16OmWw98M9yC KZaGwT97j9av4qE80lwutydBD3iB9uR2X/O82tYW+Yrvc/Rth9g7GxyI2zugNYpWu1/xcZ V43oMIJ2o8LqZ71vr14tSwYP0oXsLgw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669026941; 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=dDc3A34ZNQMnuC56bsGRqp1Nz34SK07+svCjUl5Hs1A=; b=2kuXU/hZf3DDLRB0Dn68AJBWjM2hInKg8VvbMnutBJji9lBrAQ6RPuz/Oh5KaEFN4OBAzk goEP6b3aUbatK2DQ== 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 A030C1376E; Mon, 21 Nov 2022 10:35:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6yRTJn1Ue2OoEwAAMHmgww (envelope-from ); Mon, 21 Nov 2022 10:35:41 +0000 Date: Mon, 21 Nov 2022 11:35:41 +0100 Message-ID: <87fsecwq6a.wl-tiwai@suse.de> From: Takashi Iwai To: Baisong Zhong Subject: Re: [PATCH -next] ALSA: seq: fix undefined behavior in bit shift for SNDRV_SEQ_FILTER_USE_EVENT In-Reply-To: <20221121043625.2910001-1-zhongbaisong@huawei.com> References: <20221121043625.2910001-1-zhongbaisong@huawei.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 Cc: alsa-devel@alsa-project.org, tiwai@suse.com, linux-kernel@vger.kernel.org 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" On Mon, 21 Nov 2022 05:36:25 +0100, Baisong Zhong wrote: > > Shifting signed 32-bit value by 31 bits is undefined, so changing > significant bit to unsigned. The UBSAN warning calltrace like below: > > UBSAN: shift-out-of-bounds in sound/core/seq/seq_clientmgr.c:509:22 > left shift of 1 by 31 places cannot be represented in type 'int' > ... > Call Trace: > > dump_stack_lvl+0x8d/0xcf > ubsan_epilogue+0xa/0x44 > __ubsan_handle_shift_out_of_bounds+0x1e7/0x208 > snd_seq_deliver_single_event.constprop.21+0x191/0x2f0 > snd_seq_deliver_event+0x1a2/0x350 > snd_seq_kernel_client_dispatch+0x8b/0xb0 > snd_seq_client_notify_subscription+0x72/0xa0 > snd_seq_ioctl_subscribe_port+0x128/0x160 > snd_seq_kernel_client_ctl+0xce/0xf0 > snd_seq_oss_create_client+0x109/0x15b > alsa_seq_oss_init+0x11c/0x1aa > do_one_initcall+0x80/0x440 > kernel_init_freeable+0x370/0x3c3 > kernel_init+0x1b/0x190 > ret_from_fork+0x1f/0x30 > > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Signed-off-by: Baisong Zhong > --- > include/uapi/sound/asequencer.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/uapi/sound/asequencer.h b/include/uapi/sound/asequencer.h > index 6d4a2c60808d..4c5c4dd15d02 100644 > --- a/include/uapi/sound/asequencer.h > +++ b/include/uapi/sound/asequencer.h > @@ -331,7 +331,7 @@ typedef int __bitwise snd_seq_client_type_t; > #define SNDRV_SEQ_FILTER_BROADCAST (1<<0) /* accept broadcast messages */ > #define SNDRV_SEQ_FILTER_MULTICAST (1<<1) /* accept multicast messages */ > #define SNDRV_SEQ_FILTER_BOUNCE (1<<2) /* accept bounce event in error */ > -#define SNDRV_SEQ_FILTER_USE_EVENT (1<<31) /* use event filter */ > +#define SNDRV_SEQ_FILTER_USE_EVENT (1U<<31) /* use event filter */ Similarly like the previous patch for PCM, could you update all SNDRV_SEQ_FILTER_* to 1U for consistency? thanks, Takashi 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A052BC433FE for ; Mon, 21 Nov 2022 10:35:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230318AbiKUKf4 (ORCPT ); Mon, 21 Nov 2022 05:35:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbiKUKfo (ORCPT ); Mon, 21 Nov 2022 05:35:44 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43FE5AEBFE for ; Mon, 21 Nov 2022 02:35:43 -0800 (PST) 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-out1.suse.de (Postfix) with ESMTPS id C3506220C8; Mon, 21 Nov 2022 10:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669026941; 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=dDc3A34ZNQMnuC56bsGRqp1Nz34SK07+svCjUl5Hs1A=; b=aehWRd7CYYHc/5yWJDyKtF1Ld5quSLNn1h+UBd9ZnqTgL/Wy5342b1D/7S16OmWw98M9yC KZaGwT97j9av4qE80lwutydBD3iB9uR2X/O82tYW+Yrvc/Rth9g7GxyI2zugNYpWu1/xcZ V43oMIJ2o8LqZ71vr14tSwYP0oXsLgw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669026941; 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=dDc3A34ZNQMnuC56bsGRqp1Nz34SK07+svCjUl5Hs1A=; b=2kuXU/hZf3DDLRB0Dn68AJBWjM2hInKg8VvbMnutBJji9lBrAQ6RPuz/Oh5KaEFN4OBAzk goEP6b3aUbatK2DQ== 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 A030C1376E; Mon, 21 Nov 2022 10:35:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6yRTJn1Ue2OoEwAAMHmgww (envelope-from ); Mon, 21 Nov 2022 10:35:41 +0000 Date: Mon, 21 Nov 2022 11:35:41 +0100 Message-ID: <87fsecwq6a.wl-tiwai@suse.de> From: Takashi Iwai To: Baisong Zhong Cc: , , , Subject: Re: [PATCH -next] ALSA: seq: fix undefined behavior in bit shift for SNDRV_SEQ_FILTER_USE_EVENT In-Reply-To: <20221121043625.2910001-1-zhongbaisong@huawei.com> References: <20221121043625.2910001-1-zhongbaisong@huawei.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 On Mon, 21 Nov 2022 05:36:25 +0100, Baisong Zhong wrote: > > Shifting signed 32-bit value by 31 bits is undefined, so changing > significant bit to unsigned. The UBSAN warning calltrace like below: > > UBSAN: shift-out-of-bounds in sound/core/seq/seq_clientmgr.c:509:22 > left shift of 1 by 31 places cannot be represented in type 'int' > ... > Call Trace: > > dump_stack_lvl+0x8d/0xcf > ubsan_epilogue+0xa/0x44 > __ubsan_handle_shift_out_of_bounds+0x1e7/0x208 > snd_seq_deliver_single_event.constprop.21+0x191/0x2f0 > snd_seq_deliver_event+0x1a2/0x350 > snd_seq_kernel_client_dispatch+0x8b/0xb0 > snd_seq_client_notify_subscription+0x72/0xa0 > snd_seq_ioctl_subscribe_port+0x128/0x160 > snd_seq_kernel_client_ctl+0xce/0xf0 > snd_seq_oss_create_client+0x109/0x15b > alsa_seq_oss_init+0x11c/0x1aa > do_one_initcall+0x80/0x440 > kernel_init_freeable+0x370/0x3c3 > kernel_init+0x1b/0x190 > ret_from_fork+0x1f/0x30 > > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Signed-off-by: Baisong Zhong > --- > include/uapi/sound/asequencer.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/uapi/sound/asequencer.h b/include/uapi/sound/asequencer.h > index 6d4a2c60808d..4c5c4dd15d02 100644 > --- a/include/uapi/sound/asequencer.h > +++ b/include/uapi/sound/asequencer.h > @@ -331,7 +331,7 @@ typedef int __bitwise snd_seq_client_type_t; > #define SNDRV_SEQ_FILTER_BROADCAST (1<<0) /* accept broadcast messages */ > #define SNDRV_SEQ_FILTER_MULTICAST (1<<1) /* accept multicast messages */ > #define SNDRV_SEQ_FILTER_BOUNCE (1<<2) /* accept bounce event in error */ > -#define SNDRV_SEQ_FILTER_USE_EVENT (1<<31) /* use event filter */ > +#define SNDRV_SEQ_FILTER_USE_EVENT (1U<<31) /* use event filter */ Similarly like the previous patch for PCM, could you update all SNDRV_SEQ_FILTER_* to 1U for consistency? thanks, Takashi