drm/ttm: Use scnprintf() for avoiding potential buffer overflow
Subsystems (3)
PATCH 1/1 drm/ttm: Use scnprintf() for avoiding potential buffer overflow
Since snprintf() returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing with scnprintf().
--- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +1 -1
@@ -604,7 +604,7 @@ static struct dma_pool *ttm_dma_pool_init(struct device *dev, gfp_t flags, p = pool->name;for (i =0 ; i <ARRAY_SIZE (t); i++) {if (type & t[i]) { - p +=snprintf (p,sizeof (pool->name) - (p - pool->name), + p +=scnprintf (p,sizeof (pool->name) - (p - pool->name),"%s" , n[i]); } }
Signature · 6 lines
2.16.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 5 lines · Takashi Iwai
Since
snprintf()returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing withscnprintf().Signed-off-by Takashi Iwai <[email protected]>
Quoted 20 lines
--- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +1
-1@@ -604,7 +604,7 @@ static struct dma_pool *ttm_dma_pool_init(struct device *dev, gfp_t flags, p = pool->name;for (i =0 ; i <ARRAY_SIZE (t); i++) {if (type & t[i]) { - p +=snprintf (p,sizeof (pool->name) - (p - pool->name), + p +=scnprintf (p,sizeof (pool->name) - (p - pool->name),"%s" , n[i]); } }Signature · 1 line
2.16.4
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
Reviewed-byAm 11.03.20 um 08:52 schrieb Huang Rui:
Quoted 7 lines · Takashi Iwai
Quoted 5 lines
Since
snprintf()returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing withscnprintf().Signed-off-by Takashi Iwai <[email protected]>Reviewed-by Huang Rui <[email protected]>
Takashi, should I push this to drm-misc-next or do you want to merge that somehow else?
Thanks,
Christian.
Quoted 5 lines
Quoted 5 lines
--- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +1
-1@@ -604,7 +604,7 @@ static struct dma_pool *ttm_dma_pool_init(struct device *dev, gfp_t flags, p = pool->name;for (i =0 ; i <ARRAY_SIZE (t); i++) {if (type & t[i]) { - p +=snprintf (p,sizeof (pool->name) - (p - pool->name), + p +=scnprintf (p,sizeof (pool->name) - (p - pool->name),"%s" , n[i]); } }Signature · 1 line
2.16.4
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · On Wed, 11 Mar 2020 08:56:11 +0100, Christian K6nig wrote:
Am 11.03.20 um 08:52 schrieb Huang Rui:
Quoted 5 lines · Takashi Iwai
Quoted 4 lines
Since
snprintf()returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing withscnprintf().
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Takashi Iwai <[email protected]>Reviewed-by Huang Rui <[email protected]>Reviewed-by Christian König <[email protected]>Takashi, should I push this to drm-misc-next or do you want to merge that somehow else?
Please take through your tree as you like.
Thanks!
Takashi
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel