public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@altlinux.org>
To: Gabriel Laskar <gabriel@lse.epita.fr>
Cc: intel-gfx@lists.freedesktop.org, strace-devel@lists.sourceforge.net
Subject: Re: [PATCH v3 4/5] drm: Add decoding of i915 ioctls
Date: Wed, 8 Jul 2015 03:11:36 +0300	[thread overview]
Message-ID: <20150708001136.GA8326@altlinux.org> (raw)
In-Reply-To: <20150706164024.6fbf994c@guiness.lab.lse.epita.fr>


[-- Attachment #1.1: Type: text/plain, Size: 2734 bytes --]

On Mon, Jul 06, 2015 at 04:40:24PM +0200, Gabriel Laskar wrote:
> On Mon, 6 Jul 2015 12:35:52 +0200, Patrik Jakobsson wrote:
> > On Fri, Jul 03, 2015 at 03:36:09AM +0300, Dmitry V. Levin wrote:
> > > On Wed, Jul 01, 2015 at 02:52:47PM +0200, Patrik Jakobsson wrote:
> > > [...]
> > > > --- a/drm.c
> > > > +++ b/drm.c
> > > > @@ -35,6 +35,9 @@
> > > >  
> > > >  #define DRM_MAX_NAME_LEN 128
> > > >  
> > > > +extern int drm_i915_decode_number(struct tcb *tcp, unsigned int arg);
> > > 
> > > Please rename "arg" to "code", and ...
> > > 
> > > > +extern int drm_i915_ioctl(struct tcb *tcp, const unsigned int code, long arg);
> > > 
> > > ... move both declarations to defs.h to make them visible also
> > > in the file where these functions are defined.
> > > 
> > > [...]
> > > > +static int i915_setparam(struct tcb *tcp, const unsigned int code, long arg)
> > > > +{
> > > > +	struct drm_i915_setparam param;
> > > > +
> > > > +	if (entering(tcp)) {
> > > > +		if (umove(tcp, arg, &param))
> > > > +			return 0;
> > > > +
> > > > +		tprints(", {param=");
> > > > +		printxval(drm_i915_setparams, param.param, "I915_PARAM_???");
> > > > +		tprintf(", value=%d}", param.value);
> > > > +	}
> > > > +
> > > > +	return 1;
> > > > +}
> > > 
> > > In this and most of other parsers of _IOC_WRITE ioctls added by this and
> > > the next patches, any error in parser that leads to "return 0" will result
> > > to disabled "arg" decoding, including the fallback decoding performed by
> > > sys_ioctl.
> > > 
> > > Maybe it's time to deal with this issue in a more generic way.
> > > 
> > 
> > Yes, I'm thinking SYS_FUNC(ioctl) could be improved. But on the other hand how
> > likely is it that we fail in umove and what chance do we have to recover from
> > that anyway? All I can think of is OOM.
> 
> umove() can fail in multiple ways. For example, if the memory is not
> valid in the tracee, umove() will fail.

Yes, this is the most likely cause for umove() to fail,
and the most easily reproducible one, e.g.
ioctl(-1, DRM_IOCTL_VERSION, 42);

> Anyway, SYS_FUNC(ioctl) is a bit complicated, and the handling of the
> fallbacks on failure should be more generic.

What would be useful is a way for "on entering" parsers to return
"done with decoding" information to their callers.

This could be implemented by or'ing return value in the current semantics
with a flag with "done with decoding" meaning, e.g. RVAL_DONE.

If an ioctl parser returned RVAL_DONE, this would tell SYS_FUNC(ioctl)
that the decoding is finished but fallback decoding is needed, while
RVAL_DONE+1 would mean that the decoding is finished and no fallback
decoding is needed.


-- 
ldv

[-- Attachment #1.2: Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-07-08  0:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01 12:52 [PATCH v3 0/5] drm: Add decoding for DRM/KMS and i915 ioctls Patrik Jakobsson
     [not found] ` <1435755168-16207-1-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-07-01 12:52   ` [PATCH v3 1/5] drm: Add config for detecting libdrm Patrik Jakobsson
     [not found]     ` <1435755168-16207-2-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-07-23  9:48       ` Mike Frysinger
2015-07-23 10:44         ` Dmitry V. Levin
     [not found]           ` <20150723104417.GA21575-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org>
2015-07-23 11:02             ` Mike Frysinger
2015-07-30 13:30         ` Patrik Jakobsson
2015-07-30 14:04           ` Mike Frysinger
2015-07-31  9:09             ` Patrik Jakobsson
2015-08-01 18:22               ` Dmitry V. Levin
2015-08-02 14:03                 ` Patrik Jakobsson
2015-07-01 12:52   ` [PATCH v3 2/5] drm: Add private data field to trace control block Patrik Jakobsson
2015-07-03  0:33     ` Dmitry V. Levin
2015-07-06  8:09       ` Patrik Jakobsson
2015-07-01 12:52   ` [PATCH v3 3/5] drm: Add dispatcher and driver identification for DRM Patrik Jakobsson
2015-07-01 12:52 ` [PATCH v3 4/5] drm: Add decoding of i915 ioctls Patrik Jakobsson
2015-07-03  0:36   ` Dmitry V. Levin
     [not found]     ` <20150703003609.GB29080-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org>
2015-07-06 10:35       ` Patrik Jakobsson
2015-07-06 14:40         ` Gabriel Laskar
2015-07-08  0:11           ` Dmitry V. Levin [this message]
2015-07-10 12:36             ` Patrik Jakobsson
2015-07-10 12:57               ` Dmitry V. Levin
2015-07-01 12:52 ` [PATCH v3 5/5] drm: Add decoding of DRM and KMS ioctls Patrik Jakobsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150708001136.GA8326@altlinux.org \
    --to=ldv@altlinux.org \
    --cc=gabriel@lse.epita.fr \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=strace-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox