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 263E5C77B7C for ; Fri, 12 May 2023 10:00:58 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3013811C; Fri, 12 May 2023 12:00:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3013811C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1683885656; bh=JbNUPB4oSNCKDmk7Abo2VzGqSrdqOLl6WBvUfg4Ly88=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=heqXPR+/bFQl0Dh/r6D/gVxZd/BvQzfb4up2zDh3TrYCQDJUEgw1jSSGaU85TADEL ZKYj2OuwG8fw8aU5/PRNU4GEM/KpQqwuzAxaAfdTK2QiXroSOtpbBm2qw7LV4ybNie GHnWLbktRh+dJ9xYT9RSZwyZ2rhN0wAcJ7v3T3Xs= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 39E0AF8053D; Fri, 12 May 2023 12:00:02 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 8F321F80087; Fri, 12 May 2023 12:00:02 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 04A37F8052E; Fri, 12 May 2023 11:59:58 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4004EF802E8 for ; Fri, 12 May 2023 11:59:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4004EF802E8 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=KbGnVdYH; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=4bC2roOA 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 79084204A2; Fri, 12 May 2023 09:59:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1683885589; 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=Z18hPfpjhOQ3bNlWRKK16HNv7/8D2OGUe1pMRkeDNBs=; b=KbGnVdYHVQsJDuoTXd/T2R/kaWqEq0lzZN1BNn89ta7P75cnr1dOsa6aQI+fv75J8AmoON ZHGHEB3JpqBBz6wUM5mywbaLgNHaNRLagLuVdbcbSNnwQYcVAfY67ttF+yKUPRGigI5c56 yOZ8z8PmwSE+LT+esRsZTSeJOaBnEAU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1683885589; 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=Z18hPfpjhOQ3bNlWRKK16HNv7/8D2OGUe1pMRkeDNBs=; b=4bC2roOAv6i3cnLh3WTBX6fhr5BNH2Wv8hcC/h2c1a+oZFqRkR57YNB3Fn1QMZpcblDlmA NlNN5OVeGSj8e+BA== 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 5740C13466; Fri, 12 May 2023 09:59:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wpAkFBUOXmQcUwAAMHmgww (envelope-from ); Fri, 12 May 2023 09:59:49 +0000 Date: Fri, 12 May 2023 11:59:48 +0200 Message-ID: <87o7mpamzv.wl-tiwai@suse.de> From: Takashi Iwai To: Oswald Buddenhagen Cc: alsa-devel@alsa-project.org, Jaroslav Kysela Subject: Re: [PATCH 07/14] ALSA: emu10k1: properly assert DSP init constraints In-Reply-To: References: <20230510173917.3073107-1-oswald.buddenhagen@gmx.de> <20230510173917.3073107-8-oswald.buddenhagen@gmx.de> <87a5yaaum2.wl-tiwai@suse.de> 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 Message-ID-Hash: WYQRCR6ICCDXQ2XXKI25X3YKQXVPQ7B2 X-Message-ID-Hash: WYQRCR6ICCDXQ2XXKI25X3YKQXVPQ7B2 X-MailFrom: tiwai@suse.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, 12 May 2023 11:25:23 +0200, Oswald Buddenhagen wrote: > > On Fri, May 12, 2023 at 09:15:17AM +0200, Takashi Iwai wrote: > > On Wed, 10 May 2023 19:39:10 +0200, > > Oswald Buddenhagen wrote: > >> > >> If these are hit, we've already trashed kernel memory by writing past > >> the end of the allocated buffer. There is no recovery from that. > >> > > Again, this is NAK. > > > First of all, if we really do care the overflow > > seriously, we should check at each increment instead of after > > breakage. It shouldn't be too difficult at all. > > > not difficult, but pointless bloat. > > > Second, using BUG_ON() like this case is an overkill. It was clearly > > stated by Linus in the past a few times (although I can't find the > > source right now). > > > you seem to have an irrational aversion against assertions, maybe > because linus likes to scream at people. Not because he's screaming but, it's because his opinion is correct regarding this. > relevant comments from linus were easy enough to find: > https://yarchive.net/comp/linux/BUG.html > https://lore.kernel.org/all/CA+55aFwyNTLuZgOWMTRuabWobF27ygskuxvFd-P0n-3UNT=0Og@mail.gmail.com/T/#u > > and there is also the documentation on BUG() itself. > > i don't see anything in either of these that would imply that my use > of BUG_ON() is inappropriate. it catches a serious programming error, > is easy to prove correct (the scope is a single function), and the > only immediate effect is that it will crash the insmod process (though > i would expect possible followup effects due to the kernel memory > corruption, which is exactly why the assert is there). i have a hard > time thinking of a *more* appropriate use for BUG(). I can't agree here at all. Sorry, but this is still NAK. The reason why BUG_ON() is bad is that it cannot allow debugging easily. It crashes and locks up, and you may not see what's going on. Do you want to catch and fix the bug? Then put the check at more proper pint that prevents the real corruption. the check is basically already too late -- it means that you might have already broken someone else's system. If the size matters, it can be a conditional build with CONFIG_SND_DEBUG, for example. But simply replacing and putting BUG_ON() makes little sense. Of course, it's just my opinion, but I won't change my mind about it. So I'm not going to discuss about this further and waste time. thanks, Takashi