[PATCH 07/10] Scrub data of unix socket buffers
Aruna Balakrishnaiah
aruna at linux.vnet.ibm.com
Thu Feb 27 01:31:45 EST 2014
Iterate from 0 to UNIX_HASH_SIZE and then walk the hlist in
for (i = 0; i < UNIX_HASH_SIZE; i++) {
struct list_head *list = &unix_socket_table[i];
...
}
Walk each non-empty list in unix_socket_table
struct sock *sk;
sk_for_each(sk, node, &unix_socket_table[i])
For each socket iterate over the socket buffers in
sk_receive_queue and sk_write_queue:
struct sock {
...
struct sk_buff_head sk_receive_queue;
...
struct sk_buff_head sk_write_queue;
...
};
struct sk_buff_head {
struct sk_buff *next;
struct sk_buff *prev;
};
For each struct sk_buff in the two lists clear the memory referenced
by skb->data / skb->data_len:
struct sk_buff {
...
unsigned int data_len;
...
unsigned char *data;
...
};
Signed-off-by: Aruna Balakrishnaiah <aruna at linux.vnet.ibm.com>
---
eppic_scripts/unix_sk_buff.c | 81 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
create mode 100644 eppic_scripts/unix_sk_buff.c
diff --git a/eppic_scripts/unix_sk_buff.c b/eppic_scripts/unix_sk_buff.c
new file mode 100644
index 0000000..6ab1e6c
--- /dev/null
+++ b/eppic_scripts/unix_sk_buff.c
@@ -0,0 +1,81 @@
+string
+sunix_opt()
+{
+ return "l";
+}
+
+string
+sunix_usage()
+{
+ return "\n";
+}
+
+static void
+sunix_showusage()
+{
+ printf("usage : sunix %s", sunix_usage());
+}
+
+string
+sunix_help()
+{
+ return "Help";
+}
+
+int
+sunix()
+{
+ int i;
+ int size;
+ struct hlist_head **tab;
+ struct sock_common *off = 0;
+
+ tab = &unix_socket_table;
+
+ for (i = 0; i < 256; i++) {
+ struct hlist_node *pos;
+ struct hlist_node *node;
+ struct hlist_head *tmp;
+
+ tmp = (struct hlist_head *)(tab + i);
+ pos = tmp->first;
+
+ while (pos) {
+ struct sock *sk;
+ struct sk_buff *next;
+ struct sk_buff_head *head;
+
+ sk = (struct sock *)((unsigned long)pos - (unsigned long)&(off->skc_dontcopy_begin));
+
+ head = (struct sk_buff_head *)&(sk->sk_receive_queue);
+ next = (struct sk_buff *)sk->sk_receive_queue.next;
+
+ while (next != head)
+ {
+ struct sk_buff *buff = (struct sk_buff *)next;
+
+ memset((char *)buff->data, 'L', buff->data_len);
+ memset((char *)&(buff->data_len), 'L', 0x4);
+
+ next = buff->next;
+ }
+
+ head = (struct sk_buff_head *)&(sk->sk_write_queue);
+ next = (struct sk_buff *)sk->sk_write_queue.next;
+
+ while (next != head)
+ {
+ struct sk_buff *buff = (struct sk_buff *)next;
+
+ memset((char *)buff->data, 'L', buff->data_len);
+ memset((char *)&(buff->data_len), 'L', 0x4);
+
+ next = buff->next;
+ }
+
+ node = (struct hlist_node *)((unsigned long)sk + (unsigned long)&(off->skc_dontcopy_begin));
+ pos = node->next;
+ }
+ }
+ return 1;
+}
More information about the kexec
mailing list