From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E76F6606A322 for ; Thu, 3 Dec 2026 01:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=pa1BCpA3; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=G0OJmJB+ DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=d+6AifYqS2wNEPVjkhziJA/FPByPC77illLbjgIQJy0=; b=pa1BCpA3r2/9fElAlcU7L9wSqp 4IjdZMNu5y5vBb3IL75EV+6G+0jI9I9qRp/yYwb9JI87FYoI7eKYswQVqE3HlXTgFp5gKf3hoyg1T X04tjLSHQRdIlHafL/AN1bFZkzuKEaiIB6b//5vBpG/mSGOr/Ts/fcQRy8CRTZNopkQR57lge5Ytc caFp6SgyKiVUkIJdFzfQsoUfT8Hb5CISKZi7+PykxMQDkHFqPOkriwc4tAe4z80ueRhnDlwYp0t/n /BPbQ6US6++SzpC500XExzmW2RczOtdpRzG8ANyKDnr5vJgI9P5bRK7x2PJIcVvSKTGghoNf1VUvA vMe+082A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYvqN-0000000D9aw-0lKu; Thu, 03 Dec 2026 01:42:43 +0000 Received: from out-51.mta1.migadu.com ([2001:41d0:203:375::33] helo=mta1.migadu.com) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYvqJ-0000000D9aY-19GJ for linux-mtd@lists.infradead.org; Thu, 03 Dec 2026 01:42:41 +0000 X-Envelope-To: linux-mtd@lists.infradead.org DKIM-Signature: a=rsa-sha256; bh=ZRxHb8Ei0of2Gc45E4zZn00SlAS390hi0PP4sfvvFO8=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796262155; v=1; x=1796866955; b=G0OJmJB+QK6SlWdTNkzWT7AhQb/d1jUIzVZqk13QbaC16NGaYF+fqpoYvm+NpQK9W6aUzYyy nteLDbFb/xz8s3UhuLNFxkDFXDbNyRoj/BiINepGovnjzRZF7eiUdTEF0zkbv0k3olFx2zONL6a ZU9IoR6JAGKl3DYLkPtHEwvQ= X-Envelope-To: linux-mtd@lists.infradead.org Received: by smtp.migadu.com with ESMTPS id 0a0ad2bf8c9d60e9; Thu, 03 Dec 2026 01:42:35 +0000 X-Mizu-Trace-ID: 0a0ad2bf8c9d60e9 X-Migadu-Flow: FLOW_OUT Message-ID: <86ccd302-3545-46c9-9b5f-f20c949605a6@linux.dev> Date: Thu, 3 Dec 2026 02:42:30 +0100 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RESEND] jffs2: return -EIO when a decompressor reports failure To: Karthikeyan KS , Richard Weinberger Cc: linux-mtd@lists.infradead.org, David Woodhouse References: <20261202142144.6358-1-karthiproffesional@gmail.com> Content-Language: en-US From: Haris Iqbal In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261202_174239_484170_278D2F8F X-CRM114-Status: GOOD ( 17.07 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-mtd" X-Spam-Status: No, score=-10.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On 12/2/26 15:29, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 1 potential > issue to consider: > - [Medium] jffs2: jffs2_decompress() leaks -1 (-EPERM) from > jffs2_lzo_decompress() > It also noticed 1 related pre-existing issue this patch does not > introduce: > - [Critical] jffs2: ignored zlib_inflate() failure in > jffs2_zlib_decompress() [1] > -- > > commit ca29ca73ec2076d4b1f555f86e52826b3a10f925 > Author: Karthikeyan KS > > jffs2: return -EIO when a decompressor reports failure > > This commit converts positive return values from JFFS2 decompressors into > -EIO in jffs2_decompress() so callers receive a negative errno on > decompression failure. > >> diff --git a/fs/jffs2/compr.c b/fs/jffs2/compr.c >> index 764f19dec3f0f..da317ed3ccdbc 100644 >> --- a/fs/jffs2/compr.c >> +++ b/fs/jffs2/compr.c >> @@ -288,6 +288,8 @@ int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, >> } >> this->usecount--; >> spin_unlock(&jffs2_compressor_list_lock); >> + if (ret > 0) >> + ret = -EIO; >> return ret; > > [Severity: Medium] > Should this convert all non-zero ret values to -EIO instead of only > ret > 0? > > jffs2_lzo_decompress() returns a literal -1 on decompression failure rather > than a negative errno: > > fs/jffs2/compr_lzo.c:jffs2_lzo_decompress() { > ret = lzo1x_decompress_safe(data_in, srclen, cpage_out, &dl); > > if (ret != LZO_E_OK || dl != destlen) > return -1; > > return 0; > } > > Leaving negative values unchanged causes a corrupted LZO node to propagate > -1 (-EPERM) through jffs2_read_dnode() to the page cache and userspace > instead of -EIO. None of the registered JFFS2 decompressors return a > meaningful errno code. This looks like a fair point. Converting -1 to -EIO too would be a better approach IMHO, since it seems each compressor chose its own "non-zero means failed" value. > > [Severity: Critical] > This problem wasn't introduced by this patch, but jffs2_zlib_decompress() > ignores zlib_inflate() errors [1] and returns 0 to jffs2_decompress(): > > fs/jffs2/compr_zlib.c:jffs2_zlib_decompress() { > ... > while((ret = zlib_inflate(&inf_strm, Z_FINISH)) == Z_OK) > ; > if (ret != Z_STREAM_END) { > pr_notice("inflate returned %d\n", ret); > } > zlib_inflateEnd(&inf_strm); > mutex_unlock(&inflate_mutex); > return 0; > } > > When a zlib node passes zlib_inflateInit2() but fails during > zlib_inflate(), jffs2_decompress() reports success to jffs2_read_dnode(), > exposing uninitialized page cache or heap memory as valid file data and > writing it back to flash during garbage collection. > > [1] https://sashiko.dev/#/bug/linux-40d97206-24d1-4353-814c-da3322334b46 > ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/