Thread (12 messages) read the whole thread 12 messages, 3 authors, 2020-11-24

Re: [PATCH bpf-next 1/3] ima: Implement ima_inode_hash

From: KP Singh <hidden>
Date: 2020-11-21 00:09:09
Also in: bpf, lkml

[...]
quoted
diff --git a/scripts/bpf_helpers_doc.py b/scripts/bpf_helpers_doc.py
index c5bc947a70ad..add7fcb32dcd 100755
--- a/scripts/bpf_helpers_doc.py
+++ b/scripts/bpf_helpers_doc.py
@@ -478,6 +478,7 @@ class PrinterHelpers(Printer):
              'struct tcp_request_sock',
              'struct udp6_sock',
              'struct task_struct',
+            'struct inode',
This change (bpf_helpers_doc.py) belongs to patch #2.
Indeed, I missed it during a rebase. Thanks!

quoted
              'struct path',
              'struct btf_ptr',
      }
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 2d1af8899cab..1dd2123b5b43 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -501,37 +501,17 @@ int ima_file_check(struct file *file, int mask)
  }
  EXPORT_SYMBOL_GPL(ima_file_check);

-/**
- * ima_file_hash - return the stored measurement if a file has been hashed and
- * is in the iint cache.
- * @file: pointer to the file
- * @buf: buffer in which to store the hash
- * @buf_size: length of the buffer
- *
- * On success, return the hash algorithm (as defined in the enum hash_algo).
- * If buf is not NULL, this function also outputs the hash into buf.
- * If the hash is larger than buf_size, then only buf_size bytes will be copied.
- * It generally just makes sense to pass a buffer capable of holding the largest
- * possible hash: IMA_MAX_DIGEST_SIZE.
- * The file hash returned is based on the entire file, including the appended
- * signature.
- *
- * If IMA is disabled or if no measurement is available, return -EOPNOTSUPP.
- * If the parameters are incorrect, return -EINVAL.
- */
-int ima_file_hash(struct file *file, char *buf, size_t buf_size)
+static int __ima_inode_hash(struct inode *inode, char *buf, size_t buf_size)
  {
-     struct inode *inode;
      struct integrity_iint_cache *iint;
      int hash_algo;

-     if (!file)
+     if (!inode)
              return -EINVAL;
Based on original code, for ima_file_hash(), inode cannot be NULL,
so I prefer to remove this change here and add !inode test in
ima_inode_hash.
Makes sense. Thanks!
quoted
[...]

quoted
+ * If the parameters are incorrect, return -EINVAL.
+ */
+int ima_inode_hash(struct inode *inode, char *buf, size_t buf_size)
+{
Add
        if (!inode)
                return -EINVAL;
Done.
quoted
+     return __ima_inode_hash(inode, buf, buf_size);
+}
+EXPORT_SYMBOL_GPL(ima_inode_hash);
+
  /**
   * ima_post_create_tmpfile - mark newly created tmpfile as new
   * @file : newly created tmpfile
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help