Permalink
Browse files

Fix NULL pointer error in really long file names

When execution of a really long file name (or a file in a very deep directory
structure) is denied, a NULL pointer is thrown.

Thanks for the bug report!

Reported by: Panos Sakkos <panos.sakkos@gmail.com>
Fixed by: Me
  • Loading branch information...
cormander committed Apr 5, 2012
1 parent d307305 commit 92e51e22de9bd1773873030341a3933b6824c046
Showing with 12 additions and 5 deletions.
  1. +4 −1 conf/tpe.spec
  2. +6 −3 core.c
  3. +1 −0 module.h
  4. +1 −1 scripts/mk_rpm.sh
View
@@ -4,7 +4,7 @@
Summary: Trusted Path Execution (TPE) Linux Kernel Module
Name: tpe
-Version: 1.0
+Version: 1.0.1
Release: 1%{?dist}
URL: https://github.com/cormander/tpe-lkm
Source0: %{name}-%{version}.tar.gz
@@ -59,6 +59,9 @@ rm -rf $RPM_BUILD_ROOT
/lib/modules/generic/modules.dep
%changelog
+* Wed Apr 4 2012 Corey Henderson <corman@cormander.com>
+- Fixed NULL pointer in denied execution of long file paths
+
* Wed Jul 7 2011 Corey Henderson <corman@cormander.com>
- Initial build.
View
9 core.c
@@ -46,6 +46,7 @@ void parent_task_walk(struct task_struct *task) {
struct task_struct *parent;
char filename[MAX_FILE_LEN];
+ char *path;
int c = 0;
walk:
@@ -59,7 +60,9 @@ void parent_task_walk(struct task_struct *task) {
parent = get_task_parent(task);
- printk("%s (uid:%d)", exe_from_mm(task->mm, filename, MAX_FILE_LEN), get_task_uid(task));
+ path = exe_from_mm(task->mm, filename, MAX_FILE_LEN);
+
+ printk("%s (uid:%d)", (!IS_ERR(path) ? path : "<d_path failed>"), get_task_uid(task));
if (parent && task->pid != 1) {
printk(", ");
@@ -103,9 +106,9 @@ int log_denied_exec(const struct file *file, const char *method, const char *rea
printk(PKPRE "%s untrusted %s of %s (uid:%d) by %s (uid:%d), parents: ",
( tpe_softmode ? "Would deny" : "Denied" ),
method,
- f,
+ (!IS_ERR(f) ? f : "<d_path failed>"),
get_task_uid(current),
- pf,
+ (!IS_ERR(pf) ? pf : "<d_path failed>"),
get_task_uid(parent)
);
View
@@ -14,6 +14,7 @@
#include <linux/fs.h>
#include <linux/jiffies.h>
#include <linux/sysctl.h>
+#include <linux/err.h>
#include <asm/uaccess.h>
#include <asm/insn.h>
View
@@ -1,7 +1,7 @@
#!/bin/bash
module_name=tpe
-v=1.0
+v=1.0.1
RPM_DIR=$(rpm --eval '%{_rpmdir}' 2> /dev/null)
RPM_SOURCES=$(rpm --eval '%{_sourcedir}' 2> /dev/null)

0 comments on commit 92e51e2

Please sign in to comment.