mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 22:14:03 +02:00
apparmor: replace decompress_zstd() prototype with its entity
Fix "undefined symbol: decompress_zstd" error caused by decompress_zstd()
being guarded by CONFIG_SECURITY_APPARMOR_EXPORT_BINARY=y.
Reported-by: syzbot+1f14a35d0c73d31555e4@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1f14a35d0c73d31555e4
Fixes: 17b5758bf3 ("apparmor: Initial support for compressed policies")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
dda61023f9
commit
c431011ab6
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user