linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/backing-dev.c: check user buffer length before copy data to the related user buffer.
@ 2013-08-20  3:23 Chen Gang
  2013-08-20 15:28 ` Jan Kara
  2013-08-20 23:29 ` Andrew Morton
  0 siblings, 2 replies; 7+ messages in thread
From: Chen Gang @ 2013-08-20  3:23 UTC (permalink / raw)
  To: Jan Kara, Tejun Heo, jmoyer, Jens Axboe; +Cc: Andrew Morton, linux-mm

'*lenp' may be less than "sizeof(kbuf)", need check it before the next
copy_to_user().

pdflush_proc_obsolete() is called by sysctl which 'procname' is
"nr_pdflush_threads", if the user passes buffer length less than
"sizeof(kbuf)", it will cause issue.


Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 mm/backing-dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index e04454c..2674671 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -649,7 +649,7 @@ int pdflush_proc_obsolete(struct ctl_table *table, int write,
 {
 	char kbuf[] = "0\n";
 
-	if (*ppos) {
+	if (*ppos || *lenp < sizeof(kbuf)) {
 		*lenp = 0;
 		return 0;
 	}
-- 
1.7.7.6

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2013-08-21  3:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-20  3:23 [PATCH] mm/backing-dev.c: check user buffer length before copy data to the related user buffer Chen Gang
2013-08-20 15:28 ` Jan Kara
2013-08-21  2:28   ` Chen Gang
2013-08-20 23:29 ` Andrew Morton
2013-08-21  3:35   ` Chen Gang
2013-08-21  3:45     ` Andrew Morton
2013-08-21  3:56       ` Chen Gang

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