* [PATCH] SeqFile: Fix overflow condition
@ 2013-08-19 11:32 Arun KS
2013-08-19 23:05 ` Andrew Morton
0 siblings, 1 reply; 5+ messages in thread
From: Arun KS @ 2013-08-19 11:32 UTC (permalink / raw)
To: viro, Andrew Morton
Cc: Matthew Wilcox, Bruce Fields, linux-kernel, linux-fsdevel,
vinayak menon, Nagachandra P, Vikram MP
[-- Attachment #1: Type: text/plain, Size: 2365 bytes --]
>From 27f50827e5e81f2a30544b72c1d54c3ee86835cf Mon Sep 17 00:00:00 2001
From: Arun KS <arun.ks@broadcom.com>
Date: Mon, 19 Aug 2013 12:06:33 +0530
Subject: SeqFile: Fix overflow condition
seq_path()/seq_commit() is treating a d_path() failure as an overflow
condition, but it isn't.
Signed-off-by: Arun KS <arun.ks@broadcom.com>
---
fs/seq_file.c | 6 +++---
include/linux/seq_file.h | 12 +++++++-----
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 3135c25..6a33f9c 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -463,7 +463,7 @@ int seq_path(struct seq_file *m, const struct path
*path, const char *esc)
{
char *buf;
size_t size = seq_get_buf(m, &buf);
- int res = -1;
+ int res = -ENOBUFS;
if (size) {
char *p = d_path(path, buf, size);
@@ -487,7 +487,7 @@ int seq_path_root(struct seq_file *m, const struct
path *path,
{
char *buf;
size_t size = seq_get_buf(m, &buf);
- int res = -ENAMETOOLONG;
+ int res = -ENOBUFS;
if (size) {
char *p;
@@ -516,7 +516,7 @@ int seq_dentry(struct seq_file *m, struct dentry
*dentry, const char *esc)
{
char *buf;
size_t size = seq_get_buf(m, &buf);
- int res = -1;
+ int res = -ENOBUFS;
if (size) {
char *p = dentry_path(dentry, buf, size);
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 4e32edc..43f51a0 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -7,6 +7,7 @@
#include <linux/mutex.h>
#include <linux/cpumask.h>
#include <linux/nodemask.h>
+#include <linux/errno.h>
struct seq_operations;
struct file;
@@ -66,16 +67,17 @@ static inline size_t seq_get_buf(struct seq_file
*m, char **bufp)
* @num: the number of bytes to commit
*
* Commit @num bytes of data written to a buffer previously acquired
- * by seq_buf_get. To signal an error condition, or that the data
- * didn't fit in the available space, pass a negative @num value.
+ * by seq_buf_get. To signal an overflow condition(data didn't fit
+ * in the available space), pass -ENOBUFS and for other errors pass a
+ * negative @num value.
*/
static inline void seq_commit(struct seq_file *m, int num)
{
- if (num < 0) {
- m->count = m->size;
- } else {
+ if (num >= 0) {
BUG_ON(m->count + num > m->size);
m->count += num;
+ } else if (num == -ENOBUFS)
+ m->count = m->size;
}
}
--
1.7.6
[-- Attachment #2: 0001-SeqFile-Fix-overflow-condition.patch --]
[-- Type: application/octet-stream, Size: 2377 bytes --]
From 27f50827e5e81f2a30544b72c1d54c3ee86835cf Mon Sep 17 00:00:00 2001
From: Arun KS <arun.ks@broadcom.com>
Date: Mon, 19 Aug 2013 12:06:33 +0530
Subject: SeqFile: Fix overflow condition
seq_path()/seq_commit() is treating a d_path() failure as an overflow
condition, but it isn't.
Signed-off-by: Arun KS <arun.ks@broadcom.com>
---
fs/seq_file.c | 6 +++---
include/linux/seq_file.h | 12 +++++++-----
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 3135c25..6a33f9c 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -463,7 +463,7 @@ int seq_path(struct seq_file *m, const struct path *path, const char *esc)
{
char *buf;
size_t size = seq_get_buf(m, &buf);
- int res = -1;
+ int res = -ENOBUFS;
if (size) {
char *p = d_path(path, buf, size);
@@ -487,7 +487,7 @@ int seq_path_root(struct seq_file *m, const struct path *path,
{
char *buf;
size_t size = seq_get_buf(m, &buf);
- int res = -ENAMETOOLONG;
+ int res = -ENOBUFS;
if (size) {
char *p;
@@ -516,7 +516,7 @@ int seq_dentry(struct seq_file *m, struct dentry *dentry, const char *esc)
{
char *buf;
size_t size = seq_get_buf(m, &buf);
- int res = -1;
+ int res = -ENOBUFS;
if (size) {
char *p = dentry_path(dentry, buf, size);
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 4e32edc..43f51a0 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -7,6 +7,7 @@
#include <linux/mutex.h>
#include <linux/cpumask.h>
#include <linux/nodemask.h>
+#include <linux/errno.h>
struct seq_operations;
struct file;
@@ -66,16 +67,17 @@ static inline size_t seq_get_buf(struct seq_file *m, char **bufp)
* @num: the number of bytes to commit
*
* Commit @num bytes of data written to a buffer previously acquired
- * by seq_buf_get. To signal an error condition, or that the data
- * didn't fit in the available space, pass a negative @num value.
+ * by seq_buf_get. To signal an overflow condition(data didn't fit
+ * in the available space), pass -ENOBUFS and for other errors pass a
+ * negative @num value.
*/
static inline void seq_commit(struct seq_file *m, int num)
{
- if (num < 0) {
- m->count = m->size;
- } else {
+ if (num >= 0) {
BUG_ON(m->count + num > m->size);
m->count += num;
+ } else if (num == -ENOBUFS)
+ m->count = m->size;
}
}
--
1.7.6
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] SeqFile: Fix overflow condition
2013-08-19 11:32 [PATCH] SeqFile: Fix overflow condition Arun KS
@ 2013-08-19 23:05 ` Andrew Morton
2013-08-20 5:23 ` Arun KS
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2013-08-19 23:05 UTC (permalink / raw)
To: Arun KS
Cc: viro, Matthew Wilcox, Bruce Fields, linux-kernel, linux-fsdevel,
vinayak menon, Nagachandra P, Vikram MP
On Mon, 19 Aug 2013 17:02:37 +0530 Arun KS <arunks.linux@gmail.com> wrote:
> seq_path()/seq_commit() is treating a d_path() failure as an overflow
> condition, but it isn't.
This is too brief. When fixing a bug please always describe the
user-visible effects of the bug. And unless it's utterly obvious,
provide a description of how you set about fixing that bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] SeqFile: Fix overflow condition
2013-08-19 23:05 ` Andrew Morton
@ 2013-08-20 5:23 ` Arun KS
0 siblings, 0 replies; 5+ messages in thread
From: Arun KS @ 2013-08-20 5:23 UTC (permalink / raw)
To: Andrew Morton
Cc: viro, Matthew Wilcox, Bruce Fields, linux-kernel, linux-fsdevel,
vinayak menon, Nagachandra P, Vikram MP
Hi Andrew,
On Tue, Aug 20, 2013 at 4:35 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Mon, 19 Aug 2013 17:02:37 +0530 Arun KS <arunks.linux@gmail.com> wrote:
>
>> seq_path()/seq_commit() is treating a d_path() failure as an overflow
>> condition, but it isn't.
>
> This is too brief. When fixing a bug please always describe the
> user-visible effects of the bug. And unless it's utterly obvious,
> provide a description of how you set about fixing that bug.
>
I ll address this and will send a patch soon.
Thanks,
Arun
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] SeqFile: Fix overflow condition
@ 2013-08-19 6:55 Arun KS
2013-08-19 11:30 ` Arun KS
0 siblings, 1 reply; 5+ messages in thread
From: Arun KS @ 2013-08-19 6:55 UTC (permalink / raw)
To: viro, Andrew Morton
Cc: Matthew Wilcox, Bruce Fields, linux-kernel, linux-fsdevel,
vinayak menon, Nagachandra P, Vikram MP
[-- Attachment #1: Type: text/plain, Size: 2195 bytes --]
>From 23986a85b9efe7bc3ffc0887b8d17cdf2fbab4f2 Mon Sep 17 00:00:00 2001
From: Arun KS <arun.ks@broadcom.com>
Date: Mon, 19 Aug 2013 12:06:33 +0530
Subject: SeqFile: Fix overflow condition
seq_path()/seq_commit() is treating a d_path() failure as an overflow
condition, but it isn't.
Signed-off-by: Arun KS <arun.ks@broadcom.com>
---
fs/seq_file.c | 6 +++---
include/linux/seq_file.h | 11 ++++++-----
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 3135c25..6a33f9c 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -463,7 +463,7 @@ int seq_path(struct seq_file *m, const struct path
*path, const char *esc)
{
char *buf;
size_t size = seq_get_buf(m, &buf);
- int res = -1;
+ int res = -ENOBUFS;
if (size) {
char *p = d_path(path, buf, size);
@@ -487,7 +487,7 @@ int seq_path_root(struct seq_file *m, const struct
path *path,
{
char *buf;
size_t size = seq_get_buf(m, &buf);
- int res = -ENAMETOOLONG;
+ int res = -ENOBUFS;
if (size) {
char *p;
@@ -516,7 +516,7 @@ int seq_dentry(struct seq_file *m, struct dentry
*dentry, const char *esc)
{
char *buf;
size_t size = seq_get_buf(m, &buf);
- int res = -1;
+ int res = -ENOBUFS;
if (size) {
char *p = dentry_path(dentry, buf, size);
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 4e32edc..7bfb540 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -66,16 +66,17 @@ static inline size_t seq_get_buf(struct seq_file
*m, char **bufp)
* @num: the number of bytes to commit
*
* Commit @num bytes of data written to a buffer previously acquired
- * by seq_buf_get. To signal an error condition, or that the data
- * didn't fit in the available space, pass a negative @num value.
+ * by seq_buf_get. To signal an overflow condition(data didn't fit
+ * in the available space), pass -ENOBUFS and for other errors pass a
+ * negative @num value.
*/
static inline void seq_commit(struct seq_file *m, int num)
{
- if (num < 0) {
- m->count = m->size;
- } else {
+ if (num >= 0) {
BUG_ON(m->count + num > m->size);
m->count += num;
+ } else if (num == -ENOBUFS)
+ m->count = m->size;
}
}
--
1.8.2
[-- Attachment #2: 0001-SeqFile-Fix-overflow-condition.patch --]
[-- Type: application/octet-stream, Size: 2206 bytes --]
From 23986a85b9efe7bc3ffc0887b8d17cdf2fbab4f2 Mon Sep 17 00:00:00 2001
From: Arun KS <arun.ks@broadcom.com>
Date: Mon, 19 Aug 2013 12:06:33 +0530
Subject: SeqFile: Fix overflow condition
seq_path()/seq_commit() is treating a d_path() failure as an overflow
condition, but it isn't.
Signed-off-by: Arun KS <arun.ks@broadcom.com>
---
fs/seq_file.c | 6 +++---
include/linux/seq_file.h | 11 ++++++-----
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 3135c25..6a33f9c 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -463,7 +463,7 @@ int seq_path(struct seq_file *m, const struct path *path, const char *esc)
{
char *buf;
size_t size = seq_get_buf(m, &buf);
- int res = -1;
+ int res = -ENOBUFS;
if (size) {
char *p = d_path(path, buf, size);
@@ -487,7 +487,7 @@ int seq_path_root(struct seq_file *m, const struct path *path,
{
char *buf;
size_t size = seq_get_buf(m, &buf);
- int res = -ENAMETOOLONG;
+ int res = -ENOBUFS;
if (size) {
char *p;
@@ -516,7 +516,7 @@ int seq_dentry(struct seq_file *m, struct dentry *dentry, const char *esc)
{
char *buf;
size_t size = seq_get_buf(m, &buf);
- int res = -1;
+ int res = -ENOBUFS;
if (size) {
char *p = dentry_path(dentry, buf, size);
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 4e32edc..7bfb540 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -66,16 +66,17 @@ static inline size_t seq_get_buf(struct seq_file *m, char **bufp)
* @num: the number of bytes to commit
*
* Commit @num bytes of data written to a buffer previously acquired
- * by seq_buf_get. To signal an error condition, or that the data
- * didn't fit in the available space, pass a negative @num value.
+ * by seq_buf_get. To signal an overflow condition(data didn't fit
+ * in the available space), pass -ENOBUFS and for other errors pass a
+ * negative @num value.
*/
static inline void seq_commit(struct seq_file *m, int num)
{
- if (num < 0) {
- m->count = m->size;
- } else {
+ if (num >= 0) {
BUG_ON(m->count + num > m->size);
m->count += num;
+ } else if (num == -ENOBUFS)
+ m->count = m->size;
}
}
--
1.8.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] SeqFile: Fix overflow condition
2013-08-19 6:55 Arun KS
@ 2013-08-19 11:30 ` Arun KS
0 siblings, 0 replies; 5+ messages in thread
From: Arun KS @ 2013-08-19 11:30 UTC (permalink / raw)
To: viro, Andrew Morton
Cc: Matthew Wilcox, Bruce Fields, linux-kernel, linux-fsdevel,
vinayak menon, Nagachandra P, Vikram MP
Please ignore this patch.
I ll send an updated one.
Thanks,
Arun
On Mon, Aug 19, 2013 at 12:25 PM, Arun KS <arunks.linux@gmail.com> wrote:
> From 23986a85b9efe7bc3ffc0887b8d17cdf2fbab4f2 Mon Sep 17 00:00:00 2001
> From: Arun KS <arun.ks@broadcom.com>
> Date: Mon, 19 Aug 2013 12:06:33 +0530
> Subject: SeqFile: Fix overflow condition
>
> seq_path()/seq_commit() is treating a d_path() failure as an overflow
> condition, but it isn't.
>
> Signed-off-by: Arun KS <arun.ks@broadcom.com>
> ---
> fs/seq_file.c | 6 +++---
> include/linux/seq_file.h | 11 ++++++-----
> 2 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/fs/seq_file.c b/fs/seq_file.c
> index 3135c25..6a33f9c 100644
> --- a/fs/seq_file.c
> +++ b/fs/seq_file.c
> @@ -463,7 +463,7 @@ int seq_path(struct seq_file *m, const struct path
> *path, const char *esc)
> {
> char *buf;
> size_t size = seq_get_buf(m, &buf);
> - int res = -1;
> + int res = -ENOBUFS;
>
> if (size) {
> char *p = d_path(path, buf, size);
> @@ -487,7 +487,7 @@ int seq_path_root(struct seq_file *m, const struct
> path *path,
> {
> char *buf;
> size_t size = seq_get_buf(m, &buf);
> - int res = -ENAMETOOLONG;
> + int res = -ENOBUFS;
>
> if (size) {
> char *p;
> @@ -516,7 +516,7 @@ int seq_dentry(struct seq_file *m, struct dentry
> *dentry, const char *esc)
> {
> char *buf;
> size_t size = seq_get_buf(m, &buf);
> - int res = -1;
> + int res = -ENOBUFS;
>
> if (size) {
> char *p = dentry_path(dentry, buf, size);
> diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
> index 4e32edc..7bfb540 100644
> --- a/include/linux/seq_file.h
> +++ b/include/linux/seq_file.h
> @@ -66,16 +66,17 @@ static inline size_t seq_get_buf(struct seq_file
> *m, char **bufp)
> * @num: the number of bytes to commit
> *
> * Commit @num bytes of data written to a buffer previously acquired
> - * by seq_buf_get. To signal an error condition, or that the data
> - * didn't fit in the available space, pass a negative @num value.
> + * by seq_buf_get. To signal an overflow condition(data didn't fit
> + * in the available space), pass -ENOBUFS and for other errors pass a
> + * negative @num value.
> */
> static inline void seq_commit(struct seq_file *m, int num)
> {
> - if (num < 0) {
> - m->count = m->size;
> - } else {
> + if (num >= 0) {
> BUG_ON(m->count + num > m->size);
> m->count += num;
> + } else if (num == -ENOBUFS)
> + m->count = m->size;
> }
> }
>
> --
> 1.8.2
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-08-20 5:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-19 11:32 [PATCH] SeqFile: Fix overflow condition Arun KS
2013-08-19 23:05 ` Andrew Morton
2013-08-20 5:23 ` Arun KS
-- strict thread matches above, loose matches on Subject: below --
2013-08-19 6:55 Arun KS
2013-08-19 11:30 ` Arun KS
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).