An error occurred fetching the project authors.
  1. 16 Feb, 2024 1 commit
  2. 31 Oct, 2023 1 commit
  3. 23 May, 2023 1 commit
  4. 31 Jan, 2023 2 commits
    • Roberto Sassu's avatar
      ima: Introduce MMAP_CHECK_REQPROT hook · 4958db32
      Roberto Sassu authored
      Commit 98de59bf ("take calculation of final prot in
      security_mmap_file() into a helper") caused ima_file_mmap() to receive the
      protections requested by the application and not those applied by the
      kernel.
      
      After restoring the original MMAP_CHECK behavior, existing attestation
      servers might be broken due to not being ready to handle new entries
      (previously missing) in the IMA measurement list.
      
      Restore the original correct MMAP_CHECK behavior, instead of keeping the
      current buggy one and introducing a new hook with the correct behavior.
      Otherwise, there would have been the risk of IMA users not noticing the
      problem at all, as they would actively have to update the IMA policy, to
      switch to the correct behavior.
      
      Also, introduce the new MMAP_CHECK_REQPROT hook to keep the current
      behavior, so that IMA users could easily fix a broken attestation server,
      although this approach is discouraged due to potentially missing
      measurements.
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      4958db32
    • Roberto Sassu's avatar
      ima: Align ima_file_mmap() parameters with mmap_file LSM hook · 4971c268
      Roberto Sassu authored
      Commit 98de59bf ("take calculation of final prot in
      security_mmap_file() into a helper") moved the code to update prot, to be
      the actual protections applied to the kernel, to a new helper called
      mmap_prot().
      
      However, while without the helper ima_file_mmap() was getting the updated
      prot, with the helper ima_file_mmap() gets the original prot, which
      contains the protections requested by the application.
      
      A possible consequence of this change is that, if an application calls
      mmap() with only PROT_READ, and the kernel applies PROT_EXEC in addition,
      that application would have access to executable memory without having this
      event recorded in the IMA measurement list. This situation would occur for
      example if the application, before mmap(), calls the personality() system
      call with READ_IMPLIES_EXEC as the first argument.
      
      Align ima_file_mmap() parameters with those of the mmap_file LSM hook, so
      that IMA can receive both the requested prot and the final prot. Since the
      requested protections are stored in a new variable, and the final
      protections are stored in the existing variable, this effectively restores
      the original behavior of the MMAP_CHECK hook.
      
      Cc: stable@vger.kernel.org
      Fixes: 98de59bf ("take calculation of final prot in security_mmap_file() into a helper")
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      4971c268
  5. 19 Jan, 2023 1 commit
    • Christian Brauner's avatar
      fs: port xattr to mnt_idmap · 39f60c1c
      Christian Brauner authored
      Convert to struct mnt_idmap.
      
      Last cycle we merged the necessary infrastructure in
      256c8aed ("fs: introduce dedicated idmap type for mounts").
      This is just the conversion to struct mnt_idmap.
      
      Currently we still pass around the plain namespace that was attached to a
      mount. This is in general pretty convenient but it makes it easy to
      conflate namespaces that are relevant on the filesystem with namespaces
      that are relevent on the mount level. Especially for non-vfs developers
      without detailed knowledge in this area this can be a potential source for
      bugs.
      
      Once the conversion to struct mnt_idmap is done all helpers down to the
      really low-level helpers will take a struct mnt_idmap argument instead of
      two namespace arguments. This way it becomes impossible to conflate the two
      eliminating the possibility of any bugs. All of the vfs and all filesystems
      only operate on struct mnt_idmap.
      Acked-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      39f60c1c
  6. 18 Jan, 2023 2 commits
  7. 18 Nov, 2022 1 commit
  8. 03 Nov, 2022 1 commit
    • Roberto Sassu's avatar
      ima: Fix memory leak in __ima_inode_hash() · 8c1d6a05
      Roberto Sassu authored
      Commit f3cc6b25 ("ima: always measure and audit files in policy") lets
      measurement or audit happen even if the file digest cannot be calculated.
      
      As a result, iint->ima_hash could have been allocated despite
      ima_collect_measurement() returning an error.
      
      Since ima_hash belongs to a temporary inode metadata structure, declared
      at the beginning of __ima_inode_hash(), just add a kfree() call if
      ima_collect_measurement() returns an error different from -ENOMEM (in that
      case, ima_hash should not have been allocated).
      
      Cc: stable@vger.kernel.org
      Fixes: 280fe836 ("ima: Always return a file measurement in ima_file_hash()")
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      8c1d6a05
  9. 05 May, 2022 1 commit
    • Mimi Zohar's avatar
      ima: permit fsverity's file digests in the IMA measurement list · 54f03916
      Mimi Zohar authored
      Permit fsverity's file digest (a hash of struct fsverity_descriptor) to
      be included in the IMA measurement list, based on the new measurement
      policy rule 'digest_type=verity' option.
      
      To differentiate between a regular IMA file hash from an fsverity's
      file digest, use the new d-ngv2 format field included in the ima-ngv2
      template.
      
      The following policy rule requires fsverity file digests and specifies
      the new 'ima-ngv2' template, which contains the new 'd-ngv2' field.  The
      policy rule may be constrained, for example based on a fsuuid or LSM
      label.
      
      measure func=FILE_CHECK digest_type=verity template=ima-ngv2
      Acked-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      54f03916
  10. 04 Apr, 2022 1 commit
  11. 11 Mar, 2022 2 commits
    • Roberto Sassu's avatar
      ima: Always return a file measurement in ima_file_hash() · 280fe836
      Roberto Sassu authored
      __ima_inode_hash() checks if a digest has been already calculated by
      looking for the integrity_iint_cache structure associated to the passed
      inode.
      
      Users of ima_file_hash() (e.g. eBPF) might be interested in obtaining the
      information without having to setup an IMA policy so that the digest is
      always available at the time they call this function.
      
      In addition, they likely expect the digest to be fresh, e.g. recalculated
      by IMA after a file write. Although getting the digest from the
      bprm_committed_creds hook (as in the eBPF test) ensures that the digest is
      fresh, as the IMA hook is executed before that hook, this is not always the
      case (e.g. for the mmap_file hook).
      
      Call ima_collect_measurement() in __ima_inode_hash(), if the file
      descriptor is available (passed by ima_file_hash()) and the digest is not
      available/not fresh, and store the file measurement in a temporary
      integrity_iint_cache structure.
      
      This change does not cause memory usage increase, due to using the
      temporary integrity_iint_cache structure, and due to freeing the
      ima_digest_data structure inside integrity_iint_cache before exiting from
      __ima_inode_hash().
      
      For compatibility reasons, the behavior of ima_inode_hash() remains
      unchanged.
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Reviewed-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      Link: https://lore.kernel.org/bpf/20220302111404.193900-3-roberto.sassu@huawei.com
      280fe836
    • Roberto Sassu's avatar
      ima: Fix documentation-related warnings in ima_main.c · bae60eef
      Roberto Sassu authored
      Fix the following warnings in ima_main.c, displayed with W=n make argument:
      
      security/integrity/ima/ima_main.c:432: warning: Function parameter or
                                member 'vma' not described in 'ima_file_mprotect'
      security/integrity/ima/ima_main.c:636: warning: Function parameter or
                        member 'inode' not described in 'ima_post_create_tmpfile'
      security/integrity/ima/ima_main.c:636: warning: Excess function parameter
                                  'file' description in 'ima_post_create_tmpfile'
      security/integrity/ima/ima_main.c:843: warning: Function parameter or
                           member 'load_id' not described in 'ima_post_load_data'
      security/integrity/ima/ima_main.c:843: warning: Excess function parameter
                                         'id' description in 'ima_post_load_data'
      
      Also, fix some style issues in the description of ima_post_create_tmpfile()
      and ima_post_path_mknod().
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Reviewed-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Reviewed-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      Link: https://lore.kernel.org/bpf/20220302111404.193900-2-roberto.sassu@huawei.com
      bae60eef
  12. 15 Feb, 2022 3 commits
  13. 22 Nov, 2021 1 commit
  14. 16 Aug, 2021 2 commits
  15. 10 Aug, 2021 1 commit
    • Tushar Sugandhi's avatar
      dm ima: measure data on table load · 91ccbbac
      Tushar Sugandhi authored
      DM configures a block device with various target specific attributes
      passed to it as a table.  DM loads the table, and calls each target’s
      respective constructors with the attributes as input parameters.
      Some of these attributes are critical to ensure the device meets
      certain security bar.  Thus, IMA should measure these attributes, to
      ensure they are not tampered with, during the lifetime of the device.
      So that the external services can have high confidence in the
      configuration of the block-devices on a given system.
      
      Some devices may have large tables.  And a given device may change its
      state (table-load, suspend, resume, rename, remove, table-clear etc.)
      many times.  Measuring these attributes each time when the device
      changes its state will significantly increase the size of the IMA logs.
      Further, once configured, these attributes are not expected to change
      unless a new table is loaded, or a device is removed and recreated.
      Therefore the clear-text of the attributes should only be measured
      during table load, and the hash of the active/inactive table should be
      measured for the remaining device state changes.
      
      Export IMA function ima_measure_critical_data() to allow measurement
      of DM device parameters, as well as target specific attributes, during
      table load.  Compute the hash of the inactive table and store it for
      measurements during future state change.  If a load is called multiple
      times, update the inactive table hash with the hash of the latest
      populated table.  So that the correct inactive table hash is measured
      when the device transitions to different states like resume, remove,
      rename, etc.
      Signed-off-by: default avatarTushar Sugandhi <tusharsu@linux.microsoft.com>
      Signed-off-by: Colin Ian King <colin.king@canonical.com> # leak fix
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      91ccbbac
  16. 23 Jul, 2021 3 commits
    • Roberto Sassu's avatar
      ima: Add digest and digest_len params to the functions to measure a buffer · ca3c9bdb
      Roberto Sassu authored
      This patch performs the final modification necessary to pass the buffer
      measurement to callers, so that they provide a functionality similar to
      ima_file_hash(). It adds the 'digest' and 'digest_len' parameters to
      ima_measure_critical_data() and process_buffer_measurement().
      
      These functions calculate the digest even if there is no suitable rule in
      the IMA policy and, in this case, they simply return 1 before generating a
      new measurement entry.
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: default avatarLakshmi Ramasubramanian <nramas@linux.microsoft.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      ca3c9bdb
    • Roberto Sassu's avatar
      ima: Return int in the functions to measure a buffer · ce5bb5a8
      Roberto Sassu authored
      ima_measure_critical_data() and process_buffer_measurement() currently
      don't return a result as, unlike appraisal-related functions, the result is
      not used by callers to deny an operation. Measurement-related functions
      instead rely on the audit subsystem to notify the system administrator when
      an error occurs.
      
      However, ima_measure_critical_data() and process_buffer_measurement() are a
      special case, as these are the only functions that can return a buffer
      measurement (for files, there is ima_file_hash()). In a subsequent patch,
      they will be modified to return the calculated digest.
      
      In preparation to return the result of the digest calculation, this patch
      modifies the return type from void to int, and returns 0 if the buffer has
      been successfully measured, a negative value otherwise.
      
      Given that the result of the measurement is still not necessary, this patch
      does not modify the behavior of existing callers by processing the returned
      value. For those, the return value is ignored.
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: default avatarLakshmi Ramasubramanian <nramas@linux.microsoft.com>
      Acked-by: Paul Moore <paul@paul-moore.com> (for the SELinux bits)
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      ce5bb5a8
    • Roberto Sassu's avatar
      ima: Introduce ima_get_current_hash_algo() · 5d1ef2ce
      Roberto Sassu authored
      Buffer measurements, unlike file measurements, are not accessible after the
      measurement is done, as buffers are not suitable for use with the
      integrity_iint_cache structure (there is no index, for files it is the
      inode number). In the subsequent patches, the measurement (digest) will be
      returned directly by the functions that perform the buffer measurement,
      ima_measure_critical_data() and process_buffer_measurement().
      
      A caller of those functions also needs to know the algorithm used to
      calculate the digest. Instead of adding the algorithm as a new parameter to
      the functions, this patch provides it separately with the new function
      ima_get_current_hash_algo().
      
      Since the hash algorithm does not change after the IMA setup phase, there
      is no risk of races (obtaining a digest calculated with a different
      algorithm than the one returned).
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: default avatarLakshmi Ramasubramanian <nramas@linux.microsoft.com>
      [zohar@linux.ibm.com: annotate ima_hash_algo as __ro_after_init]
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      5d1ef2ce
  17. 08 Jun, 2021 1 commit
  18. 20 Apr, 2021 1 commit
  19. 09 Apr, 2021 1 commit
  20. 22 Mar, 2021 2 commits
    • Paul Moore's avatar
      lsm: separate security_task_getsecid() into subjective and objective variants · 4ebd7651
      Paul Moore authored
      Of the three LSMs that implement the security_task_getsecid() LSM
      hook, all three LSMs provide the task's objective security
      credentials.  This turns out to be unfortunate as most of the hook's
      callers seem to expect the task's subjective credentials, although
      a small handful of callers do correctly expect the objective
      credentials.
      
      This patch is the first step towards fixing the problem: it splits
      the existing security_task_getsecid() hook into two variants, one
      for the subjective creds, one for the objective creds.
      
        void security_task_getsecid_subj(struct task_struct *p,
      				   u32 *secid);
        void security_task_getsecid_obj(struct task_struct *p,
      				  u32 *secid);
      
      While this patch does fix all of the callers to use the correct
      variant, in order to keep this patch focused on the callers and to
      ease review, the LSMs continue to use the same implementation for
      both hooks.  The net effect is that this patch should not change
      the behavior of the kernel in any way, it will be up to the latter
      LSM specific patches in this series to change the hook
      implementations and return the correct credentials.
      
      Acked-by: Mimi Zohar <zohar@linux.ibm.com> (IMA)
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Reviewed-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      4ebd7651
    • Mimi Zohar's avatar
      ima: without an IMA policy loaded, return quickly · f873b28f
      Mimi Zohar authored
      Unless an IMA policy is loaded, don't bother checking for an appraise
      policy rule.  Return immediately.
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      f873b28f
  21. 24 Jan, 2021 1 commit
  22. 15 Jan, 2021 4 commits
  23. 25 Nov, 2020 1 commit
  24. 20 Nov, 2020 1 commit
    • Lakshmi Ramasubramanian's avatar
      ima: select ima-buf template for buffer measurement · dea87d08
      Lakshmi Ramasubramanian authored
      The default IMA template used for all policy rules is the value set
      for CONFIG_IMA_DEFAULT_TEMPLATE if the policy rule does not specify
      a template. The default IMA template for buffer measurements should be
      'ima-buf' - so that the measured buffer is correctly included in the IMA
      measurement log entry.
      
      With the default template format, buffer measurements are added to
      the measurement list, but do not include the buffer data, making it
      difficult, if not impossible, to validate. Including 'ima-buf'
      template records in the measurement list by default, should not impact
      existing attestation servers without 'ima-buf' template support.
      
      Initialize a global 'ima-buf' template and select that template,
      by default, for buffer measurements.
      Signed-off-by: default avatarLakshmi Ramasubramanian <nramas@linux.microsoft.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      dea87d08
  25. 02 Nov, 2020 1 commit
    • Ard Biesheuvel's avatar
      ima: defer arch_ima_get_secureboot() call to IMA init time · b000d5cb
      Ard Biesheuvel authored
      Chester reports that it is necessary to introduce a new way to pass
      the EFI secure boot status between the EFI stub and the core kernel
      on ARM systems. The usual way of obtaining this information is by
      checking the SecureBoot and SetupMode EFI variables, but this can
      only be done after the EFI variable workqueue is created, which
      occurs in a subsys_initcall(), whereas arch_ima_get_secureboot()
      is called much earlier by the IMA framework.
      
      However, the IMA framework itself is started as a late_initcall,
      and the only reason the call to arch_ima_get_secureboot() occurs
      so early is because it happens in the context of a __setup()
      callback that parses the ima_appraise= command line parameter.
      
      So let's refactor this code a little bit, by using a core_param()
      callback to capture the command line argument, and deferring any
      reasoning based on its contents to the IMA init routine.
      
      Cc: Chester Lin <clin@suse.com>
      Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Link: https://lore.kernel.org/linux-arm-kernel/20200904072905.25332-2-clin@suse.com/Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Reported-by: kernel test robot <lkp@intel.com> [missing core_param()]
      [zohar@linux.ibm.com: included linux/module.h]
      Tested-by: default avatarChester Lin <clin@suse.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      b000d5cb
  26. 05 Oct, 2020 3 commits