Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

jfs: Fix fortify moan in symlink

JFS has in jfs_incore.h:

/* _inline may overflow into _inline_ea when needed */
/* _inline_ea may overlay the last part of
* file._xtroot if maxentry = XTROOTINITSLOT
*/
union {
struct {
/* 128: inline symlink */
unchar _inline[128];
/* 128: inline extended attr */
unchar _inline_ea[128];
};
unchar _inline_all[256];

and currently the symlink code copies into _inline;
if this is larger than 128 bytes it triggers a fortify warning of the
form:

memcpy: detected field-spanning write (size 132) of single field
"ip->i_link" at fs/jfs/namei.c:950 (size 18446744073709551615)

when it's actually OK.

Copy it into _inline_all instead.

Reported-by: syzbot+5fc38b2ddbbca7f5c680@syzkaller.appspotmail.com
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>

authored by

Dr. David Alan Gilbert and committed by
Dave Kleikamp
ebe06036 dee87445

+1 -1
+1 -1
fs/jfs/namei.c
··· 946 946 if (ssize <= IDATASIZE) { 947 947 ip->i_op = &jfs_fast_symlink_inode_operations; 948 948 949 - ip->i_link = JFS_IP(ip)->i_inline; 949 + ip->i_link = JFS_IP(ip)->i_inline_all; 950 950 memcpy(ip->i_link, name, ssize); 951 951 ip->i_size = ssize - 1; 952 952