public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gcov: fix memory allocation problem in gcov_info_dup
@ 2014-02-19  7:06 Yuan Pengfei
  2014-02-19  8:52 ` Peter Oberparleiter
  0 siblings, 1 reply; 4+ messages in thread
From: Yuan Pengfei @ 2014-02-19  7:06 UTC (permalink / raw)
  To: Peter Oberparleiter; +Cc: linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1408 bytes --]

From: Yuan Pengfei <coolypf@qq.com>

If -fprofile-values option is used, ctr->num and sci_ptr->num
may be zero, resulting in zero size and cv_size, which will
cause ENOMEM when opening gcov data files in debugfs.
Signed-off-by: Yuan Pengfei <coolypf@qq.com>
---
 kernel/gcov/gcc_3_4.c | 2 +-
 kernel/gcov/gcc_4_7.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/gcov/gcc_3_4.c b/kernel/gcov/gcc_3_4.c
index 27bc88a..1c1f425 100644
--- a/kernel/gcov/gcc_3_4.c
+++ b/kernel/gcov/gcc_3_4.c
@@ -269,7 +269,7 @@ struct gcov_info *gcov_info_dup(struct gcov_info *info)
 		dup->counts[i].num = ctr->num;
 		dup->counts[i].merge = ctr->merge;
 		dup->counts[i].values = vmalloc(size);
-		if (!dup->counts[i].values)
+		if (size && !dup->counts[i].values)
 			goto err_free;
 		memcpy(dup->counts[i].values, ctr->values, size);
 	}
diff --git a/kernel/gcov/gcc_4_7.c b/kernel/gcov/gcc_4_7.c
index 2c6e463..7465944 100644
--- a/kernel/gcov/gcc_4_7.c
+++ b/kernel/gcov/gcc_4_7.c
@@ -290,7 +290,7 @@ struct gcov_info *gcov_info_dup(struct gcov_info *info)
 
 			dci_ptr->values = vmalloc(cv_size);
 
-			if (!dci_ptr->values)
+			if (cv_size && !dci_ptr->values)
 				goto err_free;
 
 			dci_ptr->num = sci_ptr->num;
-- 
1.8.5.3ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] gcov: fix memory allocation problem in gcov_info_dup
  2014-02-19  7:06 [PATCH] gcov: fix memory allocation problem in gcov_info_dup Yuan Pengfei
@ 2014-02-19  8:52 ` Peter Oberparleiter
  2014-02-19 10:38   ` Yuan Pengfei
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Oberparleiter @ 2014-02-19  8:52 UTC (permalink / raw)
  To: Yuan Pengfei; +Cc: linux-kernel

On 19.02.2014 08:06, Yuan Pengfei wrote:
> From: Yuan Pengfei <coolypf@qq.com>
> 
> If -fprofile-values option is used, ctr->num and sci_ptr->num
> may be zero, resulting in zero size and cv_size, which will
> cause ENOMEM when opening gcov data files in debugfs.
> Signed-off-by: Yuan Pengfei <coolypf@qq.com>

I'm unaware of any user of -fprofile-values in the kernel. Are you
trying to extend gcov-kernel to also support -fprofile-values? I would
expect that additional changes to the .gcda file creation logic are
required to fully support this GCC option.


Regards,
  Peter Oberparleiter

-- 
Peter Oberparleiter
Linux on System z Development - IBM Germany


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gcov: fix memory allocation problem in gcov_info_dup
  2014-02-19  8:52 ` Peter Oberparleiter
@ 2014-02-19 10:38   ` Yuan Pengfei
  2014-02-20  8:52     ` Peter Oberparleiter
  0 siblings, 1 reply; 4+ messages in thread
From: Yuan Pengfei @ 2014-02-19 10:38 UTC (permalink / raw)
  To: Peter Oberparleiter; +Cc: linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 631 bytes --]

Using -fprofile-values is one case that will cause the memory allocation
problem. More changes are needed to fully support -fprofile-values. I
submit this patch first because I think it is obvious and does no harm.
> I'm unaware of any user of -fprofile-values in the kernel. Are you
> trying to extend gcov-kernel to also support -fprofile-values? I would
> expect that additional changes to the .gcda file creation logic are
> required to fully support this GCC option.ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gcov: fix memory allocation problem in gcov_info_dup
  2014-02-19 10:38   ` Yuan Pengfei
@ 2014-02-20  8:52     ` Peter Oberparleiter
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Oberparleiter @ 2014-02-20  8:52 UTC (permalink / raw)
  To: Yuan Pengfei; +Cc: linux-kernel

On 19.02.2014 11:38, Yuan Pengfei wrote:
> Using -fprofile-values is one case that will cause the memory allocation
> problem. More changes are needed to fully support -fprofile-values. I
> submit this patch first because I think it is obvious and does no harm.
>> I'm unaware of any user of -fprofile-values in the kernel. Are you
>> trying to extend gcov-kernel to also support -fprofile-values? I would
>> expect that additional changes to the .gcda file creation logic are
>> required to fully support this GCC option.

If there is a way to trigger the problem of gcov_info.values == NULL
using the existing gcov-kernel infrastructure then I agree that this
should be fixed. If not, then I would rather see the suggested change as
part of a patch series that enables other profiling types.

-- 
Peter Oberparleiter
Linux on System z Development - IBM Germany


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-02-20  8:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-19  7:06 [PATCH] gcov: fix memory allocation problem in gcov_info_dup Yuan Pengfei
2014-02-19  8:52 ` Peter Oberparleiter
2014-02-19 10:38   ` Yuan Pengfei
2014-02-20  8:52     ` Peter Oberparleiter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox