[PATCH 4.7 22/69] configfs: Return -EFBIG from configfs_write_bin_file.
From: Greg Kroah-Hartman
Date: Wed Sep 28 2016 - 05:25:35 EST
4.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Phil Turnbull <phil.turnbull@xxxxxxxxxx>
commit 42857cf512cb34c2c8cb50f1e766689d979d64e0 upstream.
The check for writing more than cb_max_size bytes does not 'goto out' so
it is a no-op which allows users to vmalloc an arbitrary amount.
Fixes: 03607ace807b ("configfs: implement binary attributes")
Signed-off-by: Phil Turnbull <phil.turnbull@xxxxxxxxxx>
Signed-off-by: Christoph Hellwig <hch@xxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
fs/configfs/file.c | 1 +
1 file changed, 1 insertion(+)
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -333,6 +333,7 @@ configfs_write_bin_file(struct file *fil
if (bin_attr->cb_max_size &&
*ppos + count > bin_attr->cb_max_size) {
len = -EFBIG;
+ goto out;
}
tbuf = vmalloc(*ppos + count);