On Tue, Sep 08, 2015 at 04:30:52AM +0300, Dmitry V. Levin wrote:
> On Tue, Sep 08, 2015 at 04:18:11AM +0300, Dmitry V. Levin wrote:
> [...]
> > So the whole function should look smth like this:
> > 
> > static int i915_getparam(struct tcb *tcp, const unsigned int code, long arg)
> > {
> >     struct drm_i915_getparam param;
> > 
> >     if (entering(tcp)) {
> >             if (umove_or_printaddr(tcp, arg, &param))
> >                     return RVAL_DECODED | 1;
> >             tprints(", {param=");
> 
> or rather
>               tprints(", ");
>               if (umove_or_printaddr(tcp, arg, &param))
>                       return RVAL_DECODED | 1;
>               tprints("{param=");

or rather

static int
i915_getparam(struct tcb *tcp, const unsigned int code, const long arg)
{
        struct drm_i915_getparam param;
        int value;

        if (entering(tcp)) {
                tprints(", ");
                if (umove_or_printaddr(tcp, arg, &param))
                        return RVAL_DECODED | 1;
                tprints("{param=");
                printxval(drm_i915_getparams, param.param, "I915_PARAM_???");
                return 0;
        }

        if (!umove(tcp, arg, &param)) {
                tprints(", value=");
                if (!umove_or_printaddr(tcp, (long) param.value, &value)) {
                        switch (param.param) {
                        case I915_PARAM_CHIPSET_ID:
                                tprintf("[%#04x]", value);
                                break;
                        default:
                                tprintf("[%d]", value);
                        }
                }
        }
        tprints("}");
        return 1;
}

Note that those structure members that are set by the kernel on exiting
syscall shouldn't normally be printed in case of syserror(tcp).

In case of i915_getparam, no extra check is needed because param.value is
an address supplied by userspace and umove_or_printaddr already performs
all necessary checks, but in other IOWR parsers you might want to use
        if (!syserror(tcp) && !umove(tcp, arg, &param)) {
instead.


-- 
ldv

Attachment: pgpcCJx7MZF3H.pgp
Description: PGP signature

------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to