linux-next: manual merge of the apparmor tree with Linus' tree

2019-06-19 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the apparmor tree got a conflict in:

  security/apparmor/include/policy.h

between commit:

  23375b13f98c ("apparmor: fix PROFILE_MEDIATES for untrusted input")

from Linus' tree and commit:

  06c13f554a71 ("apparmor: re-introduce a variant of PROFILE_MEDIATES_SAFE")

from the apparmor tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc security/apparmor/include/policy.h
index b5b4b8190e65,9af2114e1bf0..
--- a/security/apparmor/include/policy.h
+++ b/security/apparmor/include/policy.h
@@@ -213,14 -217,13 +213,22 @@@ static inline struct aa_profile *aa_get
return labels_profile(aa_get_newest_label(>label));
  }
  
 -#define PROFILE_MEDIATES(P, T)  ((P)->policy.start[(unsigned char) (T)])
 +static inline unsigned int PROFILE_MEDIATES(struct aa_profile *profile,
 +  unsigned char class)
 +{
 +  if (class <= AA_CLASS_LAST)
 +  return profile->policy.start[class];
 +  else
 +  return aa_dfa_match_len(profile->policy.dfa,
 +  profile->policy.start[0], , 1);
++}
++
+ /* safe version of POLICY_MEDIATES for full range input */
+ static inline unsigned int PROFILE_MEDIATES_SAFE(struct aa_profile *profile,
+unsigned char class)
+ {
+   return aa_dfa_match_len(profile->policy.dfa,
+   profile->policy.start[0], , 1);
  }
  
  static inline unsigned int PROFILE_MEDIATES_AF(struct aa_profile *profile,


pgpvbp5Uwea30.pgp
Description: OpenPGP digital signature


linux-next: manual merge of the apparmor tree with Linus' tree

2019-04-10 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the apparmor tree got a conflict in:

  security/apparmor/lsm.c

between commit:

  e33c1b992377 ("apparmor: Restore Y/N in /sys for apparmor's "enabled"")

from Linus' tree and commit:

  876dd866c084 ("apparmor: Initial implementation of raw policy blob 
compression")

from the apparmor tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc security/apparmor/lsm.c
index 87500bde5a92,e1e9c3c01cd3..
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@@ -25,8 -25,8 +25,9 @@@
  #include 
  #include 
  #include 
+ #include 
  #include 
 +#include 
  
  #include "include/apparmor.h"
  #include "include/apparmorfs.h"
@@@ -1420,46 -1424,37 +1436,77 @@@ static int param_get_aauint(char *buffe
return param_get_uint(buffer, kp);
  }
  
 +/* Can only be set before AppArmor is initialized (i.e. on boot cmdline). */
 +static int param_set_aaintbool(const char *val, const struct kernel_param *kp)
 +{
 +  struct kernel_param kp_local;
 +  bool value;
 +  int error;
 +
 +  if (apparmor_initialized)
 +  return -EPERM;
 +
 +  /* Create local copy, with arg pointing to bool type. */
 +  value = !!*((int *)kp->arg);
 +  memcpy(_local, kp, sizeof(kp_local));
 +  kp_local.arg = 
 +
 +  error = param_set_bool(val, _local);
 +  if (!error)
 +  *((int *)kp->arg) = *((bool *)kp_local.arg);
 +  return error;
 +}
 +
 +/*
 + * To avoid changing /sys/module/apparmor/parameters/enabled from Y/N to
 + * 1/0, this converts the "int that is actually bool" back to bool for
 + * display in the /sys filesystem, while keeping it "int" for the LSM
 + * infrastructure.
 + */
 +static int param_get_aaintbool(char *buffer, const struct kernel_param *kp)
 +{
 +  struct kernel_param kp_local;
 +  bool value;
 +
 +  /* Create local copy, with arg pointing to bool type. */
 +  value = !!*((int *)kp->arg);
 +  memcpy(_local, kp, sizeof(kp_local));
 +  kp_local.arg = 
 +
 +  return param_get_bool(buffer, _local);
 +}
 +
+ static int param_set_aacompressionlevel(const char *val,
+   const struct kernel_param *kp)
+ {
+   int error;
+ 
+   if (!apparmor_enabled)
+   return -EINVAL;
+   if (apparmor_initialized)
+   return -EPERM;
+ 
+   error = param_set_int(val, kp);
+ 
+   aa_g_rawdata_compression_level = clamp(aa_g_rawdata_compression_level,
+  Z_NO_COMPRESSION,
+  Z_BEST_COMPRESSION);
+   pr_info("AppArmor: policy rawdata compression level set to %u\n",
+   aa_g_rawdata_compression_level);
+ 
+   return error;
+ }
+ 
+ static int param_get_aacompressionlevel(char *buffer,
+   const struct kernel_param *kp)
+ {
+   if (!apparmor_enabled)
+   return -EINVAL;
+   if (apparmor_initialized && !policy_view_capable(NULL))
+   return -EPERM;
+   return param_get_int(buffer, kp);
+ }
+ 
  static int param_get_audit(char *buffer, const struct kernel_param *kp)
  {
if (!apparmor_enabled)


pgplC3V9Q_JZK.pgp
Description: OpenPGP digital signature