[PATCH] apparmor: replace decompress_zstd() prototype with its entity
Georgia Garcia
georgia.garcia at canonical.com
Wed Jul 15 12:14:20 UTC 2026
Hello,
On Sun, 2026-07-12 at 19:17 +0900, Tetsuo Handa wrote:
> Fix "undefined symbol: decompress_zstd" error caused by decompress_zstd()
> being guarded by CONFIG_SECURITY_APPARMOR_EXPORT_BINARY=y.
>
Acked-by: Georgia Garcia <georgia.garcia at canonical.com>
> Reported-by: syzbot+1f14a35d0c73d31555e4 at syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=1f14a35d0c73d31555e4
> Fixes: 17b5758bf35c ("apparmor: Initial support for compressed policies")
> Signed-off-by: Tetsuo Handa <penguin-kernel at I-love.SAKURA.ne.jp>
> ---
> security/apparmor/apparmorfs.c | 72 +++++++++++++++++-----------------
> 1 file changed, 36 insertions(+), 36 deletions(-)
>
> diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
> index 2ae9ab94a5a91..152c7967ff1ba 100644
> --- a/security/apparmor/apparmorfs.c
> +++ b/security/apparmor/apparmorfs.c
> @@ -483,7 +483,42 @@ static struct aa_loaddata *aa_simple_write_to_buffer(const char __user *userbuf,
>
> return data;
> }
> -static int decompress_zstd(char *src, size_t slen, char *dst, size_t dlen);
> +
> +static int decompress_zstd(char *src, size_t slen, char *dst, size_t dlen)
> +{
> + if (slen < dlen) {
> + const size_t wksp_len = zstd_dctx_workspace_bound();
> + zstd_dctx *ctx;
> + void *wksp;
> + size_t out_len;
> + int ret = 0;
> +
> + wksp = kvzalloc(wksp_len, GFP_KERNEL);
> + if (!wksp) {
> + ret = -ENOMEM;
> + goto cleanup;
> + }
> + ctx = zstd_init_dctx(wksp, wksp_len);
> + if (ctx == NULL) {
> + ret = -ENOMEM;
> + goto cleanup;
> + }
> + out_len = zstd_decompress_dctx(ctx, dst, dlen, src, slen);
> + if (zstd_is_error(out_len)) {
> + ret = -EINVAL;
> + goto cleanup;
> + }
> +cleanup:
> + kvfree(wksp);
> + return ret;
> + }
> +
> + if (dlen < slen)
> + return -EINVAL;
> + memcpy(dst, src, slen);
> + return 0;
> +}
> +
> /**
> * aa_get_data_from_compressed - common routine for getting compressed policy
> * from user and get both compressed and uncompressed version.
> @@ -1517,41 +1552,6 @@ SEQ_RAWDATA_FOPS(revision);
> SEQ_RAWDATA_FOPS(hash);
> SEQ_RAWDATA_FOPS(compressed_size);
>
> -static int decompress_zstd(char *src, size_t slen, char *dst, size_t dlen)
> -{
> - if (slen < dlen) {
> - const size_t wksp_len = zstd_dctx_workspace_bound();
> - zstd_dctx *ctx;
> - void *wksp;
> - size_t out_len;
> - int ret = 0;
> -
> - wksp = kvzalloc(wksp_len, GFP_KERNEL);
> - if (!wksp) {
> - ret = -ENOMEM;
> - goto cleanup;
> - }
> - ctx = zstd_init_dctx(wksp, wksp_len);
> - if (ctx == NULL) {
> - ret = -ENOMEM;
> - goto cleanup;
> - }
> - out_len = zstd_decompress_dctx(ctx, dst, dlen, src, slen);
> - if (zstd_is_error(out_len)) {
> - ret = -EINVAL;
> - goto cleanup;
> - }
> -cleanup:
> - kvfree(wksp);
> - return ret;
> - }
> -
> - if (dlen < slen)
> - return -EINVAL;
> - memcpy(dst, src, slen);
> - return 0;
> -}
> -
> static ssize_t rawdata_read(struct file *file, char __user *buf, size_t size,
> loff_t *ppos)
> {
More information about the Linux-security-module-archive
mailing list