| 1 |
=================================== |
| 2 |
Eppic scripts README |
| 3 |
================================== |
| 4 |
|
| 5 |
These eppic scripts are based on the fedora 19 kernel. eppic scripts |
| 6 |
naming convention follows the format: |
| 7 |
<eppic_script name>-<valid from kernel version>_to_<valid until kernel version>.c |
| 8 |
|
| 9 |
For example consider dir_names_3_10_to_3_13.c. This script would scrub |
| 10 |
sensitive information successfully, when run against kernel version >= 3.10 |
| 11 |
and kernel version <= 3.13. |
| 12 |
|
| 13 |
1. Eppic script: proc_names_3_10_to_4_8.c |
| 14 |
Description: Scrubs executable name of each user process |
| 15 |
|
| 16 |
Explanation: |
| 17 |
Walks all processes via the tasks lists starting from init_task |
| 18 |
|
| 19 |
extern struct task_struct init_task; |
| 20 |
|
| 21 |
struct task_struct { |
| 22 |
... |
| 23 |
struct list_head tasks; |
| 24 |
... |
| 25 |
char comm[TASK_COMM_LEN]; /* executable name excluding path */ |
| 26 |
... |
| 27 |
}; |
| 28 |
|
| 29 |
For each user space process clear executable name |
| 30 |
|
| 31 |
struct task_struct *tsk; |
| 32 |
list_for_each_entry(tsk, &init_task, tasks) { |
| 33 |
if (tsk->mm) |
| 34 |
memset(tsk->comm, 0, TASK_COMM_LEN); |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
2. Eppic script: dir_names_3_10_to_3_13.c |
| 39 |
Description: Scrubs filenames of cached dentries |
| 40 |
|
| 41 |
Explanation: |
| 42 |
i) iterate over all mounted filesystems |
| 43 |
|
| 44 |
struct vfsmount { |
| 45 |
struct list_head mnt_hash; |
| 46 |
... |
| 47 |
struct dentry *mnt_root; /* root of the mounted tree */ |
| 48 |
... |
| 49 |
}; |
| 50 |
|
| 51 |
for (u = 0; i < HASH_SIZE; u++) { |
| 52 |
struct vfsmount *mnt; |
| 53 |
list_for_each_entry(mnt, &mount_hashtable[u], mnt_hash) { |
| 54 |
struct dentry *root; |
| 55 |
root = mnt->mnt_root; |
| 56 |
... |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
ii) recursively walk the dentries of each tree starting from root dentry |
| 61 |
and clear d_name and d_iname |
| 62 |
|
| 63 |
struct dentry { |
| 64 |
... |
| 65 |
struct qstr d_name; |
| 66 |
... |
| 67 |
unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */ |
| 68 |
... |
| 69 |
struct list_head d_subdirs; /* our children */ |
| 70 |
... |
| 71 |
}; |
| 72 |
|
| 73 |
void walk_dentries(struct dentry *dentry) |
| 74 |
{ |
| 75 |
struct dentry *child; |
| 76 |
memset(dentry->d_iname, 0, DNAME_INLINE_LEN); |
| 77 |
memset(dentry->d_name.name, 0, dentry->d_name.len); |
| 78 |
list_for_each_entry(child, &dentry->d_subdirs, d_u.d_child) |
| 79 |
walk_dentries(child); |
| 80 |
} |
| 81 |
|
| 82 |
3. Eppic script: keyring_3_10_to_4_3.c |
| 83 |
Description: Scrubs all entries in the keyring |
| 84 |
|
| 85 |
Explanation: |
| 86 |
Scan the keyring_name_hash hash table |
| 87 |
|
| 88 |
static struct list_head keyring_name_hash[KEYRING_NAME_HASH_SIZE]; |
| 89 |
|
| 90 |
for (i = 0; i < KEYRING_NAME_HASH_SIZE; i++) |
| 91 |
if (!list_empty(&keyring_name_hash[i])) { |
| 92 |
... |
| 93 |
} |
| 94 |
|
| 95 |
For each non-empty list walk all keyring entries |
| 96 |
|
| 97 |
struct key { |
| 98 |
... |
| 99 |
struct key_type *type; /* type of key */ |
| 100 |
... |
| 101 |
unsigned short datalen; /* payload data length */ |
| 102 |
... |
| 103 |
union { |
| 104 |
struct list_head link; |
| 105 |
... |
| 106 |
} type_data; |
| 107 |
... |
| 108 |
union { |
| 109 |
unsigned long value; |
| 110 |
void __rcu *rcudata; |
| 111 |
void *data; |
| 112 |
struct keyring_list __rcu *subscriptions; |
| 113 |
} payload; |
| 114 |
}; |
| 115 |
|
| 116 |
struct key *key; |
| 117 |
list_for_each_entry(key, &keyring_name_hash[i], type_data.link) { |
| 118 |
... |
| 119 |
} |
| 120 |
|
| 121 |
Clear value/rcudata/data dependent on the type of the key. |
| 122 |
|
| 123 |
4. Eppic script: ap_messages_3_10_to_4_8.c |
| 124 |
Description: Clear the message data of all ap_bus requests |
| 125 |
|
| 126 |
Explanation: |
| 127 |
Walk all devices in the LIST_HEAD(ap_device_list); |
| 128 |
|
| 129 |
struct ap_device { |
| 130 |
... |
| 131 |
struct list_head list; /* private list of all AP devices. */ |
| 132 |
... |
| 133 |
struct list_head pendingq; /* List of message sent to AP queue. */ |
| 134 |
int pendingq_count; /* # requests on pendingq list. */ |
| 135 |
struct list_head requestq; /* List of message yet to be sent. */ |
| 136 |
int requestq_count; /* # requests on requestq list. */ |
| 137 |
... |
| 138 |
}; |
| 139 |
|
| 140 |
struct ap_device *device; |
| 141 |
list_for_each_entry(device, &ap_device_list, list) { |
| 142 |
... |
| 143 |
} |
| 144 |
|
| 145 |
For each ap device walk the pendingq and requestq list |
| 146 |
|
| 147 |
struct ap_message { |
| 148 |
struct list_head list; /* Request queueing. */ |
| 149 |
... |
| 150 |
void *message; /* Pointer to message buffer. */ |
| 151 |
size_t length; /* Message length. */ |
| 152 |
... |
| 153 |
}; |
| 154 |
|
| 155 |
struct ap_message *apmsg; |
| 156 |
list_for_each_entry(apmsg, &device->pendingq, list) { |
| 157 |
... |
| 158 |
} |
| 159 |
list_for_each_entry(apmsg, &device->requestq, list) { |
| 160 |
... |
| 161 |
} |
| 162 |
|
| 163 |
For each message in pendingq and requestq clear the message |
| 164 |
|
| 165 |
memset(apmsg->message, 0, apmsg->length); |
| 166 |
|
| 167 |
5. Eppic script: tcp_sk_buf_3_10_to_4_8.c |
| 168 |
Description: Scrub data in tcp socket buffers |
| 169 |
|
| 170 |
Explanation: |
| 171 |
Find tcp domain sockets (struct sock *sk) |
| 172 |
|
| 173 |
tcp sockets: |
| 174 |
|
| 175 |
Iterate from 0 to INET_LHTABLE_SIZE and get inet_list_hashbucket from |
| 176 |
tcp_hash_info.listening_hash[<index>] |
| 177 |
|
| 178 |
for (i = 0; i < INET_LHTABLE_SIZE; i++) { |
| 179 |
struct inet_listen_hashbucket *ilb = &tcp_hashinfo.listening_hash[i]; |
| 180 |
} |
| 181 |
For each hash bucket iterate over ilb->head null list to get sockets: |
| 182 |
struct sock *sk; |
| 183 |
sk_nulls_for_each(sk, node, &ilb->head) { |
| 184 |
... |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
For each socket iterate over the socket buffers in |
| 189 |
sk_receive_queue and sk_write_queue: |
| 190 |
|
| 191 |
struct sock { |
| 192 |
... |
| 193 |
struct sk_buff_head sk_receive_queue; |
| 194 |
... |
| 195 |
struct sk_buff_head sk_write_queue; |
| 196 |
... |
| 197 |
}; |
| 198 |
|
| 199 |
struct sk_buff_head { |
| 200 |
struct sk_buff *next; |
| 201 |
struct sk_buff *prev; |
| 202 |
}; |
| 203 |
|
| 204 |
For each struct sk_buff in the two lists clear the memory referenced |
| 205 |
by skb->data / skb->data_len: |
| 206 |
|
| 207 |
struct sk_buff { |
| 208 |
... |
| 209 |
unsigned int data_len; |
| 210 |
... |
| 211 |
unsigned char *data; |
| 212 |
... |
| 213 |
}; |
| 214 |
|
| 215 |
6. Eppic script: udp_sk_buf_3_10_to_4_8.c |
| 216 |
Description: Scrub data of udp socket buffers |
| 217 |
|
| 218 |
Explanation: |
| 219 |
Find all udp sockets (struct sock *sk) |
| 220 |
|
| 221 |
udp sockets: |
| 222 |
|
| 223 |
Iterate from 0 to udp_table->mask and get udp_hslot from hash table: |
| 224 |
for (i = 0; i < udp->table->mask; i++) { |
| 225 |
struct udp_hslot *hslot = udp_table->hash[i]; |
| 226 |
... |
| 227 |
} |
| 228 |
|
| 229 |
For each hslot iterate over hslot->head null list to get sockets: |
| 230 |
struct sock *sk; |
| 231 |
sk_nulls_for_each(sk, node, &hslot->head) { |
| 232 |
... |
| 233 |
} |
| 234 |
|
| 235 |
For each socket iterate over the socket buffers in |
| 236 |
sk_receive_queue and sk_write_queue. |
| 237 |
|
| 238 |
For each struct sk_buff in the two lists clear the memory referenced |
| 239 |
by skb->data / skb->data_len. |
| 240 |
|
| 241 |
7. Eppic script: unix_sk_buff_3_10_to_4_8.c |
| 242 |
Description: Scrub data of unix socket buffers |
| 243 |
|
| 244 |
Explanation: |
| 245 |
Iterate from 0 to UNIX_HASH_SIZE and then walk the hlist in |
| 246 |
for (i = 0; i < UNIX_HASH_SIZE; i++) { |
| 247 |
struct list_head *list = &unix_socket_table[i]; |
| 248 |
... |
| 249 |
} |
| 250 |
|
| 251 |
Walk each non-empty list in unix_socket_table |
| 252 |
struct sock *sk; |
| 253 |
sk_for_each(sk, node, &unix_socket_table[i]) |
| 254 |
|
| 255 |
For each socket iterate over the socket buffers in |
| 256 |
sk_receive_queue and sk_write_queue. |
| 257 |
|
| 258 |
For each struct sk_buff in the two lists clear the memory referenced |
| 259 |
by skb->data / skb->data_len. |
| 260 |
|
| 261 |
8. Eppic script: vhost_net_buffers_3_10_to_3_18.c |
| 262 |
Description: Scrub socket buffers of guest network I/O |
| 263 |
|
| 264 |
Explanation: |
| 265 |
Scrub socket buffers of guest network I/O |
| 266 |
|
| 267 |
vhost_net instance will be attached to the file's private data. |
| 268 |
To get to the right file check the fdtable for each task, if the file |
| 269 |
has registered its fops with vhost_net_open, if so we can retreive the |
| 270 |
file's private data. |
| 271 |
|
| 272 |
if (task->files->fdt->fd[i]->f_op->open == &vhost_net_open) |
| 273 |
struct vhost_net *net = f->private_data; |
| 274 |
|
| 275 |
struct vhost_net_virtqueue *nvq = &net->vqs[VHOST_NET_VQ_MAX]; |
| 276 |
struct vhost_virtqueue *vq = &nvq->vq; |
| 277 |
struct socket *sock = vq->private_data; |
| 278 |
struct sock *sk = sock->sk; |
| 279 |
|
| 280 |
struct sk_buff *next = sk->sk_receive_queue.next; |
| 281 |
struct sk_buff *prev = sk->sk_receive_queue.prev; |
| 282 |
|
| 283 |
Scrub next->data till the end of the sk_receive_queue and |
| 284 |
sk_write_queue list |
| 285 |
|
| 286 |
|
| 287 |
9. Eppic script: vhost_scsi_buffers_3_10_to_4_8.c |
| 288 |
Description: Scrub buffers involved in guest block I/O |
| 289 |
|
| 290 |
Explanation: |
| 291 |
vhost_scsi instance will be attached to the file's private data. |
| 292 |
to get to the right file check the fdtable for each task, if the |
| 293 |
file has registered its fops with vhost_net_open, if so we can |
| 294 |
retreive the file's private data. |
| 295 |
|
| 296 |
if (task->files->fdt->fd[i]->f_op->open == &vhost_scsi_open) |
| 297 |
vhost_scsi *vs = task->files->fdt->fd[i]->private_data; |
| 298 |
|
| 299 |
struct vhost_virtqueue *vq = (struct vhost_virtqueue *)vs->vqs[i].vq; |
| 300 |
scrub vq->iov[j].iov_base |