aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/fs/exec.c b/fs/exec.c
index a682624de572..27d487f913d3 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1649,15 +1649,26 @@ expand_fail:
1649 return ret; 1649 return ret;
1650} 1650}
1651 1651
1652static void cn_escape(char *str)
1653{
1654 for (; *str; str++)
1655 if (*str == '/')
1656 *str = '!';
1657}
1658
1652static int cn_print_exe_file(struct core_name *cn) 1659static int cn_print_exe_file(struct core_name *cn)
1653{ 1660{
1654 struct file *exe_file; 1661 struct file *exe_file;
1655 char *pathbuf, *path, *p; 1662 char *pathbuf, *path;
1656 int ret; 1663 int ret;
1657 1664
1658 exe_file = get_mm_exe_file(current->mm); 1665 exe_file = get_mm_exe_file(current->mm);
1659 if (!exe_file) 1666 if (!exe_file) {
1660 return cn_printf(cn, "%s (path unknown)", current->comm); 1667 char *commstart = cn->corename + cn->used;
1668 ret = cn_printf(cn, "%s (path unknown)", current->comm);
1669 cn_escape(commstart);
1670 return ret;
1671 }
1661 1672
1662 pathbuf = kmalloc(PATH_MAX, GFP_TEMPORARY); 1673 pathbuf = kmalloc(PATH_MAX, GFP_TEMPORARY);
1663 if (!pathbuf) { 1674 if (!pathbuf) {
@@ -1671,9 +1682,7 @@ static int cn_print_exe_file(struct core_name *cn)
1671 goto free_buf; 1682 goto free_buf;
1672 } 1683 }
1673 1684
1674 for (p = path; *p; p++) 1685 cn_escape(path);
1675 if (*p == '/')
1676 *p = '!';
1677 1686
1678 ret = cn_printf(cn, "%s", path); 1687 ret = cn_printf(cn, "%s", path);
1679 1688
@@ -1745,16 +1754,22 @@ static int format_corename(struct core_name *cn, long signr)
1745 break; 1754 break;
1746 } 1755 }
1747 /* hostname */ 1756 /* hostname */
1748 case 'h': 1757 case 'h': {
1758 char *namestart = cn->corename + cn->used;
1749 down_read(&uts_sem); 1759 down_read(&uts_sem);
1750 err = cn_printf(cn, "%s", 1760 err = cn_printf(cn, "%s",
1751 utsname()->nodename); 1761 utsname()->nodename);
1752 up_read(&uts_sem); 1762 up_read(&uts_sem);
1763 cn_escape(namestart);
1753 break; 1764 break;
1765 }
1754 /* executable */ 1766 /* executable */
1755 case 'e': 1767 case 'e': {
1768 char *commstart = cn->corename + cn->used;
1756 err = cn_printf(cn, "%s", current->comm); 1769 err = cn_printf(cn, "%s", current->comm);
1770 cn_escape(commstart);
1757 break; 1771 break;
1772 }
1758 case 'E': 1773 case 'E':
1759 err = cn_print_exe_file(cn); 1774 err = cn_print_exe_file(cn);
1760 break; 1775 break;