Whamcloud - gitweb
LU-12911 llite: Don't access lov_md fields before size check 33/38433/3
authorMr NeilBrown <neilb@suse.de>
Mon, 28 Oct 2019 01:24:26 +0000 (12:24 +1100)
committerOleg Drokin <green@whamcloud.com>
Wed, 20 May 2020 00:42:12 +0000 (00:42 +0000)
commit6b0011b8b9cd1a0fc5752512067ae2e384bf8adb
tree1ba6004cc351fb23439a53e9c145ce765a351ac1
parent21b34dd8a226fbaf2fee52b294f2482aa8670ad2
LU-12911 llite: Don't access lov_md fields before size check

When 'struct lov_user_md' is passed in via setxattr, it comes with
a size.  If thatt size is too small, some function that check exactly
what version is present might access beyond the end of allocation
memory, which can have undesirable effects, such as triggering
a KASAN warning (and possibly worse).

So check that the size is sane before looking inside the structure
at all.

Lustre-change: https://review.whamcloud.com/36589
Lustre-commit f2d06d3c76a1d69447e7bd6fd29d8165be558d73

Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: Ib3f071a3ff77a039fdfa38c903d87999108b3322
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-on: https://review.whamcloud.com/38433
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/xattr.c