From: Richard Yao Subject: [PATCH] fs: generic_file_llseek_size() should recognize invalid whence values Date: Thu, 27 Jun 2013 22:22:38 -0400 Message-ID: <1372386158-11076-3-git-send-email-ryao@gentoo.org> References: <1372386158-11076-1-git-send-email-ryao@gentoo.org> Reply-To: zfs-devel-VKpPRiiRko4/ohRxsw7f2g@public.gmane.org Mime-Version: 1.0 Cc: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kernel-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org, zfs-devel-VKpPRiiRko4/ohRxsw7f2g@public.gmane.org, Richard Yao To: Alexander Viro Return-path: In-Reply-To: <1372386158-11076-1-git-send-email-ryao-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org> List-Post: , List-Help: , List-Archive: List-Subscribe: , List-Unsubscribe: , List-Id: linux-fsdevel.vger.kernel.org generic_file_llseek_size() handles whence values in a switch statement, but it lacks cases for both SEEK_SET and invalid values. This causes it to treat all invalid whence values as SEEK_SET, which is wrong. We fix that by adding a case for SEEK_SET and a default case. Signed-off-by: Richard Yao --- fs/read_write.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index 0343000..54b8808 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -81,6 +81,7 @@ generic_file_llseek_size(struct file *file, loff_t offset, int whence, switch (whence) { case SEEK_END: offset += eof; + case SEEK_SET: break; case SEEK_CUR: /* @@ -118,6 +119,8 @@ generic_file_llseek_size(struct file *file, loff_t offset, int whence, return -ENXIO; offset = eof; break; + default: + return -EINVAL; } return lseek_execute(file, inode, offset, maxsize); -- 1.8.1.5