Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

apparmor: Fix undefined references to zstd_ symbols

Unfortunately the switch to using zstd compression did not properly
ifdef all the code that uses zstd_ symbols. So that if exporting of
binary policy is disabled in the config the compile will fail with the
following errors

security/apparmor/lsm.c:1545: undefined reference to `zstd_min_clevel'
aarch64-linux-ld: security/apparmor/lsm.c:1545: undefined reference to `zstd_max_clevel'

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>
Acked-by: Jon Tourville <jon.tourville@canonical.com>

+15 -5
+2 -2
security/apparmor/apparmorfs.c
··· 1202 1202 1203 1203 static int seq_ns_compress_min_show(struct seq_file *seq, void *v) 1204 1204 { 1205 - seq_printf(seq, "%d\n", zstd_min_clevel()); 1205 + seq_printf(seq, "%d\n", AA_MIN_CLEVEL); 1206 1206 return 0; 1207 1207 } 1208 1208 1209 1209 static int seq_ns_compress_max_show(struct seq_file *seq, void *v) 1210 1210 { 1211 - seq_printf(seq, "%d\n", zstd_max_clevel()); 1211 + seq_printf(seq, "%d\n", AA_MAX_CLEVEL); 1212 1212 return 0; 1213 1213 } 1214 1214
+11
security/apparmor/include/apparmor.h
··· 51 51 extern bool aa_g_paranoid_load; 52 52 extern unsigned int aa_g_path_max; 53 53 54 + #ifdef CONFIG_SECURITY_APPARMOR_EXPORT_BINARY 55 + #define AA_MIN_CLEVEL zstd_min_clevel() 56 + #define AA_MAX_CLEVEL zstd_max_clevel() 57 + #define AA_DEFAULT_CLEVEL ZSTD_CLEVEL_DEFAULT 58 + #else 59 + #define AA_MIN_CLEVEL 0 60 + #define AA_MAX_CLEVEL 0 61 + #define AA_DEFAULT_CLEVEL 0 62 + #endif /* CONFIG_SECURITY_APPARMOR_EXPORT_BINARY */ 63 + 64 + 54 65 #endif /* __APPARMOR_H */
+2 -3
security/apparmor/lsm.c
··· 1365 1365 #endif 1366 1366 1367 1367 /* policy loaddata compression level */ 1368 - int aa_g_rawdata_compression_level = ZSTD_CLEVEL_DEFAULT; 1368 + int aa_g_rawdata_compression_level = AA_DEFAULT_CLEVEL; 1369 1369 module_param_named(rawdata_compression_level, aa_g_rawdata_compression_level, 1370 1370 aacompressionlevel, 0400); 1371 1371 ··· 1547 1547 error = param_set_int(val, kp); 1548 1548 1549 1549 aa_g_rawdata_compression_level = clamp(aa_g_rawdata_compression_level, 1550 - zstd_min_clevel(), 1551 - zstd_max_clevel()); 1550 + AA_MIN_CLEVEL, AA_MAX_CLEVEL); 1552 1551 pr_info("AppArmor: policy rawdata compression level set to %d\n", 1553 1552 aa_g_rawdata_compression_level); 1554 1553