diff options
Diffstat (limited to 'security/tomoyo/mount.c')
-rw-r--r-- | security/tomoyo/mount.c | 55 |
1 files changed, 2 insertions, 53 deletions
diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c index aeac619f787d..7c1c7fdd3681 100644 --- a/security/tomoyo/mount.c +++ b/security/tomoyo/mount.c | |||
@@ -25,57 +25,6 @@ | |||
25 | #define TOMOYO_MOUNT_MAKE_SHARED_KEYWORD "--make-shared" | 25 | #define TOMOYO_MOUNT_MAKE_SHARED_KEYWORD "--make-shared" |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * tomoyo_encode2: Encode binary string to ascii string. | ||
29 | * | ||
30 | * @str: String in binary format. | ||
31 | * | ||
32 | * Returns pointer to @str in ascii format on success, NULL otherwise. | ||
33 | * | ||
34 | * This function uses kzalloc(), so caller must kfree() if this function | ||
35 | * didn't return NULL. | ||
36 | */ | ||
37 | static char *tomoyo_encode2(const char *str) | ||
38 | { | ||
39 | int len = 0; | ||
40 | const char *p = str; | ||
41 | char *cp; | ||
42 | char *cp0; | ||
43 | if (!p) | ||
44 | return NULL; | ||
45 | while (*p) { | ||
46 | const unsigned char c = *p++; | ||
47 | if (c == '\\') | ||
48 | len += 2; | ||
49 | else if (c > ' ' && c < 127) | ||
50 | len++; | ||
51 | else | ||
52 | len += 4; | ||
53 | } | ||
54 | len++; | ||
55 | /* Reserve space for appending "/". */ | ||
56 | cp = kzalloc(len + 10, GFP_NOFS); | ||
57 | if (!cp) | ||
58 | return NULL; | ||
59 | cp0 = cp; | ||
60 | p = str; | ||
61 | while (*p) { | ||
62 | const unsigned char c = *p++; | ||
63 | if (c == '\\') { | ||
64 | *cp++ = '\\'; | ||
65 | *cp++ = '\\'; | ||
66 | } else if (c > ' ' && c < 127) { | ||
67 | *cp++ = c; | ||
68 | } else { | ||
69 | *cp++ = '\\'; | ||
70 | *cp++ = (c >> 6) + '0'; | ||
71 | *cp++ = ((c >> 3) & 7) + '0'; | ||
72 | *cp++ = (c & 7) + '0'; | ||
73 | } | ||
74 | } | ||
75 | return cp0; | ||
76 | } | ||
77 | |||
78 | /** | ||
79 | * tomoyo_mount_acl2 - Check permission for mount() operation. | 28 | * tomoyo_mount_acl2 - Check permission for mount() operation. |
80 | * | 29 | * |
81 | * @r: Pointer to "struct tomoyo_request_info". | 30 | * @r: Pointer to "struct tomoyo_request_info". |
@@ -104,7 +53,7 @@ static int tomoyo_mount_acl2(struct tomoyo_request_info *r, char *dev_name, | |||
104 | int error = -ENOMEM; | 53 | int error = -ENOMEM; |
105 | 54 | ||
106 | /* Get fstype. */ | 55 | /* Get fstype. */ |
107 | requested_type = tomoyo_encode2(type); | 56 | requested_type = tomoyo_encode(type); |
108 | if (!requested_type) | 57 | if (!requested_type) |
109 | goto out; | 58 | goto out; |
110 | rtype.name = requested_type; | 59 | rtype.name = requested_type; |
@@ -155,7 +104,7 @@ static int tomoyo_mount_acl2(struct tomoyo_request_info *r, char *dev_name, | |||
155 | /* Map dev_name to "<NULL>" if no dev_name given. */ | 104 | /* Map dev_name to "<NULL>" if no dev_name given. */ |
156 | if (!dev_name) | 105 | if (!dev_name) |
157 | dev_name = "<NULL>"; | 106 | dev_name = "<NULL>"; |
158 | requested_dev_name = tomoyo_encode2(dev_name); | 107 | requested_dev_name = tomoyo_encode(dev_name); |
159 | if (!requested_dev_name) { | 108 | if (!requested_dev_name) { |
160 | error = -ENOMEM; | 109 | error = -ENOMEM; |
161 | goto out; | 110 | goto out; |