Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1467189 > unrolled thread
| Started by | Heinrich Schuchardt <xypron.glpk@gmx.de> |
|---|---|
| First post | 2016-08-21 20:00 +0200 |
| Last post | 2016-08-22 10:40 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 1/1] drm: avoid exposing kernel stack in compat_drm_getstats Heinrich Schuchardt <xypron.glpk@gmx.de> - 2016-08-21 20:00 +0200
Re: [PATCH 1/1] drm: avoid exposing kernel stack in compat_drm_getstats Daniel Vetter <daniel@ffwll.ch> - 2016-08-22 09:30 +0200
Re: [PATCH 1/1] drm: avoid exposing kernel stack in compat_drm_getstats Jani Nikula <jani.nikula@linux.intel.com> - 2016-08-22 10:40 +0200
| From | Heinrich Schuchardt <xypron.glpk@gmx.de> |
|---|---|
| Date | 2016-08-21 20:00 +0200 |
| Subject | [PATCH 1/1] drm: avoid exposing kernel stack in compat_drm_getstats |
| Message-ID | <s8Fcl-3qf-1@gated-at.bofh.it> |
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> --- 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)); stats = compat_alloc_user_space(sizeof(*stats)); if (!stats) return -EFAULT; -- 2.1.4
[toc] | [next] | [standalone]
| From | Daniel Vetter <daniel@ffwll.ch> |
|---|---|
| Date | 2016-08-22 09:30 +0200 |
| Subject | Re: [PATCH 1/1] drm: avoid exposing kernel stack in compat_drm_getstats |
| Message-ID | <s8RQd-3fx-13@gated-at.bofh.it> |
| In reply to | #1467189 |
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)); > 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 -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
[toc] | [prev] | [next] | [standalone]
| From | Jani Nikula <jani.nikula@linux.intel.com> |
|---|---|
| Date | 2016-08-22 10:40 +0200 |
| Message-ID | <s8SVY-3V6-23@gated-at.bofh.it> |
| In reply to | #1467421 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web