12 Mar, 2019

1 commit

  • if secmark rules fail to unpack a double free happens resulting in
    the following oops

    [ 1295.584074] audit: type=1400 audit(1549970525.256:51): apparmor="STATUS" info="failed to unpack profile secmark rules" error=-71 profile="unconfined" name="/root/test" pid=29882 comm="apparmor_parser" name="/root/test" offset=120
    [ 1374.042334] ------------[ cut here ]------------
    [ 1374.042336] kernel BUG at mm/slub.c:294!
    [ 1374.042404] invalid opcode: 0000 [#1] SMP PTI
    [ 1374.042436] CPU: 0 PID: 29921 Comm: apparmor_parser Not tainted 4.20.7-042007-generic #201902061234
    [ 1374.042461] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
    [ 1374.042489] RIP: 0010:kfree+0x164/0x180
    [ 1374.042502] Code: 74 05 41 0f b6 72 51 4c 89 d7 e8 37 cd f8 ff eb 8b 41 b8 01 00 00 00 48 89 d9 48 89 da 4c 89 d6 e8 11 f6 ff ff e9 72 ff ff ff 0b 49 8b 42 08 a8 01 75 c2 0f 0b 48 8b 3d a9 f4 19 01 e9 c5 fe
    [ 1374.042552] RSP: 0018:ffffaf7b812d7b90 EFLAGS: 00010246
    [ 1374.042568] RAX: ffff91e437679200 RBX: ffff91e437679200 RCX: ffff91e437679200
    [ 1374.042589] RDX: 00000000000088b6 RSI: ffff91e43da27060 RDI: ffff91e43d401a80
    [ 1374.042609] RBP: ffffaf7b812d7ba8 R08: 0000000000027080 R09: ffffffffa6627a6d
    [ 1374.042629] R10: ffffd3af41dd9e40 R11: ffff91e43a1740dc R12: ffff91e3f52e8000
    [ 1374.042650] R13: ffffffffa6627a6d R14: ffffffffffffffb9 R15: 0000000000000001
    [ 1374.042675] FS: 00007f928df77740(0000) GS:ffff91e43da00000(0000) knlGS:0000000000000000
    [ 1374.042697] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 1374.042714] CR2: 000055a0c3ab6b50 CR3: 0000000079ed8004 CR4: 0000000000360ef0
    [ 1374.042737] Call Trace:
    [ 1374.042750] kzfree+0x2d/0x40
    [ 1374.042763] aa_free_profile+0x12b/0x270
    [ 1374.042776] unpack_profile+0xc1/0xf10
    [ 1374.042790] aa_unpack+0x115/0x4e0
    [ 1374.042802] aa_replace_profiles+0x8e/0xcc0
    [ 1374.042817] ? kvmalloc_node+0x6d/0x80
    [ 1374.042831] ? __check_object_size+0x166/0x192
    [ 1374.042845] policy_update+0xcf/0x1b0
    [ 1374.042858] profile_load+0x7d/0xa0
    [ 1374.042871] __vfs_write+0x3a/0x190
    [ 1374.042883] ? apparmor_file_permission+0x1a/0x20
    [ 1374.042899] ? security_file_permission+0x31/0xc0
    [ 1374.042918] ? _cond_resched+0x19/0x30
    [ 1374.042931] vfs_write+0xab/0x1b0
    [ 1374.042963] ksys_write+0x55/0xc0
    [ 1374.043004] __x64_sys_write+0x1a/0x20
    [ 1374.043046] do_syscall_64+0x5a/0x110
    [ 1374.043087] entry_SYSCALL_64_after_hwframe+0x44/0xa9

    Fixes: 9caafbe2b4cf ("apparmor: Parse secmark policy")
    Reported-by: Alex Murray
    Signed-off-by: John Johansen

    John Johansen
     

03 Oct, 2018

1 commit


23 Aug, 2018

1 commit

  • The patch 736ec752d95e: "AppArmor: policy routines for loading and
    unpacking policy" from Jul 29, 2010, leads to the following static
    checker warning:

    security/apparmor/policy_unpack.c:410 verify_accept()
    warn: bitwise AND condition is false here

    security/apparmor/policy_unpack.c:413 verify_accept()
    warn: bitwise AND condition is false here

    security/apparmor/policy_unpack.c
    392 #define DFA_VALID_PERM_MASK 0xffffffff
    393 #define DFA_VALID_PERM2_MASK 0xffffffff
    394
    395 /**
    396 * verify_accept - verify the accept tables of a dfa
    397 * @dfa: dfa to verify accept tables of (NOT NULL)
    398 * @flags: flags governing dfa
    399 *
    400 * Returns: 1 if valid accept tables else 0 if error
    401 */
    402 static bool verify_accept(struct aa_dfa *dfa, int flags)
    403 {
    404 int i;
    405
    406 /* verify accept permissions */
    407 for (i = 0; i < dfa->tables[YYTD_ID_ACCEPT]->td_lolen; i++) {
    408 int mode = ACCEPT_TABLE(dfa)[i];
    409
    410 if (mode & ~DFA_VALID_PERM_MASK)
    411 return 0;
    412
    413 if (ACCEPT_TABLE2(dfa)[i] & ~DFA_VALID_PERM2_MASK)
    414 return 0;

    fixes: 736ec752d95e ("AppArmor: policy routines for loading and unpacking policy")
    Reported-by: Dan Carpenter
    Signed-off-by: John Johansen

    John Johansen
     

13 Jun, 2018

1 commit

  • The kzalloc() function has a 2-factor argument form, kcalloc(). This
    patch replaces cases of:

    kzalloc(a * b, gfp)

    with:
    kcalloc(a * b, gfp)

    as well as handling cases of:

    kzalloc(a * b * c, gfp)

    with:

    kzalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kzalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kzalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc
    + kcalloc
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kzalloc(sizeof(THING) * C2, ...)
    |
    kzalloc(sizeof(TYPE) * C2, ...)
    |
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(C1 * C2, ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

14 Mar, 2018

1 commit

  • version 2 - Force an abi break. Network mediation will only be
    available in v8 abi complaint policy.

    Provide a basic mediation of sockets. This is not a full net mediation
    but just whether a spcific family of socket can be used by an
    application, along with setting up some basic infrastructure for
    network mediation to follow.

    the user space rule hav the basic form of
    NETWORK RULE = [ QUALIFIERS ] 'network' [ DOMAIN ]
    [ TYPE | PROTOCOL ]

    DOMAIN = ( 'inet' | 'ax25' | 'ipx' | 'appletalk' | 'netrom' |
    'bridge' | 'atmpvc' | 'x25' | 'inet6' | 'rose' |
    'netbeui' | 'security' | 'key' | 'packet' | 'ash' |
    'econet' | 'atmsvc' | 'sna' | 'irda' | 'pppox' |
    'wanpipe' | 'bluetooth' | 'netlink' | 'unix' | 'rds' |
    'llc' | 'can' | 'tipc' | 'iucv' | 'rxrpc' | 'isdn' |
    'phonet' | 'ieee802154' | 'caif' | 'alg' | 'nfc' |
    'vsock' | 'mpls' | 'ib' | 'kcm' ) ','

    TYPE = ( 'stream' | 'dgram' | 'seqpacket' | 'rdm' | 'raw' |
    'packet' )

    PROTOCOL = ( 'tcp' | 'udp' | 'icmp' )

    eg.
    network,
    network inet,

    Signed-off-by: John Johansen
    Acked-by: Seth Arnold

    John Johansen
     

10 Feb, 2018

4 commits

  • This converts profile attachment based on xattrs to a fixed extended
    conditional using dfa matching.

    This has a couple of advantages
    - pattern matching can be used for the xattr match

    - xattrs can be optional for an attachment or marked as required

    - the xattr attachment conditional will be able to be combined with
    other extended conditionals when the flexible extended conditional
    work lands.

    The xattr fixed extended conditional is appended to the xmatch
    conditional. If an xattr attachment is specified the profile xmatch
    will be generated regardless of whether there is a pattern match on
    the executable name.

    Signed-off-by: John Johansen
    Acked-by: Seth Arnold

    John Johansen
     
  • Make it possible to tie Apparmor profiles to the presence of one or more
    extended attributes, and optionally their values. An example usecase for
    this is to automatically transition to a more privileged Apparmor profile
    if an executable has a valid IMA signature, which can then be appraised
    by the IMA subsystem.

    Signed-off-by: Matthew Garrett
    Signed-off-by: John Johansen

    Matthew Garrett
     
  • Now that file contexts have been moved into file, and task context
    fns() and data have been split from the context, only the cred context
    remains in context.h so rename to cred.h to better reflect what it
    deals with.

    Signed-off-by: John Johansen

    John Johansen
     
  • Splitting the management struct from the actual data blob will allow
    us in the future to do some sharing and other data reduction
    techniques like replacing the the raw data with compressed data.

    Prepare for this by separating the management struct from the data
    blob.

    Signed-off-by: John Johansen

    John Johansen
     

21 Nov, 2017

1 commit

  • Use mutex_lock_nested to provide lockdep the parent child lock ordering of
    the tree.

    This fixes the lockdep Warning
    [ 305.275177] ============================================
    [ 305.275178] WARNING: possible recursive locking detected
    [ 305.275179] 4.14.0-rc7+ #320 Not tainted
    [ 305.275180] --------------------------------------------
    [ 305.275181] apparmor_parser/1339 is trying to acquire lock:
    [ 305.275182] (&ns->lock){+.+.}, at: [] __aa_create_ns+0x6d/0x1e0
    [ 305.275187]
    but task is already holding lock:
    [ 305.275187] (&ns->lock){+.+.}, at: [] aa_prepare_ns+0x3d/0xd0
    [ 305.275190]
    other info that might help us debug this:
    [ 305.275191] Possible unsafe locking scenario:

    [ 305.275192] CPU0
    [ 305.275193] ----
    [ 305.275193] lock(&ns->lock);
    [ 305.275194] lock(&ns->lock);
    [ 305.275195]
    *** DEADLOCK ***

    [ 305.275196] May be due to missing lock nesting notation

    [ 305.275198] 2 locks held by apparmor_parser/1339:
    [ 305.275198] #0: (sb_writers#10){.+.+}, at: [] vfs_write+0x1a7/0x1d0
    [ 305.275202] #1: (&ns->lock){+.+.}, at: [] aa_prepare_ns+0x3d/0xd0
    [ 305.275205]
    stack backtrace:
    [ 305.275207] CPU: 1 PID: 1339 Comm: apparmor_parser Not tainted 4.14.0-rc7+ #320
    [ 305.275208] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-1ubuntu1 04/01/2014
    [ 305.275209] Call Trace:
    [ 305.275212] dump_stack+0x85/0xcb
    [ 305.275214] __lock_acquire+0x141c/0x1460
    [ 305.275216] ? __aa_create_ns+0x6d/0x1e0
    [ 305.275218] ? ___slab_alloc+0x183/0x540
    [ 305.275219] ? ___slab_alloc+0x183/0x540
    [ 305.275221] lock_acquire+0xed/0x1e0
    [ 305.275223] ? lock_acquire+0xed/0x1e0
    [ 305.275224] ? __aa_create_ns+0x6d/0x1e0
    [ 305.275227] __mutex_lock+0x89/0x920
    [ 305.275228] ? __aa_create_ns+0x6d/0x1e0
    [ 305.275230] ? trace_hardirqs_on_caller+0x11f/0x190
    [ 305.275231] ? __aa_create_ns+0x6d/0x1e0
    [ 305.275233] ? __lockdep_init_map+0x57/0x1d0
    [ 305.275234] ? lockdep_init_map+0x9/0x10
    [ 305.275236] ? __rwlock_init+0x32/0x60
    [ 305.275238] mutex_lock_nested+0x1b/0x20
    [ 305.275240] ? mutex_lock_nested+0x1b/0x20
    [ 305.275241] __aa_create_ns+0x6d/0x1e0
    [ 305.275243] aa_prepare_ns+0xc2/0xd0
    [ 305.275245] aa_replace_profiles+0x168/0xf30
    [ 305.275247] ? __might_fault+0x85/0x90
    [ 305.275250] policy_update+0xb9/0x380
    [ 305.275252] profile_load+0x7e/0x90
    [ 305.275254] __vfs_write+0x28/0x150
    [ 305.275256] ? rcu_read_lock_sched_held+0x72/0x80
    [ 305.275257] ? rcu_sync_lockdep_assert+0x2f/0x60
    [ 305.275259] ? __sb_start_write+0xdc/0x1c0
    [ 305.275261] ? vfs_write+0x1a7/0x1d0
    [ 305.275262] vfs_write+0xca/0x1d0
    [ 305.275264] ? trace_hardirqs_on_caller+0x11f/0x190
    [ 305.275266] SyS_write+0x49/0xa0
    [ 305.275268] entry_SYSCALL_64_fastpath+0x23/0xc2
    [ 305.275271] RIP: 0033:0x7fa6b22e8c74
    [ 305.275272] RSP: 002b:00007ffeaaee6288 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
    [ 305.275273] RAX: ffffffffffffffda RBX: 00007ffeaaee62a4 RCX: 00007fa6b22e8c74
    [ 305.275274] RDX: 0000000000000a51 RSI: 00005566a8198c10 RDI: 0000000000000004
    [ 305.275275] RBP: 0000000000000a39 R08: 0000000000000a51 R09: 0000000000000000
    [ 305.275276] R10: 0000000000000000 R11: 0000000000000246 R12: 00005566a8198c10
    [ 305.275277] R13: 0000000000000004 R14: 00005566a72ecb88 R15: 00005566a72ec3a8

    Fixes: 73688d1ed0b8 ("apparmor: refactor prepare_ns() and make usable from different views")
    Signed-off-by: John Johansen

    John Johansen
     

27 Oct, 2017

1 commit

  • This reverts commit 651e28c5537abb39076d3949fb7618536f1d242e.

    This caused a regression:
    "The specific problem is that dnsmasq refuses to start on openSUSE Leap
    42.2. The specific cause is that and attempt to open a PF_LOCAL socket
    gets EACCES. This means that networking doesn't function on a system
    with a 4.14-rc2 system."

    Sadly, the developers involved seemed to be in denial for several weeks
    about this, delaying the revert. This has not been a good release for
    the security subsystem, and this area needs to change development
    practices.

    Reported-and-bisected-by: James Bottomley
    Tracked-by: Thorsten Leemhuis
    Cc: John Johansen
    Cc: Vlastimil Babka
    Cc: Seth Arnold
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

23 Sep, 2017

4 commits

  • Provide a basic mediation of sockets. This is not a full net mediation
    but just whether a spcific family of socket can be used by an
    application, along with setting up some basic infrastructure for
    network mediation to follow.

    the user space rule hav the basic form of
    NETWORK RULE = [ QUALIFIERS ] 'network' [ DOMAIN ]
    [ TYPE | PROTOCOL ]

    DOMAIN = ( 'inet' | 'ax25' | 'ipx' | 'appletalk' | 'netrom' |
    'bridge' | 'atmpvc' | 'x25' | 'inet6' | 'rose' |
    'netbeui' | 'security' | 'key' | 'packet' | 'ash' |
    'econet' | 'atmsvc' | 'sna' | 'irda' | 'pppox' |
    'wanpipe' | 'bluetooth' | 'netlink' | 'unix' | 'rds' |
    'llc' | 'can' | 'tipc' | 'iucv' | 'rxrpc' | 'isdn' |
    'phonet' | 'ieee802154' | 'caif' | 'alg' | 'nfc' |
    'vsock' | 'mpls' | 'ib' | 'kcm' ) ','

    TYPE = ( 'stream' | 'dgram' | 'seqpacket' | 'rdm' | 'raw' |
    'packet' )

    PROTOCOL = ( 'tcp' | 'udp' | 'icmp' )

    eg.
    network,
    network inet,

    Signed-off-by: John Johansen
    Acked-by: Seth Arnold

    John Johansen
     
  • Switch unpack auditing to using the generic name field in the audit
    struct and make it so we can start adding new info messages about
    why an unpack failed.

    Signed-off-by: John Johansen
    Acked-by: Seth Arnold

    John Johansen
     
  • verify_header() is currently checking whether interface version is less
    than 5 *and* greater than 7, which always evaluates to false. Instead it
    should check whether it is less than 5 *or* greater than 7.

    Signed-off-by: Christos Gkekas
    Signed-off-by: John Johansen

    Christos Gkekas
     
  • with W=2:

    security/apparmor/policy_unpack.c: In function ‘unpack_trans_table’:
    security/apparmor/policy_unpack.c:469: warning: declaration of ‘pos’ shadows a previous local
    security/apparmor/policy_unpack.c:451: warning: shadowed declaration is here

    Rename the old "pos" to "saved_pos" to fix this.

    Fixes: 5379a3312024a8be ("apparmor: support v7 transition format compatible with label_parse")
    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Serge Hallyn
    Signed-off-by: John Johansen

    Geert Uytterhoeven
     

06 Jul, 2017

1 commit

  • Pull security layer updates from James Morris:

    - a major update for AppArmor. From JJ:

    * several bug fixes and cleanups

    * the patch to add symlink support to securityfs that was floated
    on the list earlier and the apparmorfs changes that make use of
    securityfs symlinks

    * it introduces the domain labeling base code that Ubuntu has been
    carrying for several years, with several cleanups applied. And it
    converts the current mediation over to using the domain labeling
    base, which brings domain stacking support with it. This finally
    will bring the base upstream code in line with Ubuntu and provide
    a base to upstream the new feature work that Ubuntu carries.

    * This does _not_ contain any of the newer apparmor mediation
    features/controls (mount, signals, network, keys, ...) that
    Ubuntu is currently carrying, all of which will be RFC'd on top
    of this.

    - Notable also is the Infiniband work in SELinux, and the new file:map
    permission. From Paul:

    "While we're down to 21 patches for v4.13 (it was 31 for v4.12),
    the diffstat jumps up tremendously with over 2k of line changes.

    Almost all of these changes are the SELinux/IB work done by
    Daniel Jurgens; some other noteworthy changes include a NFS v4.2
    labeling fix, a new file:map permission, and reporting of policy
    capabilities on policy load"

    There's also now genfscon labeling support for tracefs, which was
    lost in v4.1 with the separation from debugfs.

    - Smack incorporates a safer socket check in file_receive, and adds a
    cap_capable call in privilege check.

    - TPM as usual has a bunch of fixes and enhancements.

    - Multiple calls to security_add_hooks() can now be made for the same
    LSM, to allow LSMs to have hook declarations across multiple files.

    - IMA now supports different "ima_appraise=" modes (eg. log, fix) from
    the boot command line.

    * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (126 commits)
    apparmor: put back designators in struct initialisers
    seccomp: Switch from atomic_t to recount_t
    seccomp: Adjust selftests to avoid double-join
    seccomp: Clean up core dump logic
    IMA: update IMA policy documentation to include pcr= option
    ima: Log the same audit cause whenever a file has no signature
    ima: Simplify policy_func_show.
    integrity: Small code improvements
    ima: fix get_binary_runtime_size()
    ima: use ima_parse_buf() to parse template data
    ima: use ima_parse_buf() to parse measurements headers
    ima: introduce ima_parse_buf()
    ima: Add cgroups2 to the defaults list
    ima: use memdup_user_nul
    ima: fix up #endif comments
    IMA: Correct Kconfig dependencies for hash selection
    ima: define is_ima_appraise_enabled()
    ima: define Kconfig IMA_APPRAISE_BOOTPARAM option
    ima: define a set of appraisal rules requiring file signatures
    ima: extend the "ima_policy" boot command line to support multiple policies
    ...

    Linus Torvalds
     

11 Jun, 2017

3 commits


09 Jun, 2017

2 commits


19 May, 2017

1 commit


09 May, 2017

1 commit

  • Patch series "kvmalloc", v5.

    There are many open coded kmalloc with vmalloc fallback instances in the
    tree. Most of them are not careful enough or simply do not care about
    the underlying semantic of the kmalloc/page allocator which means that
    a) some vmalloc fallbacks are basically unreachable because the kmalloc
    part will keep retrying until it succeeds b) the page allocator can
    invoke a really disruptive steps like the OOM killer to move forward
    which doesn't sound appropriate when we consider that the vmalloc
    fallback is available.

    As it can be seen implementing kvmalloc requires quite an intimate
    knowledge if the page allocator and the memory reclaim internals which
    strongly suggests that a helper should be implemented in the memory
    subsystem proper.

    Most callers, I could find, have been converted to use the helper
    instead. This is patch 6. There are some more relying on __GFP_REPEAT
    in the networking stack which I have converted as well and Eric Dumazet
    was not opposed [2] to convert them as well.

    [1] http://lkml.kernel.org/r/20170130094940.13546-1-mhocko@kernel.org
    [2] http://lkml.kernel.org/r/1485273626.16328.301.camel@edumazet-glaptop3.roam.corp.google.com

    This patch (of 9):

    Using kmalloc with the vmalloc fallback for larger allocations is a
    common pattern in the kernel code. Yet we do not have any common helper
    for that and so users have invented their own helpers. Some of them are
    really creative when doing so. Let's just add kv[mz]alloc and make sure
    it is implemented properly. This implementation makes sure to not make
    a large memory pressure for > PAGE_SZE requests (__GFP_NORETRY) and also
    to not warn about allocation failures. This also rules out the OOM
    killer as the vmalloc is a more approapriate fallback than a disruptive
    user visible action.

    This patch also changes some existing users and removes helpers which
    are specific for them. In some cases this is not possible (e.g.
    ext4_kvmalloc, libcfs_kvzalloc) because those seems to be broken and
    require GFP_NO{FS,IO} context which is not vmalloc compatible in general
    (note that the page table allocation is GFP_KERNEL). Those need to be
    fixed separately.

    While we are at it, document that __vmalloc{_node} about unsupported gfp
    mask because there seems to be a lot of confusion out there.
    kvmalloc_node will warn about GFP_KERNEL incompatible (which are not
    superset) flags to catch new abusers. Existing ones would have to die
    slowly.

    [sfr@canb.auug.org.au: f2fs fixup]
    Link: http://lkml.kernel.org/r/20170320163735.332e64b7@canb.auug.org.au
    Link: http://lkml.kernel.org/r/20170306103032.2540-2-mhocko@kernel.org
    Signed-off-by: Michal Hocko
    Signed-off-by: Stephen Rothwell
    Reviewed-by: Andreas Dilger [ext4 part]
    Acked-by: Vlastimil Babka
    Cc: John Hubbard
    Cc: David Miller
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michal Hocko
     

16 Jan, 2017

12 commits


27 Jul, 2016

1 commit

  • The newly added Kconfig option could never work and just causes a build error
    when disabled:

    security/apparmor/lsm.c:675:25: error: 'CONFIG_SECURITY_APPARMOR_HASH_DEFAULT' undeclared here (not in a function)
    bool aa_g_hash_policy = CONFIG_SECURITY_APPARMOR_HASH_DEFAULT;

    The problem is that the macro undefined in this case, and we need to use the IS_ENABLED()
    helper to turn it into a boolean constant.

    Another minor problem with the original patch is that the option is even offered
    in sysfs when SECURITY_APPARMOR_HASH is not enabled, so this also hides the option
    in that case.

    Signed-off-by: Arnd Bergmann
    Fixes: 6059f71f1e94 ("apparmor: add parameter to control whether policy hashing is used")
    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    Arnd Bergmann
     

12 Jul, 2016

3 commits


15 Aug, 2013

1 commit