27 Nov, 2018

1 commit

  • [ Upstream commit 250f2da49cb8e582215a65c03f50e8ddf5cd119c ]

    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: 3b0aaf5866bf ("apparmor: add lib fn to find the "split" for fqnames")
    Reported-by: syzbot+61e4b490d9d2da591b50@syzkaller.appspotmail.com
    Signed-off-by: Zubin Mithra
    Reviewed-by: Kees Cook
    Signed-off-by: John Johansen
    Signed-off-by: Sasha Levin

    Zubin Mithra
     

19 Apr, 2018

3 commits

  • commit b5beb07ad32ab533027aa988d96a44965ec116f7 upstream.

    Resource auditing is using the peer field which is not available
    when the rlim data struct is used, because it is a different element
    of the same union. Accessing peer during resource auditing could
    cause garbage log entries or even oops the kernel.

    Move the rlim data block into the same struct as the peer field
    so they can be used together.

    CC:
    Fixes: 86b92cb782b3 ("apparmor: move resource checks to using labels")
    Signed-off-by: John Johansen
    Signed-off-by: Greg Kroah-Hartman

    John Johansen
     
  • commit 040d9e2bce0a5b321c402b79ee43a8e8d2fd3b06 upstream.

    The .ns_name should not be virtualized by the current ns view. It
    needs to report the ns base name as that is being used during startup
    as part of determining apparmor policy namespace support.

    BugLink: http://bugs.launchpad.net/bugs/1746463
    Fixes: d9f02d9c237aa ("apparmor: fix display of ns name")
    Cc: Stable
    Reported-by: Serge Hallyn
    Tested-by: Serge Hallyn
    Signed-off-by: John Johansen
    Signed-off-by: Greg Kroah-Hartman

    John Johansen
     
  • commit 98cf5bbff413eadf1b9cb195a7b80cc61c72a50e upstream.

    The existence test is not being properly logged as the signal mapping
    maps it to the last entry in the named signal table. This is done
    to help catch bugs by making the 0 mapped signal value invalid so
    that we can catch the signal value not being filled in.

    When fixing the off-by-one comparision logic the reporting of the
    existence test was broken, because the logic behind the mapped named
    table was hidden. Fix this by adding a define for the name lookup
    and using it.

    Cc: Stable
    Fixes: f7dc4c9a855a1 ("apparmor: fix off-by-one comparison on MAXMAPPED_SIG")
    Signed-off-by: John Johansen
    Signed-off-by: Greg Kroah-Hartman

    John Johansen
     

17 Jan, 2018

1 commit

  • commit 0dda0b3fb255048a221f736c8a2a24c674da8bf3 upstream.

    Given a label with a profile stack of
    A//&B or A//&C ...

    A ptrace rule should be able to specify a generic trace pattern with
    a rule like

    ptrace trace A//&**,

    however this is failing because while the correct label match routine
    is called, it is being done post label decomposition so it is always
    being done against a profile instead of the stacked label.

    To fix this refactor the cross check to pass the full peer label in to
    the label_match.

    Fixes: 290f458a4f16 ("apparmor: allow ptrace checks to be finer grained than just capability")
    Reported-by: Matthew Garrett
    Tested-by: Matthew Garrett
    Signed-off-by: John Johansen
    Signed-off-by: Greg Kroah-Hartman

    John Johansen
     

10 Jan, 2018

1 commit

  • commit 5b9f57cf47b87f07210875d6a24776b4496b818d upstream.

    When the mount code was refactored for Labels it was not correctly
    updated to check whether policy supported mediation of the mount
    class. This causes a regression when the kernel feature set is
    reported as supporting mount and policy is pinned to a feature set
    that does not support mount mediation.

    BugLink: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=882697#41
    Fixes: 2ea3ffb7782a ("apparmor: add mount mediation")
    Reported-by: Fabian Grünbichler
    Signed-off-by: John Johansen
    Signed-off-by: Greg Kroah-Hartman

    John Johansen
     

14 Dec, 2017

1 commit


05 Dec, 2017

1 commit

  • commit b12cbb21586277f72533769832c24cc6c1d60ab3 upstream.

    The apparmor_audit_data struct ordering got messed up during a merge
    conflict, resulting in the signal integer and peer pointer being in
    a union instead of a struct.

    For most of the 4.13 and 4.14 life cycle, this was hidden by
    commit 651e28c5537a ("apparmor: add base infastructure for socket
    mediation") which fixed the apparmor_audit_data struct when its data
    was added. When that commit was reverted in -rc7 the signal audit bug
    was exposed, and unfortunately it never showed up in any of the
    testing until after 4.14 was released. Shaun Khan, Zephaniah
    E. Loss-Cutler-Hull filed nearly simultaneous bug reports (with
    different oopes, the smaller of which is included below).

    Full credit goes to Tetsuo Handa for jumping on this as well and
    noticing the audit data struct problem and reporting it.

    [ 76.178568] BUG: unable to handle kernel paging request at
    ffffffff0eee3bc0
    [ 76.178579] IP: audit_signal_cb+0x6c/0xe0
    [ 76.178581] PGD 1a640a067 P4D 1a640a067 PUD 0
    [ 76.178586] Oops: 0000 [#1] PREEMPT SMP
    [ 76.178589] Modules linked in: fuse rfcomm bnep usblp uvcvideo btusb
    btrtl btbcm btintel bluetooth ecdh_generic ip6table_filter ip6_tables
    xt_tcpudp nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack
    iptable_filter ip_tables x_tables intel_rapl joydev wmi_bmof serio_raw
    iwldvm iwlwifi shpchp kvm_intel kvm irqbypass autofs4 algif_skcipher
    nls_iso8859_1 nls_cp437 crc32_pclmul ghash_clmulni_intel
    [ 76.178620] CPU: 0 PID: 10675 Comm: pidgin Not tainted
    4.14.0-f1-dirty #135
    [ 76.178623] Hardware name: Hewlett-Packard HP EliteBook Folio
    9470m/18DF, BIOS 68IBD Ver. F.62 10/22/2015
    [ 76.178625] task: ffff9c7a94c31dc0 task.stack: ffffa09b02a4c000
    [ 76.178628] RIP: 0010:audit_signal_cb+0x6c/0xe0
    [ 76.178631] RSP: 0018:ffffa09b02a4fc08 EFLAGS: 00010292
    [ 76.178634] RAX: ffffa09b02a4fd60 RBX: ffff9c7aee0741f8 RCX:
    0000000000000000
    [ 76.178636] RDX: ffffffffee012290 RSI: 0000000000000006 RDI:
    ffff9c7a9493d800
    [ 76.178638] RBP: ffffa09b02a4fd40 R08: 000000000000004d R09:
    ffffa09b02a4fc46
    [ 76.178641] R10: ffffa09b02a4fcb8 R11: ffff9c7ab44f5072 R12:
    ffffa09b02a4fd40
    [ 76.178643] R13: ffffffff9e447be0 R14: ffff9c7a94c31dc0 R15:
    0000000000000001
    [ 76.178646] FS: 00007f8b11ba2a80(0000) GS:ffff9c7afea00000(0000)
    knlGS:0000000000000000
    [ 76.178648] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 76.178650] CR2: ffffffff0eee3bc0 CR3: 00000003d5209002 CR4:
    00000000001606f0
    [ 76.178652] Call Trace:
    [ 76.178660] common_lsm_audit+0x1da/0x780
    [ 76.178665] ? d_absolute_path+0x60/0x90
    [ 76.178669] ? aa_check_perms+0xcd/0xe0
    [ 76.178672] aa_check_perms+0xcd/0xe0
    [ 76.178675] profile_signal_perm.part.0+0x90/0xa0
    [ 76.178679] aa_may_signal+0x16e/0x1b0
    [ 76.178686] apparmor_task_kill+0x51/0x120
    [ 76.178690] security_task_kill+0x44/0x60
    [ 76.178695] group_send_sig_info+0x25/0x60
    [ 76.178699] kill_pid_info+0x36/0x60
    [ 76.178703] SYSC_kill+0xdb/0x180
    [ 76.178707] ? preempt_count_sub+0x92/0xd0
    [ 76.178712] ? _raw_write_unlock_irq+0x13/0x30
    [ 76.178716] ? task_work_run+0x6a/0x90
    [ 76.178720] ? exit_to_usermode_loop+0x80/0xa0
    [ 76.178723] entry_SYSCALL_64_fastpath+0x13/0x94
    [ 76.178727] RIP: 0033:0x7f8b0e58b767
    [ 76.178729] RSP: 002b:00007fff19efd4d8 EFLAGS: 00000206 ORIG_RAX:
    000000000000003e
    [ 76.178732] RAX: ffffffffffffffda RBX: 0000557f3e3c2050 RCX:
    00007f8b0e58b767
    [ 76.178735] RDX: 0000000000000000 RSI: 0000000000000000 RDI:
    000000000000263b
    [ 76.178737] RBP: 0000000000000000 R08: 0000557f3e3c2270 R09:
    0000000000000001
    [ 76.178739] R10: 000000000000022d R11: 0000000000000206 R12:
    0000000000000000
    [ 76.178741] R13: 0000000000000001 R14: 0000557f3e3c13c0 R15:
    0000000000000000
    [ 76.178745] Code: 48 8b 55 18 48 89 df 41 b8 20 00 08 01 5b 5d 48 8b
    42 10 48 8b 52 30 48 63 48 4c 48 8b 44 c8 48 31 c9 48 8b 70 38 e9 f4 fd
    00 00 8b 14 d5 40 27 e5 9e 48 c7 c6 7d 07 19 9f 48 89 df e8 fd 35
    [ 76.178794] RIP: audit_signal_cb+0x6c/0xe0 RSP: ffffa09b02a4fc08
    [ 76.178796] CR2: ffffffff0eee3bc0
    [ 76.178799] ---[ end trace 514af9529297f1a3 ]---

    Fixes: cd1dbf76b23d ("apparmor: add the ability to mediate signals")
    Reported-by: Zephaniah E. Loss-Cutler-Hull
    Reported-by: Shuah Khan
    Suggested-by: Tetsuo Handa
    Tested-by: Ivan Kozik
    Tested-by: Zephaniah E. Loss-Cutler-Hull
    Tested-by: Christian Boltz
    Tested-by: Shuah Khan
    Signed-off-by: John Johansen
    Signed-off-by: Greg Kroah-Hartman

    John Johansen
     

09 Nov, 2017

1 commit

  • This came in yesterday, and I have verified our regression tests
    were missing this and it can cause an oops. Please apply.

    There is a an off-by-one comparision on sig against MAXMAPPED_SIG
    that can lead to a read outside the sig_map array if sig
    is MAXMAPPED_SIG. Fix this.

    Verified that the check is an out of bounds case that can cause an oops.

    Revised: add comparison fix to second case
    Fixes: cd1dbf76b23d ("apparmor: add the ability to mediate signals")
    Signed-off-by: Colin Ian King
    Signed-off-by: John Johansen
    Signed-off-by: Linus Torvalds

    John Johansen
     

03 Nov, 2017

1 commit

  • …el/git/gregkh/driver-core

    Pull initial SPDX identifiers from Greg KH:
    "License cleanup: add SPDX license identifiers to some files

    Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the
    'GPL-2.0' SPDX license identifier. The SPDX identifier is a legally
    binding shorthand, which can be used instead of the full boiler plate
    text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart
    and Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset
    of the use cases:

    - file had no licensing information it it.

    - file was a */uapi/* one with no licensing information in it,

    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to
    license had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied
    to a file was done in a spreadsheet of side by side results from of
    the output of two independent scanners (ScanCode & Windriver)
    producing SPDX tag:value files created by Philippe Ombredanne.
    Philippe prepared the base worksheet, and did an initial spot review
    of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537
    files assessed. Kate Stewart did a file by file comparison of the
    scanner results in the spreadsheet to determine which SPDX license
    identifier(s) to be applied to the file. She confirmed any
    determination that was not immediately clear with lawyers working with
    the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:

    - Files considered eligible had to be source code files.

    - Make and config files were included as candidates if they contained
    >5 lines of source

    - File already had some variant of a license header in it (even if <5
    lines).

    All documentation files were explicitly excluded.

    The following heuristics were used to determine which SPDX license
    identifiers to apply.

    - when both scanners couldn't find any license traces, file was
    considered to have no license information in it, and the top level
    COPYING file license applied.

    For non */uapi/* files that summary was:

    SPDX license identifier # files
    ---------------------------------------------------|-------
    GPL-2.0 11139

    and resulted in the first patch in this series.

    If that file was a */uapi/* path one, it was "GPL-2.0 WITH
    Linux-syscall-note" otherwise it was "GPL-2.0". Results of that
    was:

    SPDX license identifier # files
    ---------------------------------------------------|-------
    GPL-2.0 WITH Linux-syscall-note 930

    and resulted in the second patch in this series.

    - if a file had some form of licensing information in it, and was one
    of the */uapi/* ones, it was denoted with the Linux-syscall-note if
    any GPL family license was found in the file or had no licensing in
    it (per prior point). Results summary:

    SPDX license identifier # files
    ---------------------------------------------------|------
    GPL-2.0 WITH Linux-syscall-note 270
    GPL-2.0+ WITH Linux-syscall-note 169
    ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
    ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
    LGPL-2.1+ WITH Linux-syscall-note 15
    GPL-1.0+ WITH Linux-syscall-note 14
    ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
    LGPL-2.0+ WITH Linux-syscall-note 4
    LGPL-2.1 WITH Linux-syscall-note 3
    ((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
    ((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1

    and that resulted in the third patch in this series.

    - when the two scanners agreed on the detected license(s), that
    became the concluded license(s).

    - when there was disagreement between the two scanners (one detected
    a license but the other didn't, or they both detected different
    licenses) a manual inspection of the file occurred.

    - In most cases a manual inspection of the information in the file
    resulted in a clear resolution of the license that should apply
    (and which scanner probably needed to revisit its heuristics).

    - When it was not immediately clear, the license identifier was
    confirmed with lawyers working with the Linux Foundation.

    - If there was any question as to the appropriate license identifier,
    the file was flagged for further research and to be revisited later
    in time.

    In total, over 70 hours of logged manual review was done on the
    spreadsheet to determine the SPDX license identifiers to apply to the
    source files by Kate, Philippe, Thomas and, in some cases,
    confirmation by lawyers working with the Linux Foundation.

    Kate also obtained a third independent scan of the 4.13 code base from
    FOSSology, and compared selected files where the other two scanners
    disagreed against that SPDX file, to see if there was new insights.
    The Windriver scanner is based on an older version of FOSSology in
    part, so they are related.

    Thomas did random spot checks in about 500 files from the spreadsheets
    for the uapi headers and agreed with SPDX license identifier in the
    files he inspected. For the non-uapi files Thomas did random spot
    checks in about 15000 files.

    In initial set of patches against 4.14-rc6, 3 files were found to have
    copy/paste license identifier errors, and have been fixed to reflect
    the correct identifier.

    Additionally Philippe spent 10 hours this week doing a detailed manual
    inspection and review of the 12,461 patched files from the initial
    patch version early this week with:

    - a full scancode scan run, collecting the matched texts, detected
    license ids and scores

    - reviewing anything where there was a license detected (about 500+
    files) to ensure that the applied SPDX license was correct

    - reviewing anything where there was no detection but the patch
    license was not GPL-2.0 WITH Linux-syscall-note to ensure that the
    applied SPDX license was correct

    This produced a worksheet with 20 files needing minor correction. This
    worksheet was then exported into 3 different .csv files for the
    different types of files to be modified.

    These .csv files were then reviewed by Greg. Thomas wrote a script to
    parse the csv files and add the proper SPDX tag to the file, in the
    format that the file expected. This script was further refined by Greg
    based on the output to detect more types of files automatically and to
    distinguish between header and source .c files (which need different
    comment types.) Finally Greg ran the script using the .csv files to
    generate the patches.

    Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
    Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>"

    * tag 'spdx_identifiers-4.14-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
    License cleanup: add SPDX license identifier to uapi header files with a license
    License cleanup: add SPDX license identifier to uapi header files with no license
    License cleanup: add SPDX GPL-2.0 license identifier to files with no license

    Linus Torvalds
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

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

18 commits

  • …git/jj/linux-apparmor

    Pull apparmor updates from John Johansen:
    "This is the apparmor pull request, similar to SELinux and seccomp.

    It's the same series that I was sent to James' security tree + one
    regression fix that was found after the series was sent to James and
    would have been sent for v4.14-rc2.

    Features:
    - in preparation for secid mapping add support for absolute root view
    based labels
    - add base infastructure for socket mediation
    - add mount mediation
    - add signal mediation

    minor cleanups and changes:
    - be defensive, ensure unconfined profiles have dfas initialized
    - add more debug asserts to apparmorfs
    - enable policy unpacking to audit different reasons for failure
    - cleanup conditional check for label in label_print
    - Redundant condition: prev_ns. in [label.c:1498]

    Bug Fixes:
    - fix regression in apparmorfs DAC access permissions
    - fix build failure on sparc caused by undeclared signals
    - fix sparse report of incorrect type assignment when freeing label proxies
    - fix race condition in null profile creation
    - Fix an error code in aafs_create()
    - Fix logical error in verify_header()
    - Fix shadowed local variable in unpack_trans_table()"

    * tag 'apparmor-pr-2017-09-22' of git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor:
    apparmor: fix apparmorfs DAC access permissions
    apparmor: fix build failure on sparc caused by undeclared signals
    apparmor: fix incorrect type assignment when freeing proxies
    apparmor: ensure unconfined profiles have dfas initialized
    apparmor: fix race condition in null profile creation
    apparmor: move new_null_profile to after profile lookup fns()
    apparmor: add base infastructure for socket mediation
    apparmor: add more debug asserts to apparmorfs
    apparmor: make policy_unpack able to audit different info messages
    apparmor: add support for absolute root view based labels
    apparmor: cleanup conditional check for label in label_print
    apparmor: add mount mediation
    apparmor: add the ability to mediate signals
    apparmor: Redundant condition: prev_ns. in [label.c:1498]
    apparmor: Fix an error code in aafs_create()
    apparmor: Fix logical error in verify_header()
    apparmor: Fix shadowed local variable in unpack_trans_table()

    Linus Torvalds
     
  • The DAC access permissions for several apparmorfs files are wrong.

    .access - needs to be writable by all tasks to perform queries
    the others in the set only provide a read fn so should be read only.

    With policy namespace virtualization all apparmor needs to control
    the permission and visibility checks directly which means DAC
    access has to be allowed for all user, group, and other.

    BugLink: http://bugs.launchpad.net/bugs/1713103
    Fixes: c97204baf840b ("apparmor: rename apparmor file fns and data to indicate use")
    Signed-off-by: John Johansen

    John Johansen
     
  • In file included from security/apparmor/ipc.c:23:0:
    security/apparmor/include/sig_names.h:26:3: error: 'SIGSTKFLT' undeclared here (not in a function)
    [SIGSTKFLT] = 16, /* -, 16, - */
    ^
    security/apparmor/include/sig_names.h:26:3: error: array index in initializer not of integer type
    security/apparmor/include/sig_names.h:26:3: note: (near initialization for 'sig_map')
    security/apparmor/include/sig_names.h:51:3: error: 'SIGUNUSED' undeclared here (not in a function)
    [SIGUNUSED] = 34, /* -, 31, - */
    ^
    security/apparmor/include/sig_names.h:51:3: error: array index in initializer not of integer type
    security/apparmor/include/sig_names.h:51:3: note: (near initialization for 'sig_map')

    Reported-by: Stephen Rothwell
    Fixes: c6bf1adaecaa ("apparmor: add the ability to mediate signals")
    Signed-off-by: John Johansen

    John Johansen
     
  • sparse reports

    poisoning the proxy->label before freeing the struct is resulting in
    a sparse build warning.
    ../security/apparmor/label.c:52:30: warning: incorrect type in assignment (different address spaces)
    ../security/apparmor/label.c:52:30: expected struct aa_label [noderef] *label
    ../security/apparmor/label.c:52:30: got struct aa_label *

    fix with RCU_INIT_POINTER as this is one of those cases where
    rcu_assign_pointer() is not needed.

    Signed-off-by: John Johansen

    John Johansen
     
  • Generally unconfined has early bailout tests and does not need the
    dfas initialized, however if an early bailout test is ever missed
    it will result in an oops.

    Be defensive and initialize the unconfined profile to have null dfas
    (no permission) so if an early bailout test is missed we fail
    closed (no perms granted) instead of oopsing.

    Signed-off-by: John Johansen

    John Johansen
     
  • There is a race when null- profile is being created between the
    initial lookup/creation of the profile and lock/addition of the
    profile. This could result in multiple version of a profile being
    added to the list which need to be removed/replaced.

    Since these are learning profile their is no affect on mediation.

    Signed-off-by: John Johansen

    John Johansen
     
  • new_null_profile will need to use some of the profile lookup fns()
    so move instead of doing forward fn declarations.

    Signed-off-by: John Johansen

    John Johansen
     
  • 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
     
  • 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
     
  • With apparmor policy virtualization based on policy namespace View's
    we don't generally want/need absolute root based views, however there
    are cases like debugging and some secid based conversions where
    using a root based view is important.

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

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

    John Johansen
     
  • Add basic mount mediation. That allows controlling based on basic
    mount parameters. It does not include special mount parameters for
    apparmor, super block labeling, or any triggers for apparmor namespace
    parameter modifications on pivot root.

    default userspace policy rules have the form of
    MOUNT RULE = ( MOUNT | REMOUNT | UMOUNT )

    MOUNT = [ QUALIFIERS ] 'mount' [ MOUNT CONDITIONS ] [ SOURCE FILEGLOB ]
    [ '->' MOUNTPOINT FILEGLOB ]

    REMOUNT = [ QUALIFIERS ] 'remount' [ MOUNT CONDITIONS ]
    MOUNTPOINT FILEGLOB

    UMOUNT = [ QUALIFIERS ] 'umount' [ MOUNT CONDITIONS ] MOUNTPOINT FILEGLOB

    MOUNT CONDITIONS = [ ( 'fstype' | 'vfstype' ) ( '=' | 'in' )
    MOUNT FSTYPE EXPRESSION ]
    [ 'options' ( '=' | 'in' ) MOUNT FLAGS EXPRESSION ]

    MOUNT FSTYPE EXPRESSION = ( MOUNT FSTYPE LIST | MOUNT EXPRESSION )

    MOUNT FSTYPE LIST = Comma separated list of valid filesystem and
    virtual filesystem types (eg ext4, debugfs, etc)

    MOUNT FLAGS EXPRESSION = ( MOUNT FLAGS LIST | MOUNT EXPRESSION )

    MOUNT FLAGS LIST = Comma separated list of MOUNT FLAGS.

    MOUNT FLAGS = ( 'ro' | 'rw' | 'nosuid' | 'suid' | 'nodev' | 'dev' |
    'noexec' | 'exec' | 'sync' | 'async' | 'remount' |
    'mand' | 'nomand' | 'dirsync' | 'noatime' | 'atime' |
    'nodiratime' | 'diratime' | 'bind' | 'rbind' | 'move' |
    'verbose' | 'silent' | 'loud' | 'acl' | 'noacl' |
    'unbindable' | 'runbindable' | 'private' | 'rprivate' |
    'slave' | 'rslave' | 'shared' | 'rshared' |
    'relatime' | 'norelatime' | 'iversion' | 'noiversion' |
    'strictatime' | 'nouser' | 'user' )

    MOUNT EXPRESSION = ( ALPHANUMERIC | AARE ) ...

    PIVOT ROOT RULE = [ QUALIFIERS ] pivot_root [ oldroot=OLD PUT FILEGLOB ]
    [ NEW ROOT FILEGLOB ]

    SOURCE FILEGLOB = FILEGLOB

    MOUNTPOINT FILEGLOB = FILEGLOB

    eg.
    mount,
    mount /dev/foo,
    mount options=ro /dev/foo -> /mnt/,
    mount options in (ro,atime) /dev/foo -> /mnt/,
    mount options=ro options=atime,

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

    John Johansen
     
  • Add signal mediation where the signal can be mediated based on the
    signal, direction, or the label or the peer/target. The signal perms
    are verified on a cross check to ensure policy consistency in the case
    of incremental policy load/replacement.

    The optimization of skipping the cross check when policy is guaranteed
    to be consistent (single compile unit) remains to be done.

    policy rules have the form of
    SIGNAL_RULE = [ QUALIFIERS ] 'signal' [ SIGNAL ACCESS PERMISSIONS ]
    [ SIGNAL SET ] [ SIGNAL PEER ]

    SIGNAL ACCESS PERMISSIONS = SIGNAL ACCESS | SIGNAL ACCESS LIST

    SIGNAL ACCESS LIST = '(' Comma or space separated list of SIGNAL
    ACCESS ')'

    SIGNAL ACCESS = ( 'r' | 'w' | 'rw' | 'read' | 'write' | 'send' |
    'receive' )

    SIGNAL SET = 'set' '=' '(' SIGNAL LIST ')'

    SIGNAL LIST = Comma or space separated list of SIGNALS

    SIGNALS = ( 'hup' | 'int' | 'quit' | 'ill' | 'trap' | 'abrt' |
    'bus' | 'fpe' | 'kill' | 'usr1' | 'segv' | 'usr2' |
    'pipe' | 'alrm' | 'term' | 'stkflt' | 'chld' | 'cont' |
    'stop' | 'stp' | 'ttin' | 'ttou' | 'urg' | 'xcpu' |
    'xfsz' | 'vtalrm' | 'prof' | 'winch' | 'io' | 'pwr' |
    'sys' | 'emt' | 'exists' | 'rtmin+0' ... 'rtmin+32'
    )

    SIGNAL PEER = 'peer' '=' AARE

    eg.
    signal, # allow all signals
    signal send set=(hup, kill) peer=foo,

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

    John Johansen
     
  • Reported-by: David Binderman
    Signed-off-by: John Johansen

    John Johansen
     
  • We accidentally forgot to set the error code on this path. It means we
    return NULL instead of an error pointer. I looked through a bunch of
    callers and I don't think it really causes a big issue, but the
    documentation says we're supposed to return error pointers here.

    Signed-off-by: Dan Carpenter
    Acked-by: Serge Hallyn
    Signed-off-by: John Johansen

    Dan Carpenter
     
  • 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
     

02 Aug, 2017

2 commits

  • The AppArmor bprm_secureexec hook can be merged with the bprm_set_creds
    hook since it's dealing with the same information, and all of the details
    are finalized during the first call to the bprm_set_creds hook via
    prepare_binprm() (subsequent calls due to binfmt_script, etc, are ignored
    via bprm->called_set_creds).

    Here, all the comments describe how secureexec is actually calculated
    during bprm_set_creds, so this actually does it, drops the bprm flag that
    was being used internally by AppArmor, and drops the bprm_secureexec hook.

    Signed-off-by: Kees Cook
    Acked-by: John Johansen
    Reviewed-by: James Morris
    Acked-by: Serge Hallyn

    Kees Cook
     
  • The cred_prepared bprm flag has a misleading name. It has nothing to do
    with the bprm_prepare_cred hook, and actually tracks if bprm_set_creds has
    been called. Rename this flag and improve its comment.

    Cc: David Howells
    Cc: Stephen Smalley
    Cc: Casey Schaufler
    Signed-off-by: Kees Cook
    Acked-by: John Johansen
    Acked-by: James Morris
    Acked-by: Paul Moore
    Acked-by: Serge Hallyn

    Kees Cook
     

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
     

28 Jun, 2017

1 commit


11 Jun, 2017

6 commits