From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Dmitry V. Levin" Subject: Re: [PATCH v4 4/5] drm: Add decoding of i915 ioctls Date: Wed, 9 Sep 2015 14:52:18 +0300 Message-ID: <20150909115218.GD6119@altlinux.org> References: <1440420170-13337-1-git-send-email-patrik.jakobsson@linux.intel.com> <1440420170-13337-5-git-send-email-patrik.jakobsson@linux.intel.com> <20150908011811.GB17781@altlinux.org> <20150908013052.GC17781@altlinux.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1240821817==" Return-path: Received: from pegasus3.altlinux.org (pegasus3.altlinux.org [194.107.17.103]) by gabe.freedesktop.org (Postfix) with ESMTP id DA6186E03B for ; Wed, 9 Sep 2015 04:52:20 -0700 (PDT) In-Reply-To: <20150908013052.GC17781@altlinux.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Patrik Jakobsson Cc: intel-gfx@lists.freedesktop.org, strace-devel@lists.sourceforge.net List-Id: intel-gfx@lists.freedesktop.org --===============1240821817== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="mSxgbZZZvrAyzONB" Content-Disposition: inline --mSxgbZZZvrAyzONB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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: > >=20 > > static int i915_getparam(struct tcb *tcp, const unsigned int code, long= arg) > > { > > struct drm_i915_getparam param; > >=20 > > if (entering(tcp)) { > > if (umove_or_printaddr(tcp, arg, ¶m)) > > return RVAL_DECODED | 1; > > tprints(", {param=3D"); >=20 > or rather > tprints(", "); > if (umove_or_printaddr(tcp, arg, ¶m)) > return RVAL_DECODED | 1; > tprints("{param=3D"); 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, ¶m)) return RVAL_DECODED | 1; tprints("{param=3D"); printxval(drm_i915_getparams, param.param, "I915_PARAM_???"); return 0; } if (!umove(tcp, arg, ¶m)) { tprints(", value=3D"); 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, ¶m)) { instead. --=20 ldv --mSxgbZZZvrAyzONB Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlXwHXIACgkQfKvmrJ41Nh5UJwCfbQzxOdPq3oZgUMEa0tOGtx2p M2cAnAytGTARvo6N8ktRzUgs/Jhz+sXz =4XKG -----END PGP SIGNATURE----- --mSxgbZZZvrAyzONB-- --===============1240821817== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHA6Ly9saXN0 cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9pbnRlbC1nZngK --===============1240821817==--