Merge tag 'apparmor-pr-2019-12-03' of git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor
Pull apparmor updates from John Johansen: "Features: - increase left match history buffer size to provide improved conflict resolution in overlapping execution rules. - switch buffer allocation to use a memory pool and GFP_KERNEL where possible. - add compression of policy blobs to reduce memory usage. Cleanups: - fix spelling mistake "immutible" -> "immutable" Bug fixes: - fix unsigned len comparison in update_for_len macro - fix sparse warning for type-casting of current->real_cred" * tag 'apparmor-pr-2019-12-03' of git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor: apparmor: make it so work buffers can be allocated from atomic context apparmor: reduce rcu_read_lock scope for aa_file_perm mediation apparmor: fix wrong buffer allocation in aa_new_mount apparmor: fix unsigned len comparison with less than zero apparmor: increase left match history buffer size apparmor: Switch to GFP_KERNEL where possible apparmor: Use a memory pool instead per-CPU caches apparmor: Force type-casting of current->real_cred apparmor: fix spelling mistake "immutible" -> "immutable" apparmor: fix blob compression when ns is forced on a policy load apparmor: fix missing ZLIB defines apparmor: fix blob compression build failure on ppc apparmor: Initial implementation of raw policy blob compression
This commit is contained in:
@@ -36,6 +36,7 @@ extern enum audit_mode aa_g_audit;
|
||||
extern bool aa_g_audit_header;
|
||||
extern bool aa_g_debug;
|
||||
extern bool aa_g_hash_policy;
|
||||
extern int aa_g_rawdata_compression_level;
|
||||
extern bool aa_g_lock_policy;
|
||||
extern bool aa_g_logsyscall;
|
||||
extern bool aa_g_paranoid_load;
|
||||
|
@@ -197,7 +197,7 @@ int aa_path_link(struct aa_label *label, struct dentry *old_dentry,
|
||||
const struct path *new_dir, struct dentry *new_dentry);
|
||||
|
||||
int aa_file_perm(const char *op, struct aa_label *label, struct file *file,
|
||||
u32 request);
|
||||
u32 request, bool in_atomic);
|
||||
|
||||
void aa_inherit_files(const struct cred *cred, struct files_struct *files);
|
||||
|
||||
|
@@ -134,7 +134,7 @@ unsigned int aa_dfa_matchn_until(struct aa_dfa *dfa, unsigned int start,
|
||||
|
||||
void aa_dfa_free_kref(struct kref *kref);
|
||||
|
||||
#define WB_HISTORY_SIZE 8
|
||||
#define WB_HISTORY_SIZE 24
|
||||
struct match_workbuf {
|
||||
unsigned int count;
|
||||
unsigned int pos;
|
||||
@@ -147,7 +147,6 @@ struct match_workbuf N = { \
|
||||
.count = 0, \
|
||||
.pos = 0, \
|
||||
.len = 0, \
|
||||
.size = WB_HISTORY_SIZE, \
|
||||
}
|
||||
|
||||
unsigned int aa_dfa_leftmatch(struct aa_dfa *dfa, unsigned int start,
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#ifndef __AA_PATH_H
|
||||
#define __AA_PATH_H
|
||||
|
||||
|
||||
enum path_flags {
|
||||
PATH_IS_DIR = 0x1, /* path is a directory */
|
||||
PATH_CONNECT_PATH = 0x4, /* connect disconnected paths to / */
|
||||
@@ -26,51 +25,8 @@ int aa_path_name(const struct path *path, int flags, char *buffer,
|
||||
const char **name, const char **info,
|
||||
const char *disconnected);
|
||||
|
||||
#define MAX_PATH_BUFFERS 2
|
||||
|
||||
/* Per cpu buffers used during mediation */
|
||||
/* preallocated buffers to use during path lookups */
|
||||
struct aa_buffers {
|
||||
char *buf[MAX_PATH_BUFFERS];
|
||||
};
|
||||
|
||||
#include <linux/percpu.h>
|
||||
#include <linux/preempt.h>
|
||||
|
||||
DECLARE_PER_CPU(struct aa_buffers, aa_buffers);
|
||||
|
||||
#define ASSIGN(FN, A, X, N) ((X) = FN(A, N))
|
||||
#define EVAL1(FN, A, X) ASSIGN(FN, A, X, 0) /*X = FN(0)*/
|
||||
#define EVAL2(FN, A, X, Y...) \
|
||||
do { ASSIGN(FN, A, X, 1); EVAL1(FN, A, Y); } while (0)
|
||||
#define EVAL(FN, A, X...) CONCATENATE(EVAL, COUNT_ARGS(X))(FN, A, X)
|
||||
|
||||
#define for_each_cpu_buffer(I) for ((I) = 0; (I) < MAX_PATH_BUFFERS; (I)++)
|
||||
|
||||
#ifdef CONFIG_DEBUG_PREEMPT
|
||||
#define AA_BUG_PREEMPT_ENABLED(X) AA_BUG(preempt_count() <= 0, X)
|
||||
#else
|
||||
#define AA_BUG_PREEMPT_ENABLED(X) /* nop */
|
||||
#endif
|
||||
|
||||
#define __get_buffer(C, N) ({ \
|
||||
AA_BUG_PREEMPT_ENABLED("__get_buffer without preempt disabled"); \
|
||||
(C)->buf[(N)]; })
|
||||
|
||||
#define __get_buffers(C, X...) EVAL(__get_buffer, C, X)
|
||||
|
||||
#define __put_buffers(X, Y...) ((void)&(X))
|
||||
|
||||
#define get_buffers(X...) \
|
||||
do { \
|
||||
struct aa_buffers *__cpu_var = get_cpu_ptr(&aa_buffers); \
|
||||
__get_buffers(__cpu_var, X); \
|
||||
} while (0)
|
||||
|
||||
#define put_buffers(X, Y...) \
|
||||
do { \
|
||||
__put_buffers(X, Y); \
|
||||
put_cpu_ptr(&aa_buffers); \
|
||||
} while (0)
|
||||
#define IN_ATOMIC true
|
||||
char *aa_get_buffer(bool in_atomic);
|
||||
void aa_put_buffer(char *buf);
|
||||
|
||||
#endif /* __AA_PATH_H */
|
||||
|
@@ -41,6 +41,7 @@ enum {
|
||||
AAFS_LOADDATA_REVISION,
|
||||
AAFS_LOADDATA_HASH,
|
||||
AAFS_LOADDATA_DATA,
|
||||
AAFS_LOADDATA_COMPRESSED_SIZE,
|
||||
AAFS_LOADDATA_DIR, /* must be last actual entry */
|
||||
AAFS_LOADDATA_NDENTS /* count of entries */
|
||||
};
|
||||
@@ -61,11 +62,16 @@ struct aa_loaddata {
|
||||
struct dentry *dents[AAFS_LOADDATA_NDENTS];
|
||||
struct aa_ns *ns;
|
||||
char *name;
|
||||
size_t size;
|
||||
size_t size; /* the original size of the payload */
|
||||
size_t compressed_size; /* the compressed size of the payload */
|
||||
long revision; /* the ns policy revision this caused */
|
||||
int abi;
|
||||
unsigned char *hash;
|
||||
|
||||
/* Pointer to payload. If @compressed_size > 0, then this is the
|
||||
* compressed version of the payload, else it is the uncompressed
|
||||
* version (with the size indicated by @size).
|
||||
*/
|
||||
char *data;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user