diff options
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 39 |
1 files changed, 38 insertions, 1 deletions
@@ -42,7 +42,6 @@ | |||
42 | #include <linux/pid_namespace.h> | 42 | #include <linux/pid_namespace.h> |
43 | #include <linux/module.h> | 43 | #include <linux/module.h> |
44 | #include <linux/namei.h> | 44 | #include <linux/namei.h> |
45 | #include <linux/proc_fs.h> | ||
46 | #include <linux/mount.h> | 45 | #include <linux/mount.h> |
47 | #include <linux/security.h> | 46 | #include <linux/security.h> |
48 | #include <linux/syscalls.h> | 47 | #include <linux/syscalls.h> |
@@ -1624,6 +1623,41 @@ expand_fail: | |||
1624 | return ret; | 1623 | return ret; |
1625 | } | 1624 | } |
1626 | 1625 | ||
1626 | static int cn_print_exe_file(struct core_name *cn) | ||
1627 | { | ||
1628 | struct file *exe_file; | ||
1629 | char *pathbuf, *path, *p; | ||
1630 | int ret; | ||
1631 | |||
1632 | exe_file = get_mm_exe_file(current->mm); | ||
1633 | if (!exe_file) | ||
1634 | return cn_printf(cn, "(unknown)"); | ||
1635 | |||
1636 | pathbuf = kmalloc(PATH_MAX, GFP_TEMPORARY); | ||
1637 | if (!pathbuf) { | ||
1638 | ret = -ENOMEM; | ||
1639 | goto put_exe_file; | ||
1640 | } | ||
1641 | |||
1642 | path = d_path(&exe_file->f_path, pathbuf, PATH_MAX); | ||
1643 | if (IS_ERR(path)) { | ||
1644 | ret = PTR_ERR(path); | ||
1645 | goto free_buf; | ||
1646 | } | ||
1647 | |||
1648 | for (p = path; *p; p++) | ||
1649 | if (*p == '/') | ||
1650 | *p = '!'; | ||
1651 | |||
1652 | ret = cn_printf(cn, "%s", path); | ||
1653 | |||
1654 | free_buf: | ||
1655 | kfree(pathbuf); | ||
1656 | put_exe_file: | ||
1657 | fput(exe_file); | ||
1658 | return ret; | ||
1659 | } | ||
1660 | |||
1627 | /* format_corename will inspect the pattern parameter, and output a | 1661 | /* format_corename will inspect the pattern parameter, and output a |
1628 | * name into corename, which must have space for at least | 1662 | * name into corename, which must have space for at least |
1629 | * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator. | 1663 | * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator. |
@@ -1695,6 +1729,9 @@ static int format_corename(struct core_name *cn, long signr) | |||
1695 | case 'e': | 1729 | case 'e': |
1696 | err = cn_printf(cn, "%s", current->comm); | 1730 | err = cn_printf(cn, "%s", current->comm); |
1697 | break; | 1731 | break; |
1732 | case 'E': | ||
1733 | err = cn_print_exe_file(cn); | ||
1734 | break; | ||
1698 | /* core limit size */ | 1735 | /* core limit size */ |
1699 | case 'c': | 1736 | case 'c': |
1700 | err = cn_printf(cn, "%lu", | 1737 | err = cn_printf(cn, "%lu", |