diff --git a/fs/attr.c b/fs/attr.c
index d22e8187477fa77350c003d73a446284c02383bb..4d2541c1e68c3d857c46b118aa9cc494d87748c4 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -134,6 +134,8 @@ EXPORT_SYMBOL(setattr_prepare);
  */
 int inode_newsize_ok(const struct inode *inode, loff_t offset)
 {
+	if (offset < 0)
+		return -EINVAL;
 	if (inode->i_size < offset) {
 		unsigned long limit;