Skip to contentSkip to conversation

orangefs: handle zero size write in debugfs

PATCH New Dan Carpenter 1 participant 1 message Apr 14, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 orangefs: handle zero size write in debugfs

If we write zero bytes to this debugfs file, then it will cause an underflow when we do copy_from_user(buf, ubuf, count - 1). Debugfs can normally only be written to by root so the impact of this is low.

fs/orangefs/orangefs-debugfs.c +3 -0
index 791912da97d7..716ed337f166 100644
@@ -440,6 +440,9 @@ static ssize_t orangefs_debug_write(struct file *file,
 		"orangefs_debug_write: %pD\n",
 		file);
 
+	if (count = 0)
+		return 0;
+
 	/*
 	 * Thwart users who try to jamb a ridiculous number
 	 * of bytes into the debug file...