1. 06 11月, 2018 1 次提交
  2. 02 11月, 2018 2 次提交
  3. 26 10月, 2018 3 次提交
    • D
    • D
      KEYS: trusted: Expose common functionality [ver #2] · e1ea9f86
      Denis Kenzior 提交于
      This patch exposes some common functionality needed to send TPM commands.
      Several functions from keys/trusted.c are exposed for use by the new tpm
      key subtype and a module dependency is introduced.
      
      In the future, common functionality between the trusted key type and the
      asym_tpm subtype should be factored out into a common utility library.
      Signed-off-by: NDenis Kenzior <denkenz@gmail.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Tested-by: NMarcel Holtmann <marcel@holtmann.org>
      Reviewed-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJames Morris <james.morris@microsoft.com>
      e1ea9f86
    • D
      KEYS: Provide keyctls to drive the new key type ops for asymmetric keys [ver #2] · 00d60fd3
      David Howells 提交于
      Provide five keyctl functions that permit userspace to make use of the new
      key type ops for accessing and driving asymmetric keys.
      
       (*) Query an asymmetric key.
      
      	long keyctl(KEYCTL_PKEY_QUERY,
      		    key_serial_t key, unsigned long reserved,
      		    struct keyctl_pkey_query *info);
      
           Get information about an asymmetric key.  The information is returned
           in the keyctl_pkey_query struct:
      
      	__u32	supported_ops;
      
           A bit mask of flags indicating which ops are supported.  This is
           constructed from a bitwise-OR of:
      
      	KEYCTL_SUPPORTS_{ENCRYPT,DECRYPT,SIGN,VERIFY}
      
      	__u32	key_size;
      
           The size in bits of the key.
      
      	__u16	max_data_size;
      	__u16	max_sig_size;
      	__u16	max_enc_size;
      	__u16	max_dec_size;
      
           The maximum sizes in bytes of a blob of data to be signed, a signature
           blob, a blob to be encrypted and a blob to be decrypted.
      
           reserved must be set to 0.  This is intended for future use to hand
           over one or more passphrases needed unlock a key.
      
           If successful, 0 is returned.  If the key is not an asymmetric key,
           EOPNOTSUPP is returned.
      
       (*) Encrypt, decrypt, sign or verify a blob using an asymmetric key.
      
      	long keyctl(KEYCTL_PKEY_ENCRYPT,
      		    const struct keyctl_pkey_params *params,
      		    const char *info,
      		    const void *in,
      		    void *out);
      
      	long keyctl(KEYCTL_PKEY_DECRYPT,
      		    const struct keyctl_pkey_params *params,
      		    const char *info,
      		    const void *in,
      		    void *out);
      
      	long keyctl(KEYCTL_PKEY_SIGN,
      		    const struct keyctl_pkey_params *params,
      		    const char *info,
      		    const void *in,
      		    void *out);
      
      	long keyctl(KEYCTL_PKEY_VERIFY,
      		    const struct keyctl_pkey_params *params,
      		    const char *info,
      		    const void *in,
      		    const void *in2);
      
           Use an asymmetric key to perform a public-key cryptographic operation
           a blob of data.
      
           The parameter block pointed to by params contains a number of integer
           values:
      
      	__s32		key_id;
      	__u32		in_len;
      	__u32		out_len;
      	__u32		in2_len;
      
           For a given operation, the in and out buffers are used as follows:
      
      	Operation ID		in,in_len	out,out_len	in2,in2_len
      	=======================	===============	===============	===========
      	KEYCTL_PKEY_ENCRYPT	Raw data	Encrypted data	-
      	KEYCTL_PKEY_DECRYPT	Encrypted data	Raw data	-
      	KEYCTL_PKEY_SIGN	Raw data	Signature	-
      	KEYCTL_PKEY_VERIFY	Raw data	-		Signature
      
           info is a string of key=value pairs that supply supplementary
           information.
      
           The __spare space in the parameter block must be set to 0.  This is
           intended, amongst other things, to allow the passing of passphrases
           required to unlock a key.
      
           If successful, encrypt, decrypt and sign all return the amount of data
           written into the output buffer.  Verification returns 0 on success.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Tested-by: NMarcel Holtmann <marcel@holtmann.org>
      Reviewed-by: NMarcel Holtmann <marcel@holtmann.org>
      Reviewed-by: NDenis Kenzior <denkenz@gmail.com>
      Tested-by: NDenis Kenzior <denkenz@gmail.com>
      Signed-off-by: NJames Morris <james.morris@microsoft.com>
      00d60fd3
  4. 19 10月, 2018 2 次提交
  5. 13 10月, 2018 1 次提交
    • A
      apparmor: add #ifdef checks for secmark filtering · e1af4779
      Arnd Bergmann 提交于
      The newly added code fails to build when either SECMARK or
      NETFILTER are disabled:
      
      security/apparmor/lsm.c: In function 'apparmor_socket_sock_rcv_skb':
      security/apparmor/lsm.c:1138:12: error: 'struct sk_buff' has no member named 'secmark'; did you mean 'mark'?
      
      security/apparmor/lsm.c:1671:21: error: 'struct nf_hook_state' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
      
      Add a set of #ifdef checks around it to only enable the code that
      we can compile and that makes sense in that configuration.
      
      Fixes: ab9f2115 ("apparmor: Allow filtering based on secmark policy")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      e1af4779
  6. 11 10月, 2018 12 次提交
  7. 03 10月, 2018 7 次提交
    • E
      signal: Distinguish between kernel_siginfo and siginfo · ae7795bc
      Eric W. Biederman 提交于
      Linus recently observed that if we did not worry about the padding
      member in struct siginfo it is only about 48 bytes, and 48 bytes is
      much nicer than 128 bytes for allocating on the stack and copying
      around in the kernel.
      
      The obvious thing of only adding the padding when userspace is
      including siginfo.h won't work as there are sigframe definitions in
      the kernel that embed struct siginfo.
      
      So split siginfo in two; kernel_siginfo and siginfo.  Keeping the
      traditional name for the userspace definition.  While the version that
      is used internally to the kernel and ultimately will not be padded to
      128 bytes is called kernel_siginfo.
      
      The definition of struct kernel_siginfo I have put in include/signal_types.h
      
      A set of buildtime checks has been added to verify the two structures have
      the same field offsets.
      
      To make it easy to verify the change kernel_siginfo retains the same
      size as siginfo.  The reduction in size comes in a following change.
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      ae7795bc
    • Z
      apparmor: Fix uninitialized value in aa_split_fqname · 250f2da4
      Zubin Mithra 提交于
      Syzkaller reported a OOB-read with the stacktrace below. This occurs
      inside __aa_lookupn_ns as `n` is not initialized. `n` is obtained from
      aa_splitn_fqname. In cases where `name` is invalid, aa_splitn_fqname
      returns without initializing `ns_name` and `ns_len`.
      
      Fix this by always initializing `ns_name` and `ns_len`.
      
      	__dump_stack lib/dump_stack.c:77 [inline]
      	dump_stack+0x1c4/0x2b4 lib/dump_stack.c:113
      	print_address_description.cold.8+0x9/0x1ff mm/kasan/report.c:256
      	kasan_report_error mm/kasan/report.c:354 [inline]
      	kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412
      	__asan_report_load1_noabort+0x14/0x20 mm/kasan/report.c:430
      	memcmp+0xe3/0x160 lib/string.c:861
      	strnstr+0x4b/0x70 lib/string.c:934
      	__aa_lookupn_ns+0xc1/0x570 security/apparmor/policy_ns.c:209
      	aa_lookupn_ns+0x88/0x1e0 security/apparmor/policy_ns.c:240
      	aa_fqlookupn_profile+0x1b9/0x1010 security/apparmor/policy.c:468
      	fqlookupn_profile+0x80/0xc0 security/apparmor/label.c:1844
      	aa_label_strn_parse+0xa3a/0x1230 security/apparmor/label.c:1908
      	aa_label_parse+0x42/0x50 security/apparmor/label.c:1943
      	aa_change_profile+0x513/0x3510 security/apparmor/domain.c:1362
      	apparmor_setprocattr+0xaa4/0x1150 security/apparmor/lsm.c:658
      	security_setprocattr+0x66/0xc0 security/security.c:1298
      	proc_pid_attr_write+0x301/0x540 fs/proc/base.c:2555
      	__vfs_write+0x119/0x9f0 fs/read_write.c:485
      	vfs_write+0x1fc/0x560 fs/read_write.c:549
      	ksys_write+0x101/0x260 fs/read_write.c:598
      	__do_sys_write fs/read_write.c:610 [inline]
      	__se_sys_write fs/read_write.c:607 [inline]
      	__x64_sys_write+0x73/0xb0 fs/read_write.c:607
      	do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
      	entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      Fixes: 3b0aaf58 ("apparmor: add lib fn to find the "split" for fqnames")
      Reported-by: syzbot+61e4b490d9d2da591b50@syzkaller.appspotmail.com
      Signed-off-by: NZubin Mithra <zsm@chromium.org>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      250f2da4
    • J
      apparmor: don't try to replace stale label in ptraceme check · ca3fde52
      Jann Horn 提交于
      begin_current_label_crit_section() must run in sleepable context because
      when label_is_stale() is true, aa_replace_current_label() runs, which uses
      prepare_creds(), which can sleep.
      
      Until now, the ptraceme access check (which runs with tasklist_lock held)
      violated this rule.
      
      Fixes: b2d09ae4 ("apparmor: move ptrace checks to using labels")
      Reported-by: NCyrill Gorcunov <gorcunov@gmail.com>
      Reported-by: Nkernel test robot <rong.a.chen@intel.com>
      Signed-off-by: NJann Horn <jannh@google.com>
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      ca3fde52
    • L
      apparmor: Replace spin_is_locked() with lockdep · 0fb871cc
      Lance Roy 提交于
      lockdep_assert_held() is better suited to checking locking requirements,
      since it won't get confused when someone else holds the lock. This is
      also a step towards possibly removing spin_is_locked().
      Signed-off-by: NLance Roy <ldr709@gmail.com>
      Cc: John Johansen <john.johansen@canonical.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Cc: <linux-security-module@vger.kernel.org>
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      0fb871cc
    • M
      apparmor: Allow filtering based on secmark policy · ab9f2115
      Matthew Garrett 提交于
      Add support for dropping or accepting packets based on their secmark
      tags.
      Signed-off-by: NMatthew Garrett <mjg59@google.com>
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      ab9f2115
    • M
      apparmor: Parse secmark policy · 9caafbe2
      Matthew Garrett 提交于
      Add support for parsing secmark policy provided by userspace, and
      store that in the overall policy.
      Signed-off-by: NMatthew Garrett <mjg59@google.com>
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      9caafbe2
    • M
      apparmor: Add a wildcard secid · 617a629c
      Matthew Garrett 提交于
      Reserve a secid value that we can use as a wildcard, allowing us to
      define policy that's expected to match against all secids.
      Signed-off-by: NMatthew Garrett <mjg59@google.com>
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      617a629c
  8. 25 9月, 2018 1 次提交
  9. 19 9月, 2018 3 次提交
  10. 14 9月, 2018 3 次提交
  11. 08 9月, 2018 1 次提交
    • T
      apparmor: Fix network performance issue in aa_label_sk_perm · 5f997580
      Tony Jones 提交于
      The netperf benchmark shows a 5.73% reduction in throughput for
      small (64 byte) transfers by unconfined tasks.
      
      DEFINE_AUDIT_SK() in aa_label_sk_perm() should not be performed
      unconditionally, rather only when the label is confined.
      
      netperf-tcp
                                  56974a6f^              56974a6f
      Min       64         563.48 (   0.00%)      531.17 (  -5.73%)
      Min       128       1056.92 (   0.00%)      999.44 (  -5.44%)
      Min       256       1945.95 (   0.00%)     1867.97 (  -4.01%)
      Min       1024      6761.40 (   0.00%)     6364.23 (  -5.87%)
      Min       2048     11110.53 (   0.00%)    10606.20 (  -4.54%)
      Min       3312     13692.67 (   0.00%)    13158.41 (  -3.90%)
      Min       4096     14926.29 (   0.00%)    14457.46 (  -3.14%)
      Min       8192     18399.34 (   0.00%)    18091.65 (  -1.67%)
      Min       16384    21384.13 (   0.00%)    21158.05 (  -1.06%)
      Hmean     64         564.96 (   0.00%)      534.38 (  -5.41%)
      Hmean     128       1064.42 (   0.00%)     1010.12 (  -5.10%)
      Hmean     256       1965.85 (   0.00%)     1879.16 (  -4.41%)
      Hmean     1024      6839.77 (   0.00%)     6478.70 (  -5.28%)
      Hmean     2048     11154.80 (   0.00%)    10671.13 (  -4.34%)
      Hmean     3312     13838.12 (   0.00%)    13249.01 (  -4.26%)
      Hmean     4096     15009.99 (   0.00%)    14561.36 (  -2.99%)
      Hmean     8192     18975.57 (   0.00%)    18326.54 (  -3.42%)
      Hmean     16384    21440.44 (   0.00%)    21324.59 (  -0.54%)
      Stddev    64           1.24 (   0.00%)        2.85 (-130.64%)
      Stddev    128          4.51 (   0.00%)        6.53 ( -44.84%)
      Stddev    256         11.67 (   0.00%)        8.50 (  27.16%)
      Stddev    1024        48.33 (   0.00%)       75.07 ( -55.34%)
      Stddev    2048        54.82 (   0.00%)       65.16 ( -18.86%)
      Stddev    3312       153.57 (   0.00%)       56.29 (  63.35%)
      Stddev    4096       100.25 (   0.00%)       88.50 (  11.72%)
      Stddev    8192       358.13 (   0.00%)      169.99 (  52.54%)
      Stddev    16384       43.99 (   0.00%)      141.82 (-222.39%)
      Signed-off-by: NTony Jones <tonyj@suse.de>
      Fixes: 56974a6f ("apparmor: add base infastructure for socket
      mediation")
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      5f997580
  12. 06 9月, 2018 1 次提交
    • J
      selinux: refactor mls_context_to_sid() and make it stricter · 95ffe194
      Jann Horn 提交于
      The intended behavior change for this patch is to reject any MLS strings
      that contain (trailing) garbage if p->mls_enabled is true.
      
      As suggested by Paul Moore, change mls_context_to_sid() so that the two
      parts of the range are extracted before the rest of the parsing. Because
      now we don't have to scan for two different separators simultaneously
      everywhere, we can actually switch to strchr() everywhere instead of the
      open-coded loops that scan for two separators at once.
      
      mls_context_to_sid() used to signal how much of the input string was parsed
      by updating `*scontext`. However, there is actually no case in which
      mls_context_to_sid() only parses a subset of the input and still returns
      a success (other than the buggy case with a second '-' in which it
      incorrectly claims to have consumed the entire string). Turn `scontext`
      into a simple pointer argument and stop redundantly checking whether the
      entire input was consumed in string_to_context_struct(). This also lets us
      remove the `scontext_len` argument from `string_to_context_struct()`.
      Signed-off-by: NJann Horn <jannh@google.com>
      [PM: minor merge fuzz in convert_context()]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      95ffe194
  13. 05 9月, 2018 3 次提交