03 Oct, 2018

1 commit

  • 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: Lance Roy
    Cc: John Johansen
    Cc: James Morris
    Cc: "Serge E. Hallyn"
    Cc:
    Signed-off-by: John Johansen

    Lance Roy
     

20 Jul, 2018

1 commit

  • Don't read past the end of the buffer containing permissions
    characters or write past the end of the destination string.

    Detected by CoverityScan CID#1415361, 1415376 ("Out-of-bounds access")

    Fixes: e53cfe6c7caa ("apparmor: rework perm mapping to a slightly broader set")
    Signed-off-by: Tyler Hicks
    Acked-by: Serge Hallyn
    Signed-off-by: John Johansen

    Tyler Hicks
     

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

1 commit

  • 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
     

21 Nov, 2017

1 commit

  • gcc-4.4 points out suspicious code in compute_mnt_perms, where
    the aa_perms structure is only partially initialized before getting
    returned:

    security/apparmor/mount.c: In function 'compute_mnt_perms':
    security/apparmor/mount.c:227: error: 'perms.prompt' is used uninitialized in this function
    security/apparmor/mount.c:227: error: 'perms.hide' is used uninitialized in this function
    security/apparmor/mount.c:227: error: 'perms.cond' is used uninitialized in this function
    security/apparmor/mount.c:227: error: 'perms.complain' is used uninitialized in this function
    security/apparmor/mount.c:227: error: 'perms.stop' is used uninitialized in this function
    security/apparmor/mount.c:227: error: 'perms.deny' is used uninitialized in this function

    Returning or assigning partially initialized structures is a bit tricky,
    in particular it is explicitly allowed in c99 to assign a partially
    initialized structure to another, as long as only members are read that
    have been initialized earlier. Looking at what various compilers do here,
    the version that produced the warning copied uninitialized stack data,
    while newer versions (and also clang) either set the other members to
    zero or don't update the parts of the return buffer that are not modified
    in the temporary structure, but they never warn about this.

    In case of apparmor, it seems better to be a little safer and always
    initialize the aa_perms structure. Most users already do that, this
    changes the remaining ones, including the one instance that I got the
    warning for.

    Fixes: fa488437d0f9 ("apparmor: add mount mediation")
    Signed-off-by: Arnd Bergmann
    Reviewed-by: Seth Arnold
    Acked-by: Geert Uytterhoeven
    Signed-off-by: John Johansen

    Arnd Bergmann
     

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

1 commit

  • 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
     

28 Jun, 2017

1 commit


11 Jun, 2017

9 commits


09 Jun, 2017

3 commits


16 Jan, 2017

3 commits

  • The aad macro can replace aad strings when it is not intended to. Switch
    to a fn macro so it is only applied when intended.

    Also at the same time cleanup audit_data initialization by putting
    common boiler plate behind a macro, and dropping the gfp_t parameter
    which will become useless.

    Signed-off-by: John Johansen

    John Johansen
     
  • Having ops be an integer that is an index into an op name table is
    awkward and brittle. Every op change requires an edit for both the
    op constant and a string in the table. Instead switch to using const
    strings directly, eliminating the need for the table that needs to
    be kept in sync.

    Signed-off-by: John Johansen

    John Johansen
     
  • Prepare to mark sensitive kernel structures for randomization by making
    sure they're using designated initializers. These were identified during
    allyesconfig builds of x86, arm, and arm64, with most initializer fixes
    extracted from grsecurity.

    Signed-off-by: Kees Cook
    Signed-off-by: John Johansen

    Kees Cook
     

12 Jul, 2016

1 commit

  • BugLink: http://bugs.launchpad.net/bugs/1268727

    The task field in the lsm_audit struct needs to be initialized if
    a change_hat fails, otherwise the following oops will occur

    BUG: unable to handle kernel paging request at 0000002fbead7d08
    IP: [] _raw_spin_lock+0xe/0x50
    PGD 1e3f35067 PUD 0
    Oops: 0002 [#1] SMP
    Modules linked in: pppox crc_ccitt p8023 p8022 psnap llc ax25 btrfs raid6_pq xor xfs libcrc32c dm_multipath scsi_dh kvm_amd dcdbas kvm microcode amd64_edac_mod joydev edac_core psmouse edac_mce_amd serio_raw k10temp sp5100_tco i2c_piix4 ipmi_si ipmi_msghandler acpi_power_meter mac_hid lp parport hid_generic usbhid hid pata_acpi mpt2sas ahci raid_class pata_atiixp bnx2 libahci scsi_transport_sas [last unloaded: tipc]
    CPU: 2 PID: 699 Comm: changehat_twice Tainted: GF O 3.13.0-7-generic #25-Ubuntu
    Hardware name: Dell Inc. PowerEdge R415/08WNM9, BIOS 1.8.6 12/06/2011
    task: ffff8802135c6000 ti: ffff880212986000 task.ti: ffff880212986000
    RIP: 0010:[] [] _raw_spin_lock+0xe/0x50
    RSP: 0018:ffff880212987b68 EFLAGS: 00010006
    RAX: 0000000000020000 RBX: 0000002fbead7500 RCX: 0000000000000000
    RDX: 0000000000000292 RSI: ffff880212987ba8 RDI: 0000002fbead7d08
    RBP: ffff880212987b68 R08: 0000000000000246 R09: ffff880216e572a0
    R10: ffffffff815fd677 R11: ffffea0008469580 R12: ffffffff8130966f
    R13: ffff880212987ba8 R14: 0000002fbead7d08 R15: ffff8800d8c6b830
    FS: 00002b5e6c84e7c0(0000) GS:ffff880216e40000(0000) knlGS:0000000055731700
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000002fbead7d08 CR3: 000000021270f000 CR4: 00000000000006e0
    Stack:
    ffff880212987b98 ffffffff81075f17 ffffffff8130966f 0000000000000009
    0000000000000000 0000000000000000 ffff880212987bd0 ffffffff81075f7c
    0000000000000292 ffff880212987c08 ffff8800d8c6b800 0000000000000026
    Call Trace:
    [] __lock_task_sighand+0x47/0x80
    [] ? apparmor_cred_prepare+0x2f/0x50
    [] do_send_sig_info+0x2c/0x80
    [] send_sig_info+0x1e/0x30
    [] aa_audit+0x13d/0x190
    [] aa_audit_file+0xbc/0x130
    [] ? apparmor_cred_prepare+0x2f/0x50
    [] aa_change_hat+0x202/0x530
    [] aa_setprocattr_changehat+0x116/0x1d0
    [] apparmor_setprocattr+0x25d/0x300
    [] security_setprocattr+0x16/0x20
    [] proc_pid_attr_write+0x107/0x130
    [] vfs_write+0xb4/0x1f0
    [] SyS_write+0x49/0xa0
    [] tracesys+0xe1/0xe6

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

    John Johansen
     

28 Mar, 2016

2 commits


16 Apr, 2015

1 commit


23 Feb, 2013

1 commit


21 Sep, 2012

1 commit


10 Apr, 2012

2 commits


04 Apr, 2012

1 commit

  • Linus found that the gigantic size of the common audit data caused a big
    perf hit on something as simple as running stat() in a loop. This patch
    requires LSMs to declare the LSM specific portion separately rather than
    doing it in a union. Thus each LSM can be responsible for shrinking their
    portion and don't have to pay a penalty just because other LSMs have a
    bigger space requirement.

    Signed-off-by: Eric Paris
    Signed-off-by: Linus Torvalds

    Eric Paris
     

27 Mar, 2012

1 commit

  • Fix failure in aa_change_onexec api when the request is made from a confined
    task. This failure was caused by two problems

    The AA_MAY_ONEXEC perm was not being mapped correctly for this case.

    The executable name was being checked as second time instead of using the
    requested onexec profile name, which may not be the same as the exec
    profile name. This mistake can not be exploited to grant extra permission
    because of the above flaw where the ONEXEC permission was not being mapped
    so it will not be granted.

    BugLink: http://bugs.launchpad.net/bugs/963756

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen
     

14 Mar, 2012

1 commit


28 Feb, 2012

1 commit

  • The mapping of AA_MAY_META_READ for the allow mask was also being mapped
    to the audit and quiet masks. This would result in some operations being
    audited when the should not.

    This flaw was hidden by the previous audit bug which would drop some
    messages that where supposed to be audited.

    Signed-off-by: John Johansen
    Acked-by: Kees Cook

    John Johansen
     

02 Aug, 2010

1 commit

  • AppArmor does files enforcement via pathname matching. Matching is done
    at file open using a dfa match engine. Permission is against the final
    file object not parent directories, ie. the traversal of directories
    as part of the file match is implicitly allowed. In the case of nonexistant
    files (creation) permissions are checked against the target file not the
    directory. eg. In case of creating the file /dir/new, permissions are
    checked against the match /dir/new not against /dir/.

    The permissions for matches are currently stored in the dfa accept table,
    but this will change to allow for dfa reuse and also to allow for sharing
    of wider accept states.

    Signed-off-by: John Johansen
    Signed-off-by: James Morris

    John Johansen