13 Aug, 2021

1 commit

  • Conflicts:

    drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h
    9e26680733d5 ("bnxt_en: Update firmware call to retrieve TX PTP timestamp")
    9e518f25802c ("bnxt_en: 1PPS functions to configure TSIO pins")
    099fdeda659d ("bnxt_en: Event handler for PPS events")

    kernel/bpf/helpers.c
    include/linux/bpf-cgroup.h
    a2baf4e8bb0f ("bpf: Fix potentially incorrect results with bpf_get_local_storage()")
    c7603cfa04e7 ("bpf: Add ambient BPF runtime context stored in current")

    drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
    5957cc557dc5 ("net/mlx5: Set all field of mlx5_irq before inserting it to the xarray")
    2d0b41a37679 ("net/mlx5: Refcount mlx5_irq with integer")

    MAINTAINERS
    7b637cd52f02 ("MAINTAINERS: fix Microchip CAN BUS Analyzer Tool entry typo")
    7d901a1e878a ("net: phy: add Maxlinear GPY115/21x/24x driver")

    Signed-off-by: Jakub Kicinski

    Jakub Kicinski
     

10 Aug, 2021

2 commits

  • Back then, commit 96ae52279594 ("bpf: Add bpf_probe_write_user BPF helper
    to be called in tracers") added the bpf_probe_write_user() helper in order
    to allow to override user space memory. Its original goal was to have a
    facility to "debug, divert, and manipulate execution of semi-cooperative
    processes" under CAP_SYS_ADMIN. Write to kernel was explicitly disallowed
    since it would otherwise tamper with its integrity.

    One use case was shown in cf9b1199de27 ("samples/bpf: Add test/example of
    using bpf_probe_write_user bpf helper") where the program DNATs traffic
    at the time of connect(2) syscall, meaning, it rewrites the arguments to
    a syscall while they're still in userspace, and before the syscall has a
    chance to copy the argument into kernel space. These days we have better
    mechanisms in BPF for achieving the same (e.g. for load-balancers), but
    without having to write to userspace memory.

    Of course the bpf_probe_write_user() helper can also be used to abuse
    many other things for both good or bad purpose. Outside of BPF, there is
    a similar mechanism for ptrace(2) such as PTRACE_PEEK{TEXT,DATA} and
    PTRACE_POKE{TEXT,DATA}, but would likely require some more effort.
    Commit 96ae52279594 explicitly dedicated the helper for experimentation
    purpose only. Thus, move the helper's availability behind a newly added
    LOCKDOWN_BPF_WRITE_USER lockdown knob so that the helper is disabled under
    the "integrity" mode. More fine-grained control can be implemented also
    from LSM side with this change.

    Fixes: 96ae52279594 ("bpf: Add bpf_probe_write_user BPF helper to be called in tracers")
    Signed-off-by: Daniel Borkmann
    Acked-by: Andrii Nakryiko

    Daniel Borkmann
     
  • Rename LOCKDOWN_BPF_READ into LOCKDOWN_BPF_READ_KERNEL so we have naming
    more consistent with a LOCKDOWN_BPF_WRITE_USER option that we are adding.

    Signed-off-by: Daniel Borkmann
    Acked-by: Andrii Nakryiko

    Daniel Borkmann
     

06 Aug, 2021

2 commits

  • Build failure in drivers/net/wwan/mhi_wwan_mbim.c:
    add missing parameter (0, assuming we don't want buffer pre-alloc).

    Conflict in drivers/net/dsa/sja1105/sja1105_main.c between:
    589918df9322 ("net: dsa: sja1105: be stateless with FDB entries on SJA1105P/Q/R/S/SJA1110 too")
    0fac6aa098ed ("net: dsa: sja1105: delete the best_effort_vlan_filtering mode")

    Follow the instructions from the commit message of the former commit
    - removed the if conditions. When looking at commit 589918df9322 ("net:
    dsa: sja1105: be stateless with FDB entries on SJA1105P/Q/R/S/SJA1110 too")
    note that the mask_iotag fields get removed by the following patch.

    Signed-off-by: Jakub Kicinski

    Jakub Kicinski
     
  • Pull selinux fix from Paul Moore:
    "One small SELinux fix for a problem where an error code was not being
    propagated back up to userspace when a bogus SELinux policy is loaded
    into the kernel"

    * tag 'selinux-pr-20210805' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    selinux: correct the return value when loads initial sids

    Linus Torvalds
     

02 Aug, 2021

1 commit


29 Jul, 2021

1 commit

  • Add basic Kconfig, an initial (empty) af_mctp source object, and
    {AF,PF}_MCTP definitions, and the required definitions for a new
    protocol type.

    Signed-off-by: Jeremy Kerr
    Signed-off-by: David S. Miller

    Jeremy Kerr
     

03 Jul, 2021

1 commit

  • …nel/git/arnd/asm-generic

    Pull asm/unaligned.h unification from Arnd Bergmann:
    "Unify asm/unaligned.h around struct helper

    The get_unaligned()/put_unaligned() helpers are traditionally
    architecture specific, with the two main variants being the
    "access-ok.h" version that assumes unaligned pointer accesses always
    work on a particular architecture, and the "le-struct.h" version that
    casts the data to a byte aligned type before dereferencing, for
    architectures that cannot always do unaligned accesses in hardware.

    Based on the discussion linked below, it appears that the access-ok
    version is not realiable on any architecture, but the struct version
    probably has no downsides. This series changes the code to use the
    same implementation on all architectures, addressing the few
    exceptions separately"

    Link: https://lore.kernel.org/lkml/75d07691-1e4f-741f-9852-38c0b4f520bc@synopsys.com/
    Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100363
    Link: https://lore.kernel.org/lkml/20210507220813.365382-14-arnd@kernel.org/
    Link: git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git unaligned-rework-v2
    Link: https://lore.kernel.org/lkml/CAHk-=whGObOKruA_bU3aPGZfoDqZM1_9wBkwREp0H0FgR-90uQ@mail.gmail.com/

    * tag 'asm-generic-unaligned-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic:
    asm-generic: simplify asm/unaligned.h
    asm-generic: uaccess: 1-byte access is always aligned
    netpoll: avoid put_unaligned() on single character
    mwifiex: re-fix for unaligned accesses
    apparmor: use get_unaligned() only for multi-byte words
    partitions: msdos: fix one-byte get_unaligned()
    asm-generic: unaligned always use struct helpers
    asm-generic: unaligned: remove byteshift helpers
    powerpc: use linux/unaligned/le_struct.h on LE power7
    m68k: select CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
    sh: remove unaligned access for sh4a
    openrisc: always use unaligned-struct header
    asm-generic: use asm-generic/unaligned.h for most architectures

    Linus Torvalds
     

01 Jul, 2021

4 commits

  • Pull SafeSetID update from Micah Morton:
    "One very minor code cleanup change that marks a variable as
    __initdata"

    * tag 'safesetid-5.14' of git://github.com/micah-morton/linux:
    LSM: SafeSetID: Mark safesetid_initialized as __initdata

    Linus Torvalds
     
  • Pull smack updates from Casey Schaufler:
    "There is nothing more significant than an improvement to a byte count
    check in smackfs.

    All changes have been in next for weeks"

    * tag 'Smack-for-5.14' of git://github.com/cschaufler/smack-next:
    Smack: fix doc warning
    Revert "Smack: Handle io_uring kernel thread privileges"
    smackfs: restrict bytes count in smk_set_cipso()
    security/smack/: fix misspellings using codespell tool

    Linus Torvalds
     
  • Pull audit updates from Paul Moore:
    "Another merge window, another small audit pull request.

    Four patches in total: one is cosmetic, one removes an unnecessary
    initialization, one renames some enum values to prevent name
    collisions, and one converts list_del()/list_add() to list_move().

    None of these are earth shattering and all pass the audit-testsuite
    tests while merging cleanly on top of your tree from earlier today"

    * tag 'audit-pr-20210629' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit:
    audit: remove unnecessary 'ret' initialization
    audit: remove trailing spaces and tabs
    audit: Use list_move instead of list_del/list_add
    audit: Rename enum audit_state constants to avoid AUDIT_DISABLED redefinition
    audit: add blank line after variable declarations

    Linus Torvalds
     
  • Pull SELinux updates from Paul Moore:

    - The slow_avc_audit() function is now non-blocking so we can remove
    the AVC_NONBLOCKING tricks; this also includes the 'flags' variant of
    avc_has_perm().

    - Use kmemdup() instead of kcalloc()+copy when copying parts of the
    SELinux policydb.

    - The InfiniBand device name is now passed by reference when possible
    in the SELinux code, removing a strncpy().

    - Minor cleanups including: constification of avtab function args,
    removal of useless LSM/XFRM function args, SELinux kdoc fixes, and
    removal of redundant assignments.

    * tag 'selinux-pr-20210629' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    selinux: kill 'flags' argument in avc_has_perm_flags() and avc_audit()
    selinux: slow_avc_audit has become non-blocking
    selinux: Fix kernel-doc
    selinux: use __GFP_NOWARN with GFP_NOWAIT in the AVC
    lsm_audit,selinux: pass IB device name by reference
    selinux: Remove redundant assignment to rc
    selinux: Corrected comment to match kernel-doc comment
    selinux: delete selinux_xfrm_policy_lookup() useless argument
    selinux: constify some avtab function arguments
    selinux: simplify duplicate_policydb_cond_list() by using kmemdup()

    Linus Torvalds
     

29 Jun, 2021

1 commit

  • Pull integrity subsystem updates from Mimi Zohar:
    "The large majority of the changes are EVM portable & immutable
    signature related: removing a dependency on loading an HMAC key,
    safely allowing file metadata included in the EVM portable & immutable
    signatures to be modified, allowing EVM signatures to fulfill IMA file
    signature policy requirements, including the EVM file metadata
    signature in lieu of an IMA file data signature in the measurement
    list, and adding dynamic debugging of EVM file metadata.

    In addition, in order to detect critical data or file change
    reversions, duplicate measurement records are permitted in the IMA
    measurement list.

    The remaining patches address compiler, sparse, and doc warnings"

    * tag 'integrity-v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity: (31 commits)
    evm: Check xattr size discrepancy between kernel and user
    evm: output EVM digest calculation info
    IMA: support for duplicate measurement records
    ima: Fix warning: no previous prototype for function 'ima_add_kexec_buffer'
    ima: differentiate between EVM failures in the audit log
    ima: Fix fall-through warning for Clang
    ima: Pass NULL instead of 0 to ima_get_action() in ima_file_mprotect()
    ima: Include header defining ima_post_key_create_or_update()
    ima/evm: Fix type mismatch
    ima: Set correct casting types
    doc: Fix warning in Documentation/security/IMA-templates.rst
    evm: Don't return an error in evm_write_xattrs() if audit is not enabled
    ima: Define new template evm-sig
    ima: Define new template fields xattrnames, xattrlengths and xattrvalues
    evm: Verify portable signatures against all protected xattrs
    ima: Define new template field imode
    ima: Define new template fields iuid and igid
    ima: Add ima_show_template_uint() template library function
    ima: Don't remove security.ima if file must not be appraised
    ima: Introduce template field evmsig and write to field sig as fallback
    ...

    Linus Torvalds
     

21 Jun, 2021

1 commit

  • The kernel and the user obtain an xattr value in two different ways:

    kernel (EVM): uses vfs_getxattr_alloc() which obtains the xattr value from
    the filesystem handler (raw value);

    user (ima-evm-utils): uses vfs_getxattr() which obtains the xattr value
    from the LSMs (normalized value).

    Normally, this does not have an impact unless security.selinux is set with
    setfattr, with a value not terminated by '\0' (this is not the recommended
    way, security.selinux should be set with the appropriate tools such as
    chcon and restorecon).

    In this case, the kernel and the user see two different xattr values: the
    former sees the xattr value without '\0' (raw value), the latter sees the
    value with '\0' (value normalized by SELinux).

    This could result in two different verification outcomes from EVM and
    ima-evm-utils, if a signature was calculated with a security.selinux value
    terminated by '\0' and the value set in the filesystem is not terminated by
    '\0'. The former would report verification failure due to the missing '\0',
    while the latter would report verification success (because it gets the
    normalized value with '\0').

    This patch mitigates this issue by comparing in evm_calc_hmac_or_hash() the
    size of the xattr returned by the two xattr functions and by warning the
    user if there is a discrepancy.

    Signed-off-by: Roberto Sassu
    Suggested-by: Mimi Zohar
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     

20 Jun, 2021

1 commit

  • Output the data used in calculating the EVM digest and the resulting
    digest as ascii hexadecimal strings.

    Suggested-by: Lakshmi Ramasubramanian (CONFIG_DYNAMIC_DEBUG)
    Reviewed-by: Lakshmi Ramasubramanian
    Reported-by: kernel test robot (Use %zu for size_t)
    Signed-off-by: Mimi Zohar

    Mimi Zohar
     

15 Jun, 2021

1 commit

  • Fix gcc W=1 warnings:

    security/tomoyo/audit.c:331: warning: Function parameter or member 'matched_acl' not described in 'tomoyo_get_audit'
    security/tomoyo/securityfs_if.c:146: warning: Function parameter or member 'inode' not described in 'tomoyo_release'
    security/tomoyo/tomoyo.c:122: warning: Function parameter or member 'path' not described in 'tomoyo_inode_getattr'
    security/tomoyo/tomoyo.c:497: warning: Function parameter or member 'clone_flags' not described in 'tomoyo_task_alloc'
    security/tomoyo/util.c:92: warning: Function parameter or member 'time64' not described in 'tomoyo_convert_time'

    Signed-off-by: ChenXiaoSong
    [ penguin-kernel: Also adjust spaces and similar warnings ]
    Signed-off-by: Tetsuo Handa

    ChenXiaoSong
     

12 Jun, 2021

5 commits

  • The variable 'ret' is set to 0 when declared.
    The 'ret' is unused until it is set to 0 again.

    So it had better remove unnecessary initialization.

    Signed-off-by: Austin Kim
    Signed-off-by: Paul Moore

    Austin Kim
     
  • ... along with avc_has_perm_flags() itself, since now it's identical
    to avc_has_perm() (as pointed out by Paul Moore)

    Signed-off-by: Al Viro
    [PM: add "selinux:" prefix to subj and tweak for length]
    Signed-off-by: Paul Moore

    Al Viro
     
  • dump_common_audit_data() is safe to use under rcu_read_lock() now;
    no need for AVC_NONBLOCKING and games around it

    Signed-off-by: Al Viro
    Signed-off-by: Paul Moore

    Al Viro
     
  • Fix function name and add comment for parameter state in ss/services.c
    kernel-doc to remove some warnings found by running make W=1 LLVM=1.

    Reported-by: Abaci Robot
    Signed-off-by: Yang Li
    Signed-off-by: Paul Moore

    Yang Li
     
  • IMA measures contents of a given file/buffer/critical-data record,
    and properly re-measures it on change. However, IMA does not measure
    the duplicate value for a given record, since TPM extend is a very
    expensive operation. For example, if the record changes from value
    'v#1' to 'v#2', and then back to 'v#1', IMA will not measure and log
    the last change to 'v#1', since the hash of 'v#1' for that record is
    already present in the IMA htable. This limits the ability of an
    external attestation service to accurately determine the current state
    of the system. The service would incorrectly conclude that the latest
    value of the given record on the system is 'v#2', and act accordingly.

    Define and use a new Kconfig option IMA_DISABLE_HTABLE to permit
    duplicate records in the IMA measurement list.

    In addition to the duplicate measurement records described above,
    other duplicate file measurement records may be included in the log,
    when CONFIG_IMA_DISABLE_HTABLE is enabled. For example,
    - i_version is not enabled,
    - i_generation changed,
    - same file present on different filesystems,
    - an inode is evicted from dcache

    Signed-off-by: Tushar Sugandhi
    Reviewed-by: Petr Vorel
    [zohar@linux.ibm.com: updated list of duplicate measurement records]
    Signed-off-by: Mimi Zohar

    Tushar Sugandhi
     

11 Jun, 2021

4 commits

  • The function prototype for ima_add_kexec_buffer() is present
    in 'linux/ima.h'. But this header file is not included in
    ima_kexec.c where the function is implemented. This results
    in the following compiler warning when "-Wmissing-prototypes" flag
    is turned on:

    security/integrity/ima/ima_kexec.c:81:6: warning: no previous prototype
    for function 'ima_add_kexec_buffer' [-Wmissing-prototypes]

    Include the header file 'linux/ima.h' in ima_kexec.c to fix
    the compiler warning.

    Fixes: dce92f6b11c3 (arm64: Enable passing IMA log to next kernel on kexec)
    Reported-by: kernel test robot
    Signed-off-by: Lakshmi Ramasubramanian
    Acked-by: Rob Herring
    Signed-off-by: Mimi Zohar

    Lakshmi Ramasubramanian
     
  • In the field, we have seen lots of allocation failure from the call
    path below.

    06-03 13:29:12.999 1010315 31557 31557 W Binder : 31542_2: page allocation failure: order:0, mode:0x800(GFP_NOWAIT), nodemask=(null),cpuset=background,mems_allowed=0
    ...
    ...
    06-03 13:29:12.999 1010315 31557 31557 W Call trace:
    06-03 13:29:12.999 1010315 31557 31557 W : dump_backtrace.cfi_jt+0x0/0x8
    06-03 13:29:12.999 1010315 31557 31557 W : dump_stack+0xc8/0x14c
    06-03 13:29:12.999 1010315 31557 31557 W : warn_alloc+0x158/0x1c8
    06-03 13:29:12.999 1010315 31557 31557 W : __alloc_pages_slowpath+0x9d8/0xb80
    06-03 13:29:12.999 1010315 31557 31557 W : __alloc_pages_nodemask+0x1c4/0x430
    06-03 13:29:12.999 1010315 31557 31557 W : allocate_slab+0xb4/0x390
    06-03 13:29:12.999 1010315 31557 31557 W : ___slab_alloc+0x12c/0x3a4
    06-03 13:29:12.999 1010315 31557 31557 W : kmem_cache_alloc+0x358/0x5e4
    06-03 13:29:12.999 1010315 31557 31557 W : avc_alloc_node+0x30/0x184
    06-03 13:29:12.999 1010315 31557 31557 W : avc_update_node+0x54/0x4f0
    06-03 13:29:12.999 1010315 31557 31557 W : avc_has_extended_perms+0x1a4/0x460
    06-03 13:29:12.999 1010315 31557 31557 W : selinux_file_ioctl+0x320/0x3d0
    06-03 13:29:12.999 1010315 31557 31557 W : __arm64_sys_ioctl+0xec/0x1fc
    06-03 13:29:12.999 1010315 31557 31557 W : el0_svc_common+0xc0/0x24c
    06-03 13:29:12.999 1010315 31557 31557 W : el0_svc+0x28/0x88
    06-03 13:29:12.999 1010315 31557 31557 W : el0_sync_handler+0x8c/0xf0
    06-03 13:29:12.999 1010315 31557 31557 W : el0_sync+0x1a4/0x1c0
    ..
    ..
    06-03 13:29:12.999 1010315 31557 31557 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO)
    06-03 13:29:12.999 1010315 31557 31557 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0
    06-03 13:29:12.999 1010315 31557 31557 W node 0 : slabs: 57, objs: 2907, free: 0
    06-03 13:29:12.999 1010161 10686 10686 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO)
    06-03 13:29:12.999 1010161 10686 10686 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0
    06-03 13:29:12.999 1010161 10686 10686 W node 0 : slabs: 57, objs: 2907, free: 0
    06-03 13:29:12.999 1010161 10686 10686 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO)
    06-03 13:29:12.999 1010161 10686 10686 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0
    06-03 13:29:12.999 1010161 10686 10686 W node 0 : slabs: 57, objs: 2907, free: 0
    06-03 13:29:12.999 1010161 10686 10686 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO)
    06-03 13:29:12.999 1010161 10686 10686 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0
    06-03 13:29:12.999 1010161 10686 10686 W node 0 : slabs: 57, objs: 2907, free: 0
    06-03 13:29:13.000 1010161 10686 10686 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO)
    06-03 13:29:13.000 1010161 10686 10686 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0
    06-03 13:29:13.000 1010161 10686 10686 W node 0 : slabs: 57, objs: 2907, free: 0
    06-03 13:29:13.000 1010161 10686 10686 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO)
    06-03 13:29:13.000 1010161 10686 10686 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0
    06-03 13:29:13.000 1010161 10686 10686 W node 0 : slabs: 57, objs: 2907, free: 0
    06-03 13:29:13.000 1010161 10686 10686 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO)
    06-03 13:29:13.000 1010161 10686 10686 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0
    06-03 13:29:13.000 1010161 10686 10686 W node 0 : slabs: 57, objs: 2907, free: 0
    06-03 13:29:13.000 10230 30892 30892 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO)
    06-03 13:29:13.000 10230 30892 30892 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0
    06-03 13:29:13.000 10230 30892 30892 W node 0 : slabs: 57, objs: 2907, free: 0
    06-03 13:29:13.000 10230 30892 30892 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO)
    06-03 13:29:13.000 10230 30892 30892 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0

    Based on [1], selinux is tolerate for failure of memory allocation.
    Then, use __GFP_NOWARN together.

    [1] 476accbe2f6e ("selinux: use GFP_NOWAIT in the AVC kmem_caches")

    Signed-off-by: Minchan Kim
    [PM: subj fix, line wraps, normalized commit refs]
    Signed-off-by: Paul Moore

    Minchan Kim
     
  • Differentiate between an invalid EVM portable signature failure
    from other EVM HMAC/signature failures.

    Reviewed-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Mimi Zohar
     
  • Mark safesetid_initialized as __initdata since it is only used
    in initialization routine.

    Signed-off-by: Austin Kim
    Signed-off-by: Micah Morton

    Austin Kim
     

09 Jun, 2021

6 commits

  • In preparation to enable -Wimplicit-fallthrough for Clang, fix a
    fall-through warning by explicitly adding a break statement instead
    of just letting the code fall through to the next case.

    Link: https://github.com/KSPP/linux/issues/115
    Signed-off-by: Gustavo A. R. Silva
    Reviewed-by: Kees Cook
    Signed-off-by: Mimi Zohar

    Gustavo A. R. Silva
     
  • This patch fixes the sparse warning:

    sparse: warning: Using plain integer as NULL pointer

    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     
  • This patch fixes the sparse warning for ima_post_key_create_or_update() by
    adding the header file that defines the prototype (linux/ima.h).

    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     
  • The endianness of a variable written to the measurement list cannot be
    determined at compile time, as it depends on the value of the
    ima_canonical_fmt global variable (set through a kernel option with the
    same name if the machine is big endian).

    If ima_canonical_fmt is false, the endianness of a variable is the same as
    the machine; if ima_canonical_fmt is true, the endianness is little endian.
    The warning arises due to this type of instruction:

    var = cpu_to_leXX(var)

    which tries to assign a value in little endian to a variable with native
    endianness (little or big endian).

    Given that the variables set with this instruction are not used in any
    operation but just written to a buffer, it is safe to force the type of the
    value being set to be the same of the type of the variable with:

    var = (__force )cpu_to_leXX(var)

    Reported-by: kernel test robot
    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     
  • The code expects that the values being parsed from a buffer when the
    ima_canonical_fmt global variable is true are in little endian. Thus, this
    patch sets the casting types accordingly.

    Reported-by: kernel test robot
    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     
  • Fix gcc W=1 warning:

    security/smack/smack_access.c:342: warning: Function parameter or member 'ad' not described in 'smack_log'
    security/smack/smack_access.c:403: warning: Function parameter or member 'skp' not described in 'smk_insert_entry'
    security/smack/smack_access.c:487: warning: Function parameter or member 'level' not described in 'smk_netlbl_mls'
    security/smack/smack_access.c:487: warning: Function parameter or member 'len' not described in 'smk_netlbl_mls'

    Signed-off-by: ChenXiaoSong
    Signed-off-by: Casey Schaufler

    ChenXiaoSong
     

03 Jun, 2021

3 commits

  • This patch avoids that evm_write_xattrs() returns an error when audit is
    not enabled. The ab variable can be NULL and still be passed to the other
    audit_log_() functions, as those functions do not include any instruction.

    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     
  • With the recent introduction of the evmsig template field, remote verifiers
    can obtain the EVM portable signature instead of the IMA signature, to
    verify file metadata.

    After introducing the new fields to include file metadata in the
    measurement list, this patch finally defines the evm-sig template, whose
    format is:

    d-ng|n-ng|evmsig|xattrnames|xattrlengths|xattrvalues|iuid|igid|imode

    xattrnames, xattrlengths and xattrvalues are populated only from defined
    EVM protected xattrs, i.e. the ones that EVM considers to verify the
    portable signature. xattrnames and xattrlengths are populated only if the
    xattr is present.

    xattrnames and xattrlengths are not necessary for verifying the EVM
    portable signature, but they are included for completeness of information,
    if a remote verifier wants to infer more from file metadata.

    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     
  • This patch defines the new template fields xattrnames, xattrlengths and
    xattrvalues, which contain respectively a list of xattr names (strings,
    separated by |), lengths (u32, hex) and values (hex). If an xattr is not
    present, the name and length are not displayed in the measurement list.

    Reported-by: kernel test robot (Missing prototype def)
    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     

02 Jun, 2021

6 commits

  • Currently, the evm_config_default_xattrnames array contains xattr names
    only related to LSMs which are enabled in the kernel configuration.
    However, EVM portable signatures do not depend on local information and a
    vendor might include in the signature calculation xattrs that are not
    enabled in the target platform.

    Just including all xattrs names in evm_config_default_xattrnames is not a
    safe approach, because a target system might have already calculated
    signatures or HMACs based only on the enabled xattrs. After applying this
    patch, EVM would verify those signatures and HMACs with all xattrs instead.
    The non-enabled ones, which could possibly exist, would cause a
    verification error.

    Thus, this patch adds a new field named enabled to the xattr_list
    structure, which is set to true if the LSM associated to a given xattr name
    is enabled in the kernel configuration. The non-enabled xattrs are taken
    into account only in evm_calc_hmac_or_hash(), if the passed security.evm
    type is EVM_XATTR_PORTABLE_DIGSIG.

    The new function evm_protected_xattr_if_enabled() has been defined so that
    IMA can include all protected xattrs and not only the enabled ones in the
    measurement list, if the new template fields xattrnames, xattrlengths or
    xattrvalues have been included in the template format.

    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     
  • This patch defines the new template field imode, which includes the
    inode mode. It can be used by a remote verifier to verify the EVM portable
    signature, if it was included with the template fields sig or evmsig.

    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     
  • This patch defines the new template fields iuid and igid, which include
    respectively the inode UID and GID. For idmapped mounts, still the original
    UID and GID are provided.

    These fields can be used to verify the EVM portable signature, if it was
    included with the template fields sig or evmsig.

    Signed-off-by: Roberto Sassu
    Acked-by: Christian Brauner
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     
  • This patch introduces the new function ima_show_template_uint(). This can
    be used for showing integers of different sizes in ASCII format. The
    function ima_show_template_data_ascii() automatically determines how to
    print a stored integer by checking the integer size.

    If integers have been written in canonical format,
    ima_show_template_data_ascii() calls the appropriate leXX_to_cpu() function
    to correctly display the value.

    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     
  • Files might come from a remote source and might have xattrs, including
    security.ima. It should not be IMA task to decide whether security.ima
    should be kept or not. This patch removes the removexattr() system
    call in ima_inode_post_setattr().

    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     
  • With the patch to accept EVM portable signatures when the
    appraise_type=imasig requirement is specified in the policy, appraisal can
    be successfully done even if the file does not have an IMA signature.

    However, remote attestation would not see that a different signature type
    was used, as only IMA signatures can be included in the measurement list.
    This patch solves the issue by introducing the new template field 'evmsig'
    to show EVM portable signatures and by including its value in the existing
    field 'sig' if the IMA signature is not found.

    Suggested-by: Mimi Zohar
    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Roberto Sassu