From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx01.bremer-it.com (mx01.bremer-it.com [85.215.132.167]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31F1236AB46 for ; Tue, 11 Aug 2026 18:20:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=85.215.132.167 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786472416; cv=none; b=r+PSOEjwEdMlv0uPsT36AlhD/vm/9QUntGLI85LxUftVsqPLL0q1xbg7fGyQ2qxIiIDNqaa+DfrWWsMYDPF6mS66ShwwPPyfcD8BD1dWa1Hgz1ofvgOWSvQh5QXXHokGiAVWt+uo6pWtSq64q5QPjH3RIhONOH3V2e9FO4g4SDI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786472416; c=relaxed/simple; bh=brp7MlTytkIjc1IKaH4I+wpXLDJ6dsucjFGbZyOD70Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GWE5PAa+9VXY7j59Cr1bhBIfoFAYD4K5vj8uGXYH8ecbxe4C6Slsw8Sl8zsP1Q826bWhyT6qQYk/Ice98KxOCEmxCBIUe2EHvMlINdkpUkuV1+c+L1CaVmLLhhu/3WVxTTv0yHF85gCx4sIWTerxTstNqZ5PyaxsHL+9+OmVt1k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=barelysecure.org; spf=pass smtp.mailfrom=barelysecure.org; dkim=pass (2048-bit key) header.d=barelysecure.org header.i=@barelysecure.org header.b=r4l0P+uy; arc=none smtp.client-ip=85.215.132.167 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=barelysecure.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=barelysecure.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=barelysecure.org header.i=@barelysecure.org header.b="r4l0P+uy" Received: from cashel.logfs.org (c-98-33-96-243.hsd1.ca.comcast.net [98.33.96.243]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mx01.bremer-it.com (Postfix) with ESMTPSA id 1B67A2CC76; Tue, 11 Aug 2026 20:19:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=barelysecure.org; s=dkim68; t=1786472402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/9pS6KtHLQ6uFM7vzTJ4cHqsIGhzdLQpbeisSsi6mKg=; b=r4l0P+uydX5qL+wKXianH+Y/pV+EJK32jDjwvm4k74mV09S6DXowJ72tytdNkZTPJaH72L K8uaCuOhX4j1cyc58mFyzQRDQENOUnq8LgTsmhXOUOSUiCBO0QglYb56FM5UZFNuFrY3Mp jsgGHHwAQrw9aGwjYVrfP8tvn+yXpbXaKlEuEpeGvydQ7UmOOawcIK4oezO3aEu1ANPTWL omOV2fmeZfaTPelDdmeoDNuSfpgRGqnuhk6lmdOVZyIioOAAnkJa8W0mMsVjiY9jQ+Ohex Pxg1otBcbgN/8RpvFz2GpN4gPxLPPNQ/CFA7XKtzBqUA86suiYwQVNoD1CUpww== Authentication-Results: ORIGINATING; auth=pass smtp.auth=joern@lazybastard.org smtp.mailfrom=joern@barelysecure.org Date: Tue, 11 Aug 2026 11:19:54 -0700 From: =?iso-8859-1?Q?J=F6rn?= Engel To: Pei Xiao Cc: Miquel Raynal , syzbot , joern@lazybastard.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, richard@nod.at, syzkaller-bugs@googlegroups.com, vigneshr@ti.com Subject: Re: [syzbot] [mtd?] divide error in block2mtd_setup2 Message-ID: References: <6a791c94.01d0871a.3a0d52.009b.GAE@google.com> <29397db9-7db4-4969-bb0e-5bb71f0c0303@kylinos.cn> <87se4mqhc3.fsf@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Level: *** X-Rspamd-Action: no action X-Spamd-Result: default: False [3.31 / 14.00]; BAYES_SPAM(1.91)[88.46%]; SUSPICIOUS_RECIPS(1.50)[]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; TAGGED_RCPT(0.00)[b320a4d5f65a61dbbf89]; FROM_HAS_DN(0.00)[]; ASN(0.00)[asn:7922, ipnet:98.32.0.0/11, country:US]; MIME_TRACE(0.00)[0:+]; MISSING_XM_UA(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; RCPT_COUNT_SEVEN(0.00)[9]; DKIM_SIGNED(0.00)[barelysecure.org:s=dkim68]; FROM_EQ_ENVFROM(0.00)[]; ALIAS_RESOLVED(0.00)[]; LOCAL_OUTBOUND(0.00)[]; URIBL_BLOCKED(0.00)[barelysecure.org:from_mime,barelysecure.org:from_smtp,c-98-33-96-243.hsd1.ca.comcast.net:rdns,cashel.logfs.org:mid,cashel.logfs.org:helo]; TO_MATCH_ENVRCPT_SOME(0.00)[]; SUBJECT_HAS_QUESTION(0.00)[] X-Rspamd-Server: server01 X-Rspamd-Queue-Id: 1B67A2CC76 X-Spamd-Bar: +++ On Tue, Aug 11, 2026 at 11:02:53AM +0800, Pei Xiao wrote: > > > Thank you for your reply. I am waiting for a reply on whether the cast > on 'long' needs to be removed. Once that is confirmed, I would be happy > to do it. Thank you. It doesn't need to be removed, but it should be removed. Any unnecessary code should be removed in general and unnecessary casts in particular should. One of better parts of the C language is that casts are hardly ever necessary. Which means that any remaining necessary casts should immediately draw attention of the reader - something tricky and potentially dangerous is going on here. But you stop paying attention when things become too common. Which means that unnecessary casts are not just noise, they actively do harm. In this particular case, we can simply test whether the cast makes any difference: #include #include int main(void) { for (int i=0; i<=1<<16; i++) { for (int k=1; k<=1<<16; k++) { long long size = (long long)i << 32; int erase_size = k; long long a = size % erase_size; long long b = (long)size % erase_size; assert(a==b); } } } Compile with optimizations and the compiler decides to remove the loop. Unless you suspect a compiler bug, I guess that settles the question. ;) Jörn -- Semper ubi sub ubi ubique. -- latin pun