Skip to contentSkip to conversation

tracing: Have traceprobe_probes_write() not access userspace unnecessarily

RFC PATCH In review Steven Rostedt 4 participants 15 messages Feb 9, 2017 – Feb 15, 2017 Tracing

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

RFC PATCH 1/1 tracing: Have traceprobe_probes_write() not access userspace unnecessarily

The code in traceprobe_probes_write() reads up to 4096 bytes from userpace for each line. If userspace passes in several lines to execute, the code will do a large read for each line, even though, it is highly likely that the first read from userspace received all of the lines at one.

I changed the logic to do a single read from userspace, and to only read from userspace again if not all of the read from userspace made it in.

I tested this by adding printk()s and writing files that would test -1, ==, and +1 the buffer size, to make sure that there's no overflows and that if a single line is written with +1 the buffer size, that it fails properly.

---
 kernel/trace/trace_probe.c | 48 ++++++++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 19 deletions(-)
kernel/trace/trace_probe.c +29 -19
index 8c0553d..2a06f1f 100644
@@ -647,7 +647,7 @@ ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer,
 				size_t count, loff_t *ppos,
 				int (*createfn)(int, char **))
 {
-	char *kbuf, *tmp;
+	char *kbuf, *buf, *tmp;
 	int ret = 0;
 	size_t done = 0;
 	size_t size;
@@ -667,27 +667,37 @@ ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer,
 			goto out;
 		}
 		kbuf[size] = '\0';
-		tmp = strchr(kbuf, '\n');
+		buf = kbuf;
+		do {
+			tmp = strchr(buf, '\n');
+			if (tmp) {
+				*tmp = '\0';
+				size = tmp - buf + 1;
+			} else {
+				size = strlen(buf);
+				if (done + size < count) {
+					if (buf != kbuf)
+						break;
+					pr_warn("Line length is too long: Should be less than %d\n",
+						WRITE_BUFSIZE);
+					ret = -EINVAL;
+					goto out;
+				}
+			}
+			done += size;
 
-		if (tmp) {
-			*tmp = '\0';
-			size = tmp - kbuf + 1;
-		} else if (done + size < count) {
-			pr_warn("Line length is too long: Should be less than %d\n",
-				WRITE_BUFSIZE);
-			ret = -EINVAL;
-			goto out;
-		}
-		done += size;
-		/* Remove comments */
-		tmp = strchr(kbuf, '#');
+			/* Remove comments */
+			tmp = strchr(buf, '#');
 
-		if (tmp)
-			*tmp = '\0';
+			if (tmp)
+				*tmp = '\0';
 
-		ret = traceprobe_command(kbuf, createfn);
-		if (ret)
-			goto out;
+			ret = traceprobe_command(buf, createfn);
+			if (ret)
+				goto out;
+			buf += size;
+
+		} while (done < count);
 	}
 	ret = done;
 
Signature · 1 line
2.9.3
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · On Thu, 9 Feb 2017 18:04:58 -0500 Steven Rostedt <[email protected]> wrote:

The code in traceprobe_probes_write() reads up to 4096 bytes from userpace for each line. If userspace passes in several lines to execute, the code will do a large read for each line, even though, it is highly likely that the first read from userspace received all of the lines at one.

Quoted 7 lines

I changed the logic to do a single read from userspace, and to only read from userspace again if not all of the read from userspace made it in.

I tested this by adding printk()s and writing files that would test -1, ==, and +1 the buffer size, to make sure that there's no overflows and that if a single line is written with +1 the buffer size, that it fails properly.

Thanks Steve!

BTW, this can conflict with my previous patch.

https://lkml.org/lkml/2017/2/6/1048
https://lkml.org/lkml/2017/2/7/203

I'll update this. Ingo, Can I send these patch to Steve?

Thank you,

Quoted 77 lines
---
 kernel/trace/trace_probe.c | 48 ++++++++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 19 deletions(-)
kernel/trace/trace_probe.c +29 -19
index 8c0553d..2a06f1f 100644
@@ -647,7 +647,7 @@ ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer,
 				size_t count, loff_t *ppos,
 				int (*createfn)(int, char **))
 {
-	char *kbuf, *tmp;
+	char *kbuf, *buf, *tmp;
 	int ret = 0;
 	size_t done = 0;
 	size_t size;
@@ -667,27 +667,37 @@ ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer,
 			goto out;
 		}
 		kbuf[size] = '\0';
-		tmp = strchr(kbuf, '\n');
+		buf = kbuf;
+		do {
+			tmp = strchr(buf, '\n');
+			if (tmp) {
+				*tmp = '\0';
+				size = tmp - buf + 1;
+			} else {
+				size = strlen(buf);
+				if (done + size < count) {
+					if (buf != kbuf)
+						break;
+					pr_warn("Line length is too long: Should be less than %d\n",
+						WRITE_BUFSIZE);
+					ret = -EINVAL;
+					goto out;
+				}
+			}
+			done += size;
 
-		if (tmp) {
-			*tmp = '\0';
-			size = tmp - kbuf + 1;
-		} else if (done + size < count) {
-			pr_warn("Line length is too long: Should be less than %d\n",
-				WRITE_BUFSIZE);
-			ret = -EINVAL;
-			goto out;
-		}
-		done += size;
-		/* Remove comments */
-		tmp = strchr(kbuf, '#');
+			/* Remove comments */
+			tmp = strchr(buf, '#');
 
-		if (tmp)
-			*tmp = '\0';
+			if (tmp)
+				*tmp = '\0';
 
-		ret = traceprobe_command(kbuf, createfn);
-		if (ret)
-			goto out;
+			ret = traceprobe_command(buf, createfn);
+			if (ret)
+				goto out;
+			buf += size;
+
+		} while (done < count);
 	}
 	ret = done;
 
Signature · 1 line
2.9.3
Signature · 1 line
Masami Hiramatsu <[email protected]>
#2 lore raw
Quoted 19 lines · Masami Hiramatsu
Quoted 6 lines · On Thu, 9 Feb 2017 18:04:58 -0500 Steven Rostedt <[email protected]> wrote:

The code in traceprobe_probes_write() reads up to 4096 bytes from userpace for each line. If userspace passes in several lines to execute, the code will do a large read for each line, even though, it is highly likely that the first read from userspace received all of the lines at one.

Quoted 7 lines

I changed the logic to do a single read from userspace, and to only read from userspace again if not all of the read from userspace made it in.

I tested this by adding printk()s and writing files that would test -1, ==, and +1 the buffer size, to make sure that there's no overflows and that if a single line is written with +1 the buffer size, that it fails properly.

Thanks Steve!

Quoted 8 lines

BTW, this can conflict with my previous patch.

https://lkml.org/lkml/2017/2/6/1048
https://lkml.org/lkml/2017/2/7/203

I'll update this. Ingo, Can I send these patch to Steve?

Sure, I've not applied your patch yet - mind sending it to Steve on top of Steve's patch?

Thanks,

Ingo

maintainer
#3 lore raw
Quoted 26 lines · On Fri, 10 Feb 2017 08:53:02 +0100 Ingo Molnar <[email protected]> wrote:
Quoted 23 lines · Masami Hiramatsu
Quoted 6 lines · On Thu, 9 Feb 2017 18:04:58 -0500 Steven Rostedt <[email protected]> wrote:

The code in traceprobe_probes_write() reads up to 4096 bytes from userpace for each line. If userspace passes in several lines to execute, the code will do a large read for each line, even though, it is highly likely that the first read from userspace received all of the lines at one.

Quoted 7 lines

I changed the logic to do a single read from userspace, and to only read from userspace again if not all of the read from userspace made it in.

I tested this by adding printk()s and writing files that would test -1, ==, and +1 the buffer size, to make sure that there's no overflows and that if a single line is written with +1 the buffer size, that it fails properly.

Thanks Steve!

BTW, this can conflict with my previous patch.

Quoted 7 lines
Quoted 4 lines

https://lkml.org/lkml/2017/2/6/1048
https://lkml.org/lkml/2017/2/7/203

I'll update this. Ingo, Can I send these patch to Steve?

Sure, I've not applied your patch yet - mind sending it to Steve on top of Steve's patch?

Of course, yes. :)

Thanks!

Quoted 4 lines

Thanks,

Ingo

Signature · 1 line
Masami Hiramatsu <[email protected]>
author maintainer
#4 lore raw
Quoted 5 lines · On Fri, 10 Feb 2017 19:37:53 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 2 lines

Sure, I've not applied your patch yet - mind sending it to Steve on top of Steve's patch?

Of course, yes. :)

Thanks! I'll apply them on top of mine then.

-- Steve

maintainer
#5 lore raw

PATCH v2 1/2 tracing/probes: Fix a warning message to show correct maximum length

In reply to Ingo Molnar

Since tracing/*probe_events will accept a probe definition up to 4096 - 2 ('\n' and '\0') bytes, it must show 4094 instead of 4096 in warning message.

Note that there is one possible case of exceed 4094. If user prepare 4096 bytes null-terminated string and syscall write it with the count == 4095, then it can be accepted. However, if user puts a '\n' after that, it must rejected. So IMHO, the warning message should indicate shorter one, since it is safer.

---
 kernel/trace/trace_probe.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/trace_probe.c +2 -1
index 2a06f1f..847c1e0 100644
@@ -678,8 +678,9 @@ ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer,
 				if (done + size < count) {
 					if (buf != kbuf)
 						break;
+					/* This can accept WRITE_BUFSIZE - 2 ('\n' + '\0') */
 					pr_warn("Line length is too long: Should be less than %d\n",
-						WRITE_BUFSIZE);
+						WRITE_BUFSIZE - 2);
 					ret = -EINVAL;
 					goto out;
 				}
author maintainer
#6 lore raw

Re: [PATCH V2 1/2] tracing/probes: Fix a warning message to show correct maximum length

Quoted 3 lines · On Fri, 10 Feb 2017 22:21:55 +0900 Masami Hiramatsu <[email protected]> wrote:

Since tracing/*probe_events will accept a probe definition up to 4096 - 2 ('\n' and '\0') bytes, it must show 4094 instead of 4096 in warning message.

Actually, during the testing I found that we don't need the '\n'.

echo -n 'p:irq do_IRQ a=@jiffies_64' > kprobe_events

works just fine. My tests work with 4095 characters. Before and after my patch.

-- Steve

Quoted 28 lines

Note that there is one possible case of exceed 4094. If user prepare 4096 bytes null-terminated string and syscall write it with the count == 4095, then it can be accepted. However, if user puts a '\n' after that, it must rejected. So IMHO, the warning message should indicate shorter one, since it is safer.

---
 kernel/trace/trace_probe.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/trace_probe.c +2 -1
index 2a06f1f..847c1e0 100644
@@ -678,8 +678,9 @@ ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer,
 				if (done + size < count) {
 					if (buf != kbuf)
 						break;
+					/* This can accept WRITE_BUFSIZE - 2 ('\n' + '\0') */
 					pr_warn("Line length is too long: Should be less than %d\n",
-						WRITE_BUFSIZE);
+						WRITE_BUFSIZE - 2);
 					ret = -EINVAL;
 					goto out;
 				}
maintainer
#7 lore raw

Re: [PATCH V2 1/2] tracing/probes: Fix a warning message to show correct maximum length

Quoted 7 lines · On Fri, 10 Feb 2017 11:04:34 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 3 lines · On Fri, 10 Feb 2017 22:21:55 +0900 Masami Hiramatsu <[email protected]> wrote:

Since tracing/*probe_events will accept a probe definition up to 4096 - 2 ('\n' and '\0') bytes, it must show 4094 instead of 4096 in warning message.

Quoted 6 lines

Actually, during the testing I found that we don't need the '\n'.

echo -n 'p:irq do_IRQ a=@jiffies_64' > kprobe_events

works just fine. My tests work with 4095 characters. Before and after my patch.

Yeah, I see. I concider the case that if the writer writes 4095 chars command + '\n' + next command, it will fail, that is what I pointed out below note.

Quoted 7 lines
Quoted 7 lines

Note that there is one possible case of exceed 4094. If user prepare 4096 bytes null-terminated string and syscall write it with the count == 4095, then it can be accepted. However, if user puts a '\n' after that, it must rejected. So IMHO, the warning message should indicate shorter one, since it is safer.

Thank you,

Quoted 22 lines
Quoted 21 lines
---
 kernel/trace/trace_probe.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/trace_probe.c +2 -1
index 2a06f1f..847c1e0 100644
@@ -678,8 +678,9 @@ ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer,
 				if (done + size < count) {
 					if (buf != kbuf)
 						break;
+					/* This can accept WRITE_BUFSIZE - 2 ('\n' + '\0') */
 					pr_warn("Line length is too long: Should be less than %d\n",
-						WRITE_BUFSIZE);
+						WRITE_BUFSIZE - 2);
 					ret = -EINVAL;
 					goto out;
 				}
Signature · 1 line
Masami Hiramatsu <[email protected]>
author maintainer
#8 lore raw

Re: [PATCH V2 1/2] tracing/probes: Fix a warning message to show correct maximum length

Quoted 22 lines · On Thu, 16 Feb 2017 00:10:30 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 7 lines · On Fri, 10 Feb 2017 11:04:34 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 3 lines · On Fri, 10 Feb 2017 22:21:55 +0900 Masami Hiramatsu <[email protected]> wrote:

Since tracing/*probe_events will accept a probe definition up to 4096 - 2 ('\n' and '\0') bytes, it must show 4094 instead of 4096 in warning message.

Quoted 6 lines

Actually, during the testing I found that we don't need the '\n'.

echo -n 'p:irq do_IRQ a=@jiffies_64' > kprobe_events

works just fine. My tests work with 4095 characters. Before and after my patch.

Yeah, I see. I concider the case that if the writer writes 4095 chars command + '\n' + next command, it will fail, that is what I pointed out below note.

Quoted 1 line
Quoted 1 line
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines

Note that there is one possible case of exceed 4094. If user prepare 4096 bytes null-terminated string and syscall write it with the count == 4095, then it can be accepted. However, if user puts a '\n' after that, it must rejected. So IMHO, the warning message should indicate shorter one, since it is safer.

Thank you,

OK, I'll just add the patch as is.

Thanks,

-- Steve

maintainer
#9 lore raw

PATCH v2 2/2 tracing/probe: Show subsystem name in messages

In reply to Ingo Molnar

Show "trace_probe:", "trace_kprobe:" and "trace_uprobe:" headers for each warning/error/info message. This will help people to notice that kprobe/uprobe events caused those messages.

---
 kernel/trace/trace_kprobe.c |    1 +
 kernel/trace/trace_probe.c  |    1 +
 kernel/trace/trace_uprobe.c |    1 +
 3 files changed, 3 insertions(+)
kernel/trace/trace_kprobe.c +1 -0
index d3729bd..5f688cc 100644
@@ -16,6 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#define pr_fmt(fmt)	"trace_kprobe: " fmt
 
 #include <linux/module.h>
 #include <linux/uaccess.h>
kernel/trace/trace_probe.c +1 -0
index 847c1e0..52478f0 100644
@@ -21,6 +21,7 @@
  * Copyright (C) IBM Corporation, 2010-2011
  * Author:     Srikar Dronamraju
  */
+#define pr_fmt(fmt)	"trace_probe: " fmt
 
 #include "trace_probe.h"
 
kernel/trace/trace_uprobe.c +1 -0
index e5445ab..2c6b2d0c 100644
@@ -17,6 +17,7 @@
  * Copyright (C) IBM Corporation, 2010-2012
  * Author:	Srikar Dronamraju <[email protected]>
  */
+#define pr_fmt(fmt)	"trace_kprobe: " fmt
 
 #include <linux/module.h>
 #include <linux/uaccess.h>
#10 lore raw

Re: [PATCH V2 2/2] tracing/probe: Show subsystem name in messages

Quoted 41 lines · Masami Hiramatsu

Show "trace_probe:", "trace_kprobe:" and "trace_uprobe:" headers for each warning/error/info message. This will help people to notice that kprobe/uprobe events caused those messages.

---
 kernel/trace/trace_kprobe.c |    1 +
 kernel/trace/trace_probe.c  |    1 +
 kernel/trace/trace_uprobe.c |    1 +
 3 files changed, 3 insertions(+)
kernel/trace/trace_kprobe.c +1 -0
index d3729bd..5f688cc 100644
@@ -16,6 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#define pr_fmt(fmt)	"trace_kprobe: " fmt
 
 #include <linux/module.h>
 #include <linux/uaccess.h>
kernel/trace/trace_probe.c +1 -0
index 847c1e0..52478f0 100644
@@ -21,6 +21,7 @@
  * Copyright (C) IBM Corporation, 2010-2011
  * Author:     Srikar Dronamraju
  */
+#define pr_fmt(fmt)	"trace_probe: " fmt
 
 #include "trace_probe.h"
 
kernel/trace/trace_uprobe.c +0 -0
index e5445ab..2c6b2d0c 100644

kernel/trace/trace_uprobe.c line 20

Quoted 4 lines
kernel/trace/trace_uprobe.c +1 -0
@@ -17,6 +17,7 @@
  * Copyright (C) IBM Corporation, 2010-2012
  * Author:	Srikar Dronamraju <[email protected]>
  */
+#define pr_fmt(fmt)	"trace_kprobe: " fmt

s/kprobe/uprobe/ ?

Thanks,
Namhyung

Quoted 4 lines
kernel/trace/trace_uprobe.c +0 -0
 #include <linux/module.h>
 #include <linux/uaccess.h>
 
author maintainer
#11 lore raw

Re: [PATCH V2 2/2] tracing/probe: Show subsystem name in messages

Quoted 11 lines · On Sat, 11 Feb 2017 01:01:55 +0900 Namhyung Kim <[email protected]> wrote:

kernel/trace/trace_uprobe.c line 20

Quoted 9 lines
kernel/trace/trace_uprobe.c +1 -0
index e5445ab..2c6b2d0c 100644
@@ -17,6 +17,7 @@
  * Copyright (C) IBM Corporation, 2010-2012
  * Author:	Srikar Dronamraju <[email protected]>
  */
+#define pr_fmt(fmt)	"trace_kprobe: " fmt  

s/kprobe/uprobe/ ?

Masami,

Can you update both patches and resend?

-- Steve

maintainer
#12 lore raw

Re: [PATCH V2 2/2] tracing/probe: Show subsystem name in messages

Quoted 15 lines · On Fri, 10 Feb 2017 11:17:29 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 11 lines · On Sat, 11 Feb 2017 01:01:55 +0900 Namhyung Kim <[email protected]> wrote:

kernel/trace/trace_uprobe.c line 20

Quoted 9 lines
kernel/trace/trace_uprobe.c +1 -0
index e5445ab..2c6b2d0c 100644
@@ -17,6 +17,7 @@
  * Copyright (C) IBM Corporation, 2010-2012
  * Author:	Srikar Dronamraju <[email protected]>
  */
+#define pr_fmt(fmt)	"trace_kprobe: " fmt  

s/kprobe/uprobe/ ?

Quoted 3 lines

Masami,

Can you update both patches and resend?

Oops! OK.

Thanks,

Signature · 1 line
Masami Hiramatsu <[email protected]>
maintainer
#13 lore raw

PATCH v3 1/1 tracing/probe: Show subsystem name in messages

In reply to Steven Rostedt

Show "trace_probe:", "trace_kprobe:" and "trace_uprobe:" headers for each warning/error/info message. This will help people to notice that kprobe/uprobe events caused those messages.

--
Changes in v3:
- Fix a typo.

---
 kernel/trace/trace_kprobe.c |    1 +
 kernel/trace/trace_probe.c  |    1 +
 kernel/trace/trace_uprobe.c |    1 +
 3 files changed, 3 insertions(+)
kernel/trace/trace_kprobe.c +1 -0
index d3729bd..5f688cc 100644
@@ -16,6 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#define pr_fmt(fmt)	"trace_kprobe: " fmt
 
 #include <linux/module.h>
 #include <linux/uaccess.h>
kernel/trace/trace_probe.c +1 -0
index 847c1e0..52478f0 100644
@@ -21,6 +21,7 @@
  * Copyright (C) IBM Corporation, 2010-2011
  * Author:     Srikar Dronamraju
  */
+#define pr_fmt(fmt)	"trace_probe: " fmt
 
 #include "trace_probe.h"
 
kernel/trace/trace_uprobe.c +1 -0
index e5445ab..95dd810 100644
@@ -17,6 +17,7 @@
  * Copyright (C) IBM Corporation, 2010-2012
  * Author:	Srikar Dronamraju <[email protected]>
  */
+#define pr_fmt(fmt)	"trace_uprobe: " fmt
 
 #include <linux/module.h>
 #include <linux/uaccess.h>
Acked-by on v1 1/1
#14 lore raw
In reply to Steven Rostedt
Quoted 6 lines · Steven Rostedt

The code in traceprobe_probes_write() reads up to 4096 bytes from userpace for each line. If userspace passes in several lines to execute, the code will do a large read for each line, even though, it is highly likely that the first read from userspace received all of the lines at one.

Quoted 8 lines

I changed the logic to do a single read from userspace, and to only read from userspace again if not all of the read from userspace made it in.

I tested this by adding printk()s and writing files that would test -1, ==, and +1 the buffer size, to make sure that there's no overflows and that if a single line is written with +1 the buffer size, that it fails properly.

Thanks,
Namhyung

Quoted 76 lines
---
 kernel/trace/trace_probe.c | 48 ++++++++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 19 deletions(-)
kernel/trace/trace_probe.c +29 -19
index 8c0553d..2a06f1f 100644
@@ -647,7 +647,7 @@ ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer,
 				size_t count, loff_t *ppos,
 				int (*createfn)(int, char **))
 {
-	char *kbuf, *tmp;
+	char *kbuf, *buf, *tmp;
 	int ret = 0;
 	size_t done = 0;
 	size_t size;
@@ -667,27 +667,37 @@ ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer,
 			goto out;
 		}
 		kbuf[size] = '\0';
-		tmp = strchr(kbuf, '\n');
+		buf = kbuf;
+		do {
+			tmp = strchr(buf, '\n');
+			if (tmp) {
+				*tmp = '\0';
+				size = tmp - buf + 1;
+			} else {
+				size = strlen(buf);
+				if (done + size < count) {
+					if (buf != kbuf)
+						break;
+					pr_warn("Line length is too long: Should be less than %d\n",
+						WRITE_BUFSIZE);
+					ret = -EINVAL;
+					goto out;
+				}
+			}
+			done += size;
 
-		if (tmp) {
-			*tmp = '\0';
-			size = tmp - kbuf + 1;
-		} else if (done + size < count) {
-			pr_warn("Line length is too long: Should be less than %d\n",
-				WRITE_BUFSIZE);
-			ret = -EINVAL;
-			goto out;
-		}
-		done += size;
-		/* Remove comments */
-		tmp = strchr(kbuf, '#');
+			/* Remove comments */
+			tmp = strchr(buf, '#');
 
-		if (tmp)
-			*tmp = '\0';
+			if (tmp)
+				*tmp = '\0';
 
-		ret = traceprobe_command(kbuf, createfn);
-		if (ret)
-			goto out;
+			ret = traceprobe_command(buf, createfn);
+			if (ret)
+				goto out;
+			buf += size;
+
+		} while (done < count);
 	}
 	ret = done;
 
Signature · 1 line
2.9.3