From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH] tests/gem_reset_stats: add close-pending-fork Date: Tue, 3 Dec 2013 18:03:43 +0100 Message-ID: <20131203170343.GM27344@phenom.ffwll.local> References: <1385995666-3541-1-git-send-email-mika.kuoppala@intel.com> <20131202150308.GC26672@nuc-i3427.alporthouse.com> <87wqjnmcwc.fsf@gaia.fi.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ee0-f48.google.com (mail-ee0-f48.google.com [74.125.83.48]) by gabe.freedesktop.org (Postfix) with ESMTP id E056CF9E6E for ; Tue, 3 Dec 2013 09:02:57 -0800 (PST) Received: by mail-ee0-f48.google.com with SMTP id e49so1689665eek.21 for ; Tue, 03 Dec 2013 09:02:57 -0800 (PST) Content-Disposition: inline In-Reply-To: <87wqjnmcwc.fsf@gaia.fi.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org To: Mika Kuoppala Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Mon, Dec 02, 2013 at 06:32:51PM +0200, Mika Kuoppala wrote: > Chris Wilson 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 > >> --- > >> +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. I guess a quick comment to explain that in the code would help. Can you please update the patch? -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch