]> sourceware.org Git - systemtap.git/commitdiff
Fix PR16541 by updating the nfsd.stp tapset.
authorDavid Smith <dsmith@redhat.com>
Mon, 10 Feb 2014 19:07:09 +0000 (13:07 -0600)
committerDavid Smith <dsmith@redhat.com>
Mon, 10 Feb 2014 19:07:09 +0000 (13:07 -0600)
* tapset/linux/nfsd.stp: Two fixes. Handle kernels with CONFIG_USER_NS,
  whose uids/gids aren't simple types. In nfsd.close, handle the inlined
  case were we can't find the argument.

tapset/linux/nfsd.stp

index 092f55d3c32e0ef33e45c3e903b283f1cb9210f7..5aa4eb0bdfca0786e1947bf8382454be129333ad 100644 (file)
@@ -146,6 +146,34 @@ function ftype:string(type:long) %{ /* pure */
        }
 %}
 
+function __rqstp_uid:long(rqstp:long)
+{
+%( CONFIG_USER_NS == "y" %?
+       # Notice we're using the 'init_user_ns' here, not
+       # 'current_user_ns()'. This matches up with the use in
+       # net/sunrpc/auth_generic.c.
+       return %{ /* pure */
+                 from_kuid_munged(&init_user_ns,
+                                  ((struct svc_rqst *)STAP_ARG_rqstp)->rq_cred.cr_uid) %}
+%:
+       return @cast(rqstp, "svc_rqst")->rq_cred->cr_uid
+%)
+}
+
+function __rqstp_gid:long(rqstp:long)
+{
+%( CONFIG_USER_NS == "y" %?
+       # Notice we're using the 'init_user_ns' here, not
+       # 'current_user_ns()'. This matches up with the use in
+       # net/sunrpc/auth_generic.c.
+       return %{ /* pure */
+                 from_kgid_munged(&init_user_ns,
+                                  ((struct svc_rqst *)STAP_ARG_rqstp)->rq_cred.cr_gid) %}
+%:
+       return @cast(rqstp, "svc_rqst")->rq_cred->cr_gid
+%)
+}
+
 /**
  * probe nfsd.dispatch - NFS server receives an operation from client 
  *
@@ -230,8 +258,8 @@ probe nfsd.proc2.lookup = kernel.function("nfsd_proc_lookup") !,
        filelen = $argp->len
        filename = kernel_string_n($argp->name, $argp->len)
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc2.lookup"
        argstr = sprintf("%s", kernel_string_n($argp->name, $argp->len))
@@ -259,8 +287,8 @@ probe nfsd.proc3.lookup = kernel.function("nfsd3_proc_lookup") !,
        filelen = $argp->len
        filename  = kernel_string_n($argp->name, $argp->len)
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc3.lookup"
        argstr = sprintf("%s", kernel_string_n($argp->name, $argp->len))
@@ -306,8 +334,8 @@ probe nfsd.proc4.lookup = kernel.function("nfsd4_lookup").call !,
        filelen = $lookup->lo_len
        filename  = kernel_string_n($lookup->lo_name, $lookup->lo_len)
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc4.lookup"
        argstr = sprintf("%s", kernel_string_n($lookup->lo_name, $lookup->lo_len))
@@ -364,8 +392,8 @@ probe nfsd.proc2.read = kernel.function("nfsd_proc_read") !,
        vec = @choose_defined($rqstp->rq_vec, $argp->vec)
        vlen = $argp->vlen
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc2.read"
        argstr = sprintf("%d,%d",count,offset)
@@ -398,8 +426,8 @@ probe nfsd.proc3.read = kernel.function("nfsd3_proc_read") !,
        vec = @choose_defined($rqstp->rq_vec, $argp->vec)
        vlen = $argp->vlen
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc3.read"
        argstr = sprintf("%d,%d",count,offset)
@@ -432,8 +460,8 @@ probe nfsd.proc4.read = kernel.function("nfsd4_read").call !,
        vec = $rqstp->rq_vec
        vlen = $read->rd_vlen
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc4.read"
        argstr = sprintf("%d,%d",count,offset)
@@ -494,8 +522,8 @@ probe nfsd.proc2.write = kernel.function("nfsd_proc_write") !,
        vlen = $argp->vlen
        stable = 1                      # hardcoded in nfsd_proc_write()
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc2.write"
        argstr = sprintf("%d,%d",count,offset)
@@ -531,8 +559,8 @@ probe nfsd.proc3.write = kernel.function("nfsd3_proc_write") !,
        vlen = $argp->vlen
        stable = $argp->stable
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc3.write"
        argstr = sprintf("%d,%d",count,offset)
@@ -567,8 +595,8 @@ probe nfsd.proc4.write = kernel.function("nfsd4_write").call !,
        vlen = @choose_defined($write->wr_vlen, 0)
        stable = $write->wr_stable_how
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc4.write"
        argstr = sprintf("%d,%d",count,offset)
@@ -625,8 +653,8 @@ probe nfsd.proc3.commit = kernel.function("nfsd3_proc_commit") !,
        count = $argp->count 
        offset = $argp->offset 
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc3.commit"
        argstr = sprintf("%d,%d",count,offset)
@@ -656,8 +684,8 @@ probe nfsd.proc4.commit = kernel.function("nfsd4_commit").call !,
        count = $commit->co_count 
        offset = $commit->co_offset 
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc4.commit"
        argstr = sprintf("%d,%d",count,offset)
@@ -712,8 +740,8 @@ probe nfsd.proc2.create = kernel.function("nfsd_proc_create") !,
        filename  = kernel_string_n($argp->name, $argp->len)
        createmode = 0                  # gets computed by nfsd_proc_create
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc2.create"
        argstr = sprintf("%s", kernel_string_n($argp->name, $argp->len))
@@ -742,8 +770,8 @@ probe nfsd.proc3.create = kernel.function("nfsd3_proc_create") !,
        filename  = kernel_string_n($argp->name, $argp->len)
        createmode = $argp->createmode
        
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc3.create"
        argstr = sprintf("%s (mode=%s)",
@@ -775,8 +803,8 @@ probe nfsd.proc4.create = kernel.function("nfsd4_create").call !,
        filename  = kernel_string_n($create->cr_name, $create->cr_namelen)
        createmode = $create->cr_type
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc4.create"
        argstr = sprintf("%s (type=%s)", 
@@ -830,8 +858,8 @@ probe nfsd.proc2.remove = kernel.function("nfsd_proc_remove") !,
        filelen = $argp->len
        filename  = kernel_string_n($argp->name, $argp->len)
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc2.remove"
        argstr = sprintf("%s", kernel_string_n($argp->name, $argp->len))
@@ -859,8 +887,8 @@ probe nfsd.proc3.remove = kernel.function("nfsd3_proc_remove") !,
        filelen = $argp->len
        filename  = kernel_string_n($argp->name, $argp->len)
        
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc3.remove"
        argstr = sprintf("%s", kernel_string_n($argp->name, $argp->len))
@@ -887,8 +915,8 @@ probe nfsd.proc4.remove = kernel.function("nfsd4_remove").call !,
        filelen = $remove->rm_namelen
        filename  = kernel_string_n($remove->rm_name, $remove->rm_namelen)
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc4.remove"
        argstr = sprintf("%s", 
@@ -946,8 +974,8 @@ probe nfsd.proc2.rename = kernel.function("nfsd_proc_rename") !,
        tlen = $argp->tlen
        tname = kernel_string_n($argp->tname, $argp->tlen)
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc2.rename"
        argstr = sprintf("%s to %s", 
@@ -980,8 +1008,8 @@ probe nfsd.proc3.rename = kernel.function("nfsd3_proc_rename") !,
        tlen = $argp->tlen
        tname = kernel_string_n($argp->tname, $argp->tlen)
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc3.rename"
        argstr = sprintf("%s to %s", 
@@ -1014,8 +1042,8 @@ probe nfsd.proc4.rename = kernel.function("nfsd4_rename").call !,
        tlen = $rename->rn_tnamelen
        tname = kernel_string_n($rename->rn_tname, $rename->rn_tnamelen)
 
-       uid = $rqstp->rq_cred->cr_uid
-       gid = $rqstp->rq_cred->cr_gid
+       uid = __rqstp_uid($rqstp)
+       gid = __rqstp_gid($rqstp)
 
        name = "nfsd.proc4.rename"
        argstr = sprintf("%s to %s", 
@@ -1093,15 +1121,29 @@ probe nfsd.open.return = kernel.function("nfsd_open").return !,
  *
  * @filename: file name
  */
-probe nfsd.close = kernel.function("nfsd_close") !,
-                   module("nfsd").function("nfsd_close") ?
+probe nfsd.close = __nfsd.call_close ?, __nfsd.inlined_close ?
 {
        client_ip ="N/A"
-       filename = __file_filename($filp)
-
        name = "nfsd.close"
        argstr = sprintf("%s",filename)
 }
+/*
+ * Why split nfsd.close up into '__nfsd.call_close' and
+ * '__nfds.inlined_close'? We need the '@choose_defined()' since
+ * SystemTap has trouble accessing the arguments of inlined functions
+ * (PR 1155). But, if we only used '@choose_defined()', we wouldn't
+ * automatically notice a change in the argument name.
+ */
+probe __nfsd.call_close = kernel.function("nfsd_close").call !,
+                         module("nfsd").function("nfsd_close").call ?
+{
+       filename = __file_filename($filp)
+}
+probe __nfsd.inlined_close = kernel.function("nfsd_close").inline !,
+                            module("nfsd").function("nfsd_close").inline ?
+{
+       filename = __file_filename(@choose_defined($filp, 0))
+}
 
 probe nfsd.close.return = kernel.function("nfsd_close").return !,
                           module("nfsd").function("nfsd_close").return ?
This page took 0.038757 seconds and 5 git commands to generate.