apparmor: make sure the decompression ctx is promperly initialized
authorJohn Johansen <john.johansen@canonical.com>
Sun, 25 Sep 2022 22:36:45 +0000 (15:36 -0700)
committerJohn Johansen <john.johansen@canonical.com>
Mon, 3 Oct 2022 21:49:04 +0000 (14:49 -0700)
The decompress ctx was not properly initialized when reading raw
profile data back to userspace.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: 52ccc20c652b ("apparmor: use zstd compression for profile data")
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/apparmorfs.c

index f6d83ffde3c42f8ea7e651e0a447673fd31415a9..ddd64b8ebf05ea16f5a2dc06b2d06e6884b147e2 100644 (file)
@@ -1327,7 +1327,11 @@ static int decompress_zstd(char *src, size_t slen, char *dst, size_t dlen)
                        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;