All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
	intel-gfx@lists.freedesktop.org
Cc: stable@vger.kernel.org
Subject: Re: [Intel-gfx] [PATCH] drm/i915: Sanity check mmap length against object size
Date: Mon, 18 Mar 2019 12:16:13 +0000	[thread overview]
Message-ID: <155291136327.4168.1276604702868670237@skylake-alporthouse-com> (raw)
In-Reply-To: <155291101199.4168.4589198141475186842@skylake-alporthouse-com>

Quoting Chris Wilson (2019-03-18 12:10:12)
> Quoting Chris Wilson (2019-03-14 11:44:37)
> > Quoting Tvrtko Ursulin (2019-03-14 11:33:43)
> > > I am only wondering what happens to reads/write to the trailing area? 
> > > Does shmemfs expands the backing store for this mmap and we just end up 
> > > with otherwise unused chunk at the end?
> > 
> > My expectation would be that they generate a SIGBUS since the filp
> > should not be extended to cover the absent pages. So it would be the
> > equivalent of mmaping a file then calling ftruncate(0).
> 
> Ok, having just checked, what actually happens is that shmemfs quite
> happily allocates the extra page beyond the end of the object and
> userspace can freely read/write into that address space with only the
> mere consequence that those pages are not mapped to the GPU.

Or egg-on-face moment, wrong kernel (already had the safety check!)

ickle@kabylake:~/intel-gpu-tools$ sudo ./build/tests/gem_mmap --run bad-size
IGT-Version: 1.23-g3fc026d3e (x86_64) (Linux: 5.0.0+ x86_64)
Starting subtest: bad-size
Received signal SIGBUS.
Stack trace:
 #0 [fatal_sig_handler+0xd5]
 #1 [killpg+0x40]
 #2 [__real_main119+0x1b6]
 #3 [main+0x44]
 #4 [__libc_start_main+0xeb]
 #5 [_start+0x2a]
Subtest bad-size: CRASH (0.001s)

SIGBUS!
-Chris

  reply	other threads:[~2019-03-18 12:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14  7:58 [PATCH] drm/i915: Sanity check mmap length against object size Chris Wilson
2019-03-14  8:43 ` ✓ Fi.CI.BAT: success for " Patchwork
2019-03-14 11:33 ` [Intel-gfx] [PATCH] " Tvrtko Ursulin
2019-03-14 11:44   ` Chris Wilson
2019-03-18 12:10     ` Chris Wilson
2019-03-18 12:16       ` Chris Wilson [this message]
2019-03-14 17:41 ` ✗ Fi.CI.IGT: failure for " Patchwork
2019-03-15 18:24 ` ✓ Fi.CI.BAT: success for drm/i915: Sanity check mmap length against object size (rev2) Patchwork
2019-03-15 20:44 ` ✓ Fi.CI.IGT: " Patchwork
2019-03-18 12:17 ` [PATCH] drm/i915: Sanity check mmap length against object size Chris Wilson
2019-03-18 12:55 ` Joonas Lahtinen
2019-03-18 12:55   ` Joonas Lahtinen
2019-03-25  0:38 ` Sasha Levin

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=155291136327.4168.1276604702868670237@skylake-alporthouse-com \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=stable@vger.kernel.org \
    --cc=tvrtko.ursulin@linux.intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.