From: Jani Nikula <jani.nikula@linux.intel.com>
To: Daniel Vetter <daniel@ffwll.ch>,
Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/1] drm: avoid exposing kernel stack in compat_drm_getstats
Date: Mon, 22 Aug 2016 11:29:07 +0300 [thread overview]
Message-ID: <87fupxurzg.fsf@intel.com> (raw)
In-Reply-To: <20160822072718.GC6232@phenom.ffwll.local>
On Mon, 22 Aug 2016, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Sun, Aug 21, 2016 at 07:56:19PM +0200, Heinrich Schuchardt wrote:
>> The C standard does not specify the size of the integer used
>> to store an enum. Hence in structure drm_stats32_t alignment
>> bytes may exist.
>>
>> To avoid exposing bytes from the kernel stack it is
>> necessary to initialize variable s32 completely.
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>
> Applied to drm-misc, thanks.
> -Daniel
>
>> ---
>> drivers/gpu/drm/drm_ioc32.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
>> index 57676f8..32a489b 100644
>> --- a/drivers/gpu/drm/drm_ioc32.c
>> +++ b/drivers/gpu/drm/drm_ioc32.c
>> @@ -346,6 +346,7 @@ static int compat_drm_getstats(struct file *file, unsigned int cmd,
>> struct drm_stats __user *stats;
>> int i, err;
>>
>> + memset(&s32, 0, sizeof(drm_stats32_t));
For future reference,
memset(&s32, 0, sizeof(s32));
is the better approach, avoiding problems if the type of s32 ever
changes.
BR,
Jani.
>> stats = compat_alloc_user_space(sizeof(*stats));
>> if (!stats)
>> return -EFAULT;
>> --
>> 2.1.4
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Jani Nikula, Intel Open Source Technology Center
prev parent reply other threads:[~2016-08-22 8:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-21 17:56 [PATCH 1/1] drm: avoid exposing kernel stack in compat_drm_getstats Heinrich Schuchardt
2016-08-22 7:27 ` Daniel Vetter
2016-08-22 8:29 ` Jani Nikula [this message]
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=87fupxurzg.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xypron.glpk@gmx.de \
/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