lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Fri, 4 Nov 2016 17:33:22 +0000
From:   Eric Engestrom <eric.engestrom@...tec.com>
To:     <linux-kernel@...r.kernel.org>
CC:     Ville Syrjälä 
        <ville.syrjala@...ux.intel.com>, Rob Clark <robdclark@...il.com>,
        Eric Engestrom <eric.engestrom@...tec.com>,
        David Airlie <airlied@...ux.ie>,
        <dri-devel@...ts.freedesktop.org>
Subject: [PATCH variant 1] drm: make drm_get_format_name atomic/irq safe again

Fixes: 90844f00049e9f42573fd31d7c32e8fd31d3fd07

    drm: make drm_get_format_name thread-safe

    Signed-off-by: Eric Engestrom <eric@...estrom.ch>
    [danvet: Clarify that the returned pointer must be freed with
    kfree().]
    Signed-off-by: Daniel Vetter <daniel.vetter@...ll.ch>

Note (Rob Clark):
I think we need to be a bit careful about follow-up audits of callers of
this..  now that you need to kfree the return value I think it is fairly
easy for new patches to introduce new callers which leak the return
value.  We probably should have left the function as-is and introduce
a new variant, or something like that.

Suggested-by: Rob Clark <robdclark@...il.com> (GFP_ATOMIC)
Suggested-by: Ville Syrjälä <ville.syrjala@...ux.intel.com> (kasprintf)
Signed-off-by: Eric Engestrom <eric.engestrom@...tec.com>
---

I'll send another variant tonight that moves the allocation to the
callers (sounds cleaner to me, although there'll be some code
duplication and more opportunities to make mistakes I guess).

---
 drivers/gpu/drm/drm_fourcc.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index 29c56b4..66dcf21 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -87,9 +87,7 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format);
  */
 char *drm_get_format_name(uint32_t format)
 {
-	char *buf = kmalloc(32, GFP_KERNEL);
-
-	snprintf(buf, 32,
+	return kasprintf(GFP_ATOMIC,
 		 "%c%c%c%c %s-endian (0x%08x)",
 		 printable_char(format & 0xff),
 		 printable_char((format >> 8) & 0xff),
@@ -97,8 +95,6 @@ char *drm_get_format_name(uint32_t format)
 		 printable_char((format >> 24) & 0x7f),
 		 format & DRM_FORMAT_BIG_ENDIAN ? "big" : "little",
 		 format);
-
-	return buf;
 }
 EXPORT_SYMBOL(drm_get_format_name);
 
-- 
Cheers,
  Eric

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ