public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] tests/gem_reset_stats: add close-pending-fork
Date: Mon, 02 Dec 2013 18:32:51 +0200	[thread overview]
Message-ID: <87wqjnmcwc.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20131202150308.GC26672@nuc-i3427.alporthouse.com>

Chris Wilson <chris@chris-wilson.co.uk> writes:

> On Mon, Dec 02, 2013 at 04:47:46PM +0200, Mika Kuoppala wrote:
>> Fork and create another filedesc to wait access to already
>> hung GPU and then kill it. This triggers use after free of the
>> request->batch_obj.
>> 
>> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
>> ---
>> +static int __test_open_any(void)
>> +{
>> +	char *name;
>> +	int ret, fd;
>> +
>> +	ret = asprintf(&name, "/dev/dri/card%d", drm_get_card());
>> +	if (ret == -1)
>> +		return -1;
>> +
>> +	fd = open(name, O_RDWR);
>> +	free(name);
>> +
>> +	return fd;
>> +}
>> +
>> +static void test_close_pending_fork(void)
>> +{
>> +	int pid;
>> +	int fd, fd2, h;
>> +
>> +	fd = drm_open_any();
>> +	igt_assert(fd >= 0);
>
> [snip]
>
>> +	close(fd);
>> +
>> +	fd = drm_open_any();
>
> This breaks the testsuite since drm_open_any() will now return the
> closed fd. Hence your __test_open_any() above.
>
> However this does not justify kernel doing anything other than terminating
> your process with extreme prejudice.

I discussed this with Chris in IRC. There seems to be no problem
as drm_open_any doesn't cache file descriptors.

The reason i use __test_open_any is that I needed a way to bypass
testsuites exit handling.

--Mika

  reply	other threads:[~2013-12-02 16:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-02 14:47 [PATCH] tests/gem_reset_stats: add close-pending-fork Mika Kuoppala
2013-12-02 15:03 ` Chris Wilson
2013-12-02 16:32   ` Mika Kuoppala [this message]
2013-12-03 17:03     ` Daniel Vetter
2013-12-04 14:39       ` Mika Kuoppala
2013-12-04 15:48         ` Daniel Vetter
2013-12-02 15:31 ` [RFC] drm/i915: reference count batch object on requests Mika Kuoppala
2013-12-03 17:10   ` Daniel Vetter
2013-12-04 11:24     ` Chris Wilson
2013-12-04 12:08       ` Daniel Vetter
2013-12-04 12:11         ` Chris Wilson
2013-12-04 13:28     ` Mika Kuoppala

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=87wqjnmcwc.fsf@gaia.fi.intel.com \
    --to=mika.kuoppala@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /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