This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Make _get_sock_addr return correct address in older kernel


Hi, everyone

I found _get_sock_addr sometimes failed getting correct address in older kernel as 2.6.9~2.6.15.
It cause memory-access-error in socket.send, socket.aio_write, socket.readv, and .etc.

For example, in probe socket.send:
Pass 5: starting run.
ERROR: kernel read fault at 0x0000000000000027 ((&(sktp->sk)))
WARNING: Number of errors: 1, skipped probes: 0
Pass 5: run completed in 21usr/582sys/640real ms.

It is because filep->private_data is not valid in older version of kernel, and can be fixed by following patch.
Patched code can support both old and new kernel.

If no objection, I will commit it.

Signed-off-by: Zhaolei <zhaolei@cn.fujitsu.com>

diff --git a/tapset/socket.stp b/tapset/socket.stp
index 54a7c71..3197a0e 100644
--- a/tapset/socket.stp
+++ b/tapset/socket.stp
@@ -910,7 +910,14 @@ function _success_check(ret:long)
 function _get_sock_addr:long (file:long)
 %{ /* pure */
        struct file *filep = (struct file *)(long)(THIS->file);
-       struct socket *sockp = filep? kread(&(filep->private_data)) : NULL;
+       struct socket *sockp;
+       if (filep) {
+               struct dentry *dentry = kread(&(filep->f_dentry));
+               struct inode *inode = kread(&(dentry->d_inode));
+               sockp = &container_of(inode, struct socket_alloc, vfs_inode)->socket;
+       } else {
+               sockp = NULL;
+       }
        if (sockp == NULL)
                THIS->__retvalue = -1;
        else

Regards
Zhaolei

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]