Skip to content
Permalink
Casey-Schaufle…
Switch branches/tags

Commits on Dec 14, 2021

  1. AppArmor: Remove the exclusive flag

    With the inclusion of the interface LSM process attribute
    mechanism AppArmor no longer needs to be treated as an
    "exclusive" security module. Remove the flag that indicates
    it is exclusive. Remove the stub getpeersec_dgram AppArmor
    hook as it has no effect in the single LSM case and
    interferes in the multiple LSM case.
    
    Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
    Acked-by: John Johansen <john.johansen@canonical.com>
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  2. LSM: Add /proc attr entry for full LSM context

    Add an entry /proc/.../attr/context which displays the full
    process security "context" in compound format:
            lsm1\0value\0lsm2\0value\0...
    This entry is not writable.
    
    A security module may decide that its policy does not allow
    this information to be displayed. In this case none of the
    information will be displayed.
    
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Cc: linux-api@vger.kernel.org
    Cc: linux-doc@vger.kernel.org
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  3. Audit: Add record for multiple object security contexts

    Create a new audit record AUDIT_MAC_OBJ_CONTEXTS.
    An example of the MAC_OBJ_CONTEXTS (1421) record is:
    
        type=MAC_OBJ_CONTEXTS[1421]
        msg=audit(1601152467.009:1050):
        obj_selinux=unconfined_u:object_r:user_home_t:s0
    
    When an audit event includes a AUDIT_MAC_OBJ_CONTEXTS record
    the "obj=" field in other records in the event will be "obj=?".
    An AUDIT_MAC_OBJ_CONTEXTS record is supplied when the system has
    multiple security modules that may make access decisions based
    on an object security context.
    
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  4. Audit: Add record for multiple task security contexts

    Create a new audit record AUDIT_MAC_TASK_CONTEXTS.
    An example of the MAC_TASK_CONTEXTS (1420) record is:
    
        type=MAC_TASK_CONTEXTS[1420]
        msg=audit(1600880931.832:113)
        subj_apparmor=unconfined
        subj_smack=_
    
    When an audit event includes a AUDIT_MAC_TASK_CONTEXTS record
    the "subj=" field in other records in the event will be "subj=?".
    An AUDIT_MAC_TASK_CONTEXTS record is supplied when the system has
    multiple security modules that may make access decisions based
    on a subject security context.
    
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  5. Audit: Add framework for auxiliary records

    Add a list for auxiliary record data to the audit_buffer structure.
    Add the audit_stamp information to the audit_buffer as there's no
    guarantee that there will be an audit_context containing the stamp
    associated with the event. At audit_log_end() time create auxiliary
    records (none are currently defined) as have been added to the list.
    
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  6. Audit: Create audit_stamp structure

    Replace the timestamp and serial number pair used in audit records
    with a structure containing the two elements.
    
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Acked-by: Paul Moore <paul@paul-moore.com>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  7. Audit: Keep multiple LSM data in audit_names

    Replace the osid field in the audit_names structure
    with a lsmblob structure. This accomodates the use
    of an lsmblob in security_audit_rule_match() and
    security_inode_getsecid().
    
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Acked-by: Paul Moore <paul@paul-moore.com>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  8. LSM: Extend security_secid_to_secctx to include module selection

    Add a parameter to security_secid_to_secctx() to identify
    which of the security modules that may be active should
    provide the security context. If the parameter is greater
    than or equal to zero, the security module associated with
    that LSM "slot" is used. If the value is LSMBLOB_DISPLAY
    the "interface lsm" is used. If the value is LSMBLOB_FIRST
    the first security module providing a hook is used.
    
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  9. binder: Pass LSM identifier for confirmation

    Send an identifier for the security module interface_lsm
    along with the security context. This allows the receiver
    to verify that the receiver and the sender agree on which
    security module's context is being used. If they don't
    agree the message is rejected.
    
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  10. NET: Store LSM netlabel data in a lsmblob

    Netlabel uses LSM interfaces requiring an lsmblob and
    the internal storage is used to pass information between
    these interfaces, so change the internal data from a secid
    to a lsmblob. Update the netlabel interfaces and their
    callers to accommodate the change. This requires that the
    modules using netlabel use the lsm_id.slot to access the
    correct secid when using netlabel.
    
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: John Johansen <john.johansen@canonical.com>
    Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
    Acked-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Cc: netdev@vger.kernel.org
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  11. LSM: security_secid_to_secctx in netlink netfilter

    Change netlink netfilter interfaces to use lsmcontext
    pointers, and remove scaffolding.
    
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: John Johansen <john.johansen@canonical.com>
    Acked-by: Paul Moore <paul@paul-moore.com>
    Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
    Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Cc: netdev@vger.kernel.org
    Cc: netfilter-devel@vger.kernel.org
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  12. LSM: Use lsmcontext in security_inode_getsecctx

    Change the security_inode_getsecctx() interface to fill
    a lsmcontext structure instead of data and length pointers.
    This provides the information about which LSM created the
    context so that security_release_secctx() can use the
    correct hook.
    
    Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
    Acked-by: Paul Moore <paul@paul-moore.com>
    Acked-by: Chuck Lever <chuck.lever@oracle.com>
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: John Johansen <john.johansen@canonical.com>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Cc: linux-nfs@vger.kernel.org
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  13. LSM: Use lsmcontext in security_secid_to_secctx

    Replace the (secctx,seclen) pointer pair with a single
    lsmcontext pointer to allow return of the LSM identifier
    along with the context and context length. This allows
    security_release_secctx() to know how to release the
    context. Callers have been modified to use or save the
    returned data from the new structure.
    
    security_secid_to_secctx() will now return the length value
    if the passed lsmcontext pointer is NULL.
    
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Cc: netdev@vger.kernel.org
    Cc: linux-audit@redhat.com
    Cc: netfilter-devel@vger.kernel.org
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  14. LSM: Ensure the correct LSM context releaser

    Add a new lsmcontext data structure to hold all the information
    about a "security context", including the string, its size and
    which LSM allocated the string. The allocation information is
    necessary because LSMs have different policies regarding the
    lifecycle of these strings. SELinux allocates and destroys
    them on each use, whereas Smack provides a pointer to an entry
    in a list that never goes away.
    
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: John Johansen <john.johansen@canonical.com>
    Acked-by: Paul Moore <paul@paul-moore.com>
    Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
    Acked-by: Chuck Lever <chuck.lever@oracle.com>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Cc: linux-integrity@vger.kernel.org
    Cc: netdev@vger.kernel.org
    Cc: linux-audit@redhat.com
    Cc: netfilter-devel@vger.kernel.org
    To: Pablo Neira Ayuso <pablo@netfilter.org>
    Cc: linux-nfs@vger.kernel.org
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  15. LSM: Specify which LSM to display

    Create a new entry "interface_lsm" in the procfs attr directory for
    controlling which LSM security information is displayed for a
    process. A process can only read or write its own display value.
    
    The name of an active LSM that supplies hooks for
    human readable data may be written to "interface_lsm" to set the
    value. The name of the LSM currently in use can be read from
    "interface_lsm". At this point there can only be one LSM capable
    of display active. A helper function lsm_task_ilsm() is
    provided to get the interface lsm slot for a task_struct.
    
    Setting the "interface_lsm" requires that all security modules using
    setprocattr hooks allow the action. Each security module is
    responsible for defining its policy.
    
    AppArmor hook provided by John Johansen <john.johansen@canonical.com>
    SELinux hook provided by Stephen Smalley <stephen.smalley.work@gmail.com>
    
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Stephen Smalley <stephen.smalley.work@gmail.com>
    Cc: Paul Moore <paul@paul-moore.com>
    Cc: John Johansen <john.johansen@canonical.com>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: linux-api@vger.kernel.org
    Cc: linux-doc@vger.kernel.org
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  16. LSM: Use lsmblob in security_cred_getsecid

    Change the security_cred_getsecid() interface to fill in a
    lsmblob instead of a u32 secid. The associated data elements
    in the audit sub-system are changed from a secid to a lsmblob
    to accommodate multiple possible LSM audit users.
    
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: John Johansen <john.johansen@canonical.com>
    Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
    Acked-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Cc: linux-integrity@vger.kernel.org
    Cc: linux-audit@redhat.com
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  17. LSM: Use lsmblob in security_inode_getsecid

    Change the security_inode_getsecid() interface to fill in a
    lsmblob structure instead of a u32 secid. This allows for its
    callers to gather data from all registered LSMs. Data is provided
    for IMA and audit.
    
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: John Johansen <john.johansen@canonical.com>
    Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
    Acked-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Cc: linux-integrity@vger.kernel.org
    Cc: linux-audit@redhat.com
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  18. LSM: Use lsmblob in security_task_getsecid

    Change the security_task_getsecid_subj() and
    security_task_getsecid_obj() interfaces to fill in
    a lsmblob structure instead of a u32 secid in support of
    LSM stacking. Audit interfaces will need to collect all
    possible secids for possible reporting.
    
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: John Johansen <john.johansen@canonical.com>
    Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
    Acked-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Cc: linux-integrity@vger.kernel.org
    Cc: linux-audit@redhat.com
    Cc: netdev@vger.kernel.org
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  19. LSM: Use lsmblob in security_ipc_getsecid

    There may be more than one LSM that provides IPC data
    for auditing. Change security_ipc_getsecid() to fill in
    a lsmblob structure instead of the u32 secid. The
    audit data structure containing the secid will be updated
    later, so there is a bit of scaffolding here.
    
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: John Johansen <john.johansen@canonical.com>
    Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
    Acked-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Cc: linux-audit@redhat.com
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  20. LSM: Use lsmblob in security_secid_to_secctx

    Change security_secid_to_secctx() to take a lsmblob as input
    instead of a u32 secid. It will then call the LSM hooks
    using the lsmblob element allocated for that module. The
    callers have been updated as well. This allows for the
    possibility that more than one module may be called upon
    to translate a secid to a string, as can occur in the
    audit code.
    
    Acked-by: Paul Moore <paul@paul-moore.com>
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Cc: netdev@vger.kernel.org
    Cc: linux-audit@redhat.com
    Cc: netfilter-devel@vger.kernel.org
    To: Pablo Neira Ayuso <pablo@netfilter.org>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  21. LSM: Use lsmblob in security_secctx_to_secid

    Change the security_secctx_to_secid interface to use a lsmblob
    structure in place of the single u32 secid in support of
    module stacking. Change its callers to do the same.
    
    The security module hook is unchanged, still passing back a secid.
    The infrastructure passes the correct entry from the lsmblob.
    
    Acked-by: Paul Moore <paul@paul-moore.com>
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Cc: netdev@vger.kernel.org
    Cc: netfilter-devel@vger.kernel.org
    To: Pablo Neira Ayuso <pablo@netfilter.org>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  22. LSM: Use lsmblob in security_kernel_act_as

    Change the security_kernel_act_as interface to use a lsmblob
    structure in place of the single u32 secid in support of
    module stacking. Change its only caller, set_security_override,
    to do the same. Change that one's only caller,
    set_security_override_from_ctx, to call it with the new
    parameter type.
    
    The security module hook is unchanged, still taking a secid.
    The infrastructure passes the correct entry from the lsmblob.
    lsmblob_init() is used to fill the lsmblob structure, however
    this will be removed later in the series when security_secctx_to_secid()
    is updated to provide a lsmblob instead of a secid.
    
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: John Johansen <john.johansen@canonical.com>
    Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
    Acked-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    To: David Howells <dhowells@redhat.com>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  23. LSM: Use lsmblob in security_audit_rule_match

    Change the secid parameter of security_audit_rule_match
    to a lsmblob structure pointer. Pass the entry from the
    lsmblob structure for the approprite slot to the LSM hook.
    
    Change the users of security_audit_rule_match to use the
    lsmblob instead of a u32. The scaffolding function lsmblob_init()
    fills the blob with the value of the old secid, ensuring that
    it is available to the appropriate module hook. The sources of
    the secid, security_task_getsecid() and security_inode_getsecid(),
    will be converted to use the blob structure later in the series.
    At the point the use of lsmblob_init() is dropped.
    
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Acked-by: Paul Moore <paul@paul-moore.com>
    Cc: linux-audit@redhat.com
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  24. IMA: avoid label collisions with stacked LSMs

    Integrity measurement may filter on security module information
    and needs to be clear in the case of multiple active security
    modules which applies. Provide a boot option ima_rules_lsm= to
    allow the user to specify an active security module to apply
    filters to. If not specified, use the first registered module
    that supports the audit_rule_match() LSM hook. Allow the user
    to specify in the IMA policy an lsm= option to specify the
    security module to use for a particular rule.
    
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    To: Mimi Zohar <zohar@linux.ibm.com>
    To: linux-integrity@vger.kernel.org
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  25. LSM: provide lsm name and id slot mappings

    Provide interfaces to map LSM slot numbers and LSM names.
    Update the LSM registration code to save this information.
    
    Acked-by: Paul Moore <paul@paul-moore.com>
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  26. LSM: Add the lsmblob data structure.

    When more than one security module is exporting data to
    audit and networking sub-systems a single 32 bit integer
    is no longer sufficient to represent the data. Add a
    structure to be used instead.
    
    The lsmblob structure is currently an array of
    u32 "secids". There is an entry for each of the
    security modules built into the system that would
    use secids if active. The system assigns the module
    a "slot" when it registers hooks. If modules are
    compiled in but not registered there will be unused
    slots.
    
    A new lsm_id structure, which contains the name
    of the LSM and its slot number, is created. There
    is an instance for each LSM, which assigns the name
    and passes it to the infrastructure to set the slot.
    
    The audit rules data is expanded to use an array of
    security module data rather than a single instance.
    A new structure audit_lsm_rules is defined to avoid the
    confusion which commonly accompanies the use of
    void ** parameters.
    
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  27. LSM: Infrastructure management of the sock security

    Move management of the sock->sk_security blob out
    of the individual security modules and into the security
    infrastructure. Instead of allocating the blobs from within
    the modules the modules tell the infrastructure how much
    space is required, and the space is allocated there.
    
    Acked-by: Paul Moore <paul@paul-moore.com>
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: John Johansen <john.johansen@canonical.com>
    Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021
  28. integrity: disassociate ima_filter_rule from security_audit_rule

    Create real functions for the ima_filter_rule interfaces.
    These replace #defines that obscure the reuse of audit
    interfaces. The new fuctions are put in security.c because
    they use security module registered hooks that we don't
    want exported.
    
    Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
    Acked-by: Paul Moore <paul@paul-moore.com>
    cschaufler authored and intel-lab-lkp committed Dec 14, 2021

Commits on Nov 30, 2021

  1. netfilter: ctnetlink: remove useless type conversion to bool

    dying is bool, the type conversion to true/false value is not
    needed.
    
    Signed-off-by: Bernard Zhao <bernard@vivo.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Bernard Zhao authored and ummakynes committed Nov 30, 2021
  2. netfilter: nf_queue: remove leftover synchronize_rcu

    Its no longer needed after commit 8702997
    ("netfilter: nf_queue: move hookfn registration out of struct net").
    
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Florian Westphal authored and ummakynes committed Nov 30, 2021
  3. netfilter: conntrack: Use memset_startat() to zero struct nf_conn

    In preparation for FORTIFY_SOURCE performing compile-time and run-time
    field bounds checking for memset(), avoid intentionally writing across
    neighboring fields.
    
    Use memset_startat() to avoid confusing memset() about writing beyond
    the target struct member.
    
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    kees authored and ummakynes committed Nov 30, 2021
  4. ipvs: remove unused variable for ip_vs_new_dest

    The dest variable is not used after ip_vs_new_dest anymore in
    ip_vs_add_dest, do not need pass it to ip_vs_new_dest, remove it.
    
    Signed-off-by: GuoYong Zheng <zhenggy@chinatelecom.cn>
    Acked-by: Julian Anastasov <ja@ssi.bg>
    Acked-by: Simon Horman <horms@verge.net.au>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    GuoYong Zheng authored and ummakynes committed Nov 30, 2021
  5. net: ixp4xx_hss: drop kfree for memory allocated with devm_kzalloc

    It's not necessary to free memory allocated with devm_kzalloc
    and using kfree leads to a double free.
    
    Fixes: 35aefaa ("net: ixp4xx_hss: Convert to use DT probing")
    Reported-by: Hulk Robot <hulkci@huawei.com>
    Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Wei Yongjun authored and davem330 committed Nov 30, 2021
  6. net: mscc: ocelot: fix mutex_lock not released

    If err is true, the function will be returned, but mutex_lock isn't
    released.
    
    Reported-by: Zeal Robot <zealci@zte.com.cn>
    Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Lv Ruyi authored and davem330 committed Nov 30, 2021
  7. net: hns3: make symbol 'hclge_mac_speed_map_to_fw' static

    The sparse tool complains as follows:
    
    drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c:2656:28: warning:
     symbol 'hclge_mac_speed_map_to_fw' was not declared. Should it be static?
    
    This symbol is not used outside of hclge_main.c, so marks it static.
    
    Fixes: e46da6a ("net: hns3: refine function hclge_cfg_mac_speed_dup_hw()")
    Reported-by: Hulk Robot <hulkci@huawei.com>
    Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Wei Yongjun authored and davem330 committed Nov 30, 2021
Older