summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorNitin Kumbhar <nkumbhar@nvidia.com>2012-11-22 14:59:31 +0530
committerDan Willemsen <dwillemsen@nvidia.com>2013-09-14 13:15:11 -0700
commitd4e9800e34c2b6efdd8ad668926e11002905daed (patch)
treeb681b540bc6ac662e3975ba4734cddf4970cec9e /security
parent80c32af80e3a4f7e05003f58857d48ffbcdc7999 (diff)
Fix build issues from linux-3.7-rc1 merge.
Change-Id: Iad130dc9ea776302376319e0cfdcfe72057b8354
Diffstat (limited to 'security')
-rw-r--r--security/tf_driver/tf_util.c195
1 files changed, 92 insertions, 103 deletions
diff --git a/security/tf_driver/tf_util.c b/security/tf_driver/tf_util.c
index 303a5edefc03..b09c2af80447 100644
--- a/security/tf_driver/tf_util.c
+++ b/security/tf_driver/tf_util.c
@@ -858,7 +858,6 @@ int tf_get_current_process_hash(void *hash)
int result = 0;
void *buffer;
struct mm_struct *mm;
- struct vm_area_struct *vma;
buffer = internal_kmalloc(PAGE_SIZE, GFP_KERNEL);
if (buffer == NULL) {
@@ -871,73 +870,69 @@ int tf_get_current_process_hash(void *hash)
mm = current->mm;
down_read(&(mm->mmap_sem));
- for (vma = mm->mmap; vma != NULL; vma = vma->vm_next) {
- if ((vma->vm_flags & VM_EXECUTABLE) != 0 && vma->vm_file
- != NULL) {
- struct dentry *dentry;
- unsigned long start;
- unsigned long cur;
- unsigned long end;
- struct sha1_ctx sha1;
+ if (mm->exe_file) {
+ struct dentry *dentry;
+ unsigned long start;
+ unsigned long cur;
+ unsigned long end;
+ struct sha1_ctx sha1;
- dentry = dget(vma->vm_file->f_dentry);
+ dentry = dget(mm->exe_file->f_dentry);
+ dprintk(
+ KERN_DEBUG "tf_get_current_process_hash: "
+ "Found executable VMA for inode %lu "
+ "(%lu bytes).\n",
+ dentry->d_inode->i_ino,
+ (unsigned long) (dentry->d_inode->
+ i_size));
+
+ start = do_mmap_pgoff(mm->exe_file, 0,
+ dentry->d_inode->i_size,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE, 0);
+ if (start < 0) {
dprintk(
- KERN_DEBUG "tf_get_current_process_hash: "
- "Found executable VMA for inode %lu "
- "(%lu bytes).\n",
- dentry->d_inode->i_ino,
- (unsigned long) (dentry->d_inode->
- i_size));
-
- start = do_mmap(vma->vm_file, 0,
- dentry->d_inode->i_size,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE, 0);
- if (start < 0) {
+ KERN_ERR "tf_get_current_process_hash"
+ "Hash: do_mmap failed (error %d)!\n",
+ (int) start);
+ dput(dentry);
+ result = -EFAULT;
+ goto out;
+ }
+
+ end = start + dentry->d_inode->i_size;
+
+ sha1_init(&sha1);
+ cur = start;
+ while (cur < end) {
+ unsigned long chunk;
+
+ chunk = end - cur;
+ if (chunk > PAGE_SIZE)
+ chunk = PAGE_SIZE;
+ if (copy_from_user(buffer, (const void *) cur,
+ chunk) != 0) {
dprintk(
- KERN_ERR "tf_get_current_process_hash"
- "Hash: do_mmap failed (error %d)!\n",
- (int) start);
+ KERN_ERR "tf_get_current_"
+ "process_hash: copy_from_user "
+ "failed!\n");
+ result = -EINVAL;
+ (void) do_munmap(mm, start,
+ dentry->d_inode->i_size);
dput(dentry);
- result = -EFAULT;
- goto vma_out;
+ goto out;
}
-
- end = start + dentry->d_inode->i_size;
-
- sha1_init(&sha1);
- cur = start;
- while (cur < end) {
- unsigned long chunk;
-
- chunk = end - cur;
- if (chunk > PAGE_SIZE)
- chunk = PAGE_SIZE;
- if (copy_from_user(buffer, (const void *) cur,
- chunk) != 0) {
- dprintk(
- KERN_ERR "tf_get_current_"
- "process_hash: copy_from_user "
- "failed!\n");
- result = -EINVAL;
- (void) do_munmap(mm, start,
- dentry->d_inode->i_size);
- dput(dentry);
- goto vma_out;
- }
- sha1_update(&sha1, buffer, chunk);
- cur += chunk;
- }
- sha1_final(&sha1, hash);
- result = 0;
-
- (void) do_munmap(mm, start, dentry->d_inode->i_size);
- dput(dentry);
- break;
+ sha1_update(&sha1, buffer, chunk);
+ cur += chunk;
}
+ sha1_final(&sha1, hash);
+ result = 0;
+
+ (void) do_munmap(mm, start, dentry->d_inode->i_size);
+ dput(dentry);
}
-vma_out:
+out:
up_read(&(mm->mmap_sem));
internal_kfree(buffer);
@@ -960,7 +955,6 @@ int tf_hash_application_path_and_data(char *buffer, void *data,
int result = -ENOENT;
char *tmp = NULL;
struct mm_struct *mm;
- struct vm_area_struct *vma;
tmp = internal_kmalloc(PAGE_SIZE, GFP_KERNEL);
if (tmp == NULL) {
@@ -971,53 +965,48 @@ int tf_hash_application_path_and_data(char *buffer, void *data,
mm = current->mm;
down_read(&(mm->mmap_sem));
- for (vma = mm->mmap; vma != NULL; vma = vma->vm_next) {
- if ((vma->vm_flags & VM_EXECUTABLE) != 0
- && vma->vm_file != NULL) {
- struct path *path;
- char *endpath;
- size_t pathlen;
- struct sha1_ctx sha1;
- u8 hash[SHA1_DIGEST_SIZE];
-
- path = &vma->vm_file->f_path;
-
- endpath = d_path(path, tmp, PAGE_SIZE);
- if (IS_ERR(path)) {
- result = PTR_ERR(endpath);
- up_read(&(mm->mmap_sem));
- goto end;
- }
- pathlen = (tmp + PAGE_SIZE) - endpath;
+ if (mm->exe_file) {
+ struct path *path;
+ char *endpath;
+ size_t pathlen;
+ struct sha1_ctx sha1;
+ u8 hash[SHA1_DIGEST_SIZE];
+
+ path = &mm->exe_file->f_path;
+
+ endpath = d_path(path, tmp, PAGE_SIZE);
+ if (IS_ERR(path)) {
+ result = PTR_ERR(endpath);
+ up_read(&(mm->mmap_sem));
+ goto end;
+ }
+ pathlen = (tmp + PAGE_SIZE) - endpath;
#ifdef CONFIG_TF_DRIVER_DEBUG_SUPPORT
- {
- char *c;
- dprintk(KERN_DEBUG "current process path = ");
- for (c = endpath;
- c < tmp + PAGE_SIZE;
- c++)
- dprintk("%c", *c);
-
- dprintk(", uid=%d, euid=%d\n", current_uid(),
- current_euid());
- }
+ {
+ char *c;
+ dprintk(KERN_DEBUG "current process path = ");
+ for (c = endpath;
+ c < tmp + PAGE_SIZE;
+ c++)
+ dprintk("%c", *c);
+
+ dprintk(", uid=%d, euid=%d\n", current_uid(),
+ current_euid());
+ }
#endif /* defined(CONFIG_TF_DRIVER_DEBUG_SUPPORT) */
- sha1_init(&sha1);
- sha1_update(&sha1, endpath, pathlen);
- if (data != NULL) {
- dprintk(KERN_INFO "current process path: "
- "Hashing additional data\n");
- sha1_update(&sha1, data, data_len);
- }
- sha1_final(&sha1, hash);
- memcpy(buffer, hash, sizeof(hash));
-
- result = 0;
-
- break;
+ sha1_init(&sha1);
+ sha1_update(&sha1, endpath, pathlen);
+ if (data != NULL) {
+ dprintk(KERN_INFO "current process path: "
+ "Hashing additional data\n");
+ sha1_update(&sha1, data, data_len);
}
+ sha1_final(&sha1, hash);
+ memcpy(buffer, hash, sizeof(hash));
+
+ result = 0;
}
up_read(&(mm->mmap_sem));