OSDN Git Service

fs: nfs: Fix possible null-pointer dereferences in encode_attrs()
authorJia-Ju Bai <baijiaju1990@gmail.com>
Fri, 26 Jul 2019 07:48:53 +0000 (15:48 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Oct 2019 20:40:54 +0000 (13:40 -0700)
commit5deaece94aa9f3be912ec2c61483ba876fcef12e
tree994c3e993ca3d08a647f8cb6c102fdae1f27fe0f
parentb1b8f7b23a2832f46593707627fee765575bcd7c
fs: nfs: Fix possible null-pointer dereferences in encode_attrs()

[ Upstream commit e2751463eaa6f9fec8fea80abbdc62dbc487b3c5 ]

In encode_attrs(), there is an if statement on line 1145 to check
whether label is NULL:
    if (label && (attrmask[2] & FATTR4_WORD2_SECURITY_LABEL))

When label is NULL, it is used on lines 1178-1181:
    *p++ = cpu_to_be32(label->lfs);
    *p++ = cpu_to_be32(label->pi);
    *p++ = cpu_to_be32(label->len);
    p = xdr_encode_opaque_fixed(p, label->label, label->len);

To fix these bugs, label is checked before being used.

These bugs are found by a static analysis tool STCheck written by us.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/nfs4xdr.c