lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon,  3 Apr 2023 21:33:59 +0800
From:   Yangtao Li <frank.li@...o.com>
To:     linux-f2fs-devel@...ts.sourceforge.net
Cc:     chao@...nel.org, frank.li@...o.com, jaegeuk@...nel.org,
        linux-kernel@...r.kernel.org, terrelln@...com
Subject: Re: [RESEND] f2fs: add sanity compress level check for compressed file

Hi Chao,

> Why not zstd_max_clevel()?

zstd_max_clevel() is only defined when CONFIG_F2FS_FS_ZSTD is enabled,
using zstd_max_clevel() will result in compile errors otherwise.

If using the following code,

----------------------------------------------------------------------------
        switch (ri->i_compress_algorithm) {
        case COMPRESS_LZO:
        case COMPRESS_LZORLE:
                if (compress_level)
                        goto err;
                break;
        case COMPRESS_LZ4:
                if ((compress_level && compress_level < LZ4HC_MIN_CLEVEL) ||
                                compress_level > LZ4HC_MAX_CLEVEL)
                        goto err;
                break;
#ifdef CONFIG_F2FS_FS_ZSTD
        case COMPRESS_ZSTD:
                if (!compress_level || compress_level > zstd_max_clevel())
                        goto err;
                break;
#endif
        default:
                goto err;
        }
----------------------------------------------------------------------------

then we will get this result:

	F2FS-fs (loop0): sanity_check_compress_inode: inode (ino=4) has
			unsupported compress level: 0, run fsck to fix

Another way is to use the following code, which ignores the check for
level when CONFIG_F2FS_FS_ZSTD is not enabled.

----------------------------------------------------------------------------
        switch (ri->i_compress_algorithm) {
        case COMPRESS_LZO:
        case COMPRESS_LZORLE:
                if (compress_level)
                        goto err;
                break;
        case COMPRESS_LZ4:
                if ((compress_level && compress_level < LZ4HC_MIN_CLEVEL) ||
                                compress_level > LZ4HC_MAX_CLEVEL)
                        goto err;
                break;
        case COMPRESS_ZSTD:
#ifdef CONFIG_F2FS_FS_ZSTD
                if (!compress_level || compress_level > zstd_max_clevel())
                        goto err;
                break;
#else
                return true;
#endif
        default:
                goto err;
        }
----------------------------------------------------------------------------

Perhaps exporting ZSTD_MAX_CLEVEL is a better choice?

Thx,
Yangtao

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ