Commit d815b197 authored by Sabyrzhan Tasbolatov's avatar Sabyrzhan Tasbolatov Committed by Zheng Zengkai
Browse files

smackfs: restrict bytes count in smackfs write functions



stable inclusion
from stable-5.10.21
commit fa5b65609256fee27199c81368e984e48cb5dcfe
bugzilla: 50609

--------------------------------

commit 7ef4c19d upstream.

syzbot found WARNINGs in several smackfs write operations where
bytes count is passed to memdup_user_nul which exceeds
GFP MAX_ORDER. Check count size if bigger than PAGE_SIZE.

Per smackfs doc, smk_write_net4addr accepts any label or -CIPSO,
smk_write_net6addr accepts any label or -DELETE. I couldn't find
any general rule for other label lengths except SMK_LABELLEN,
SMK_LONGLABEL, SMK_CIPSOMAX which are documented.

Let's constrain, in general, smackfs label lengths for PAGE_SIZE.
Although fuzzer crashes write to smackfs/netlabel on 0x400000 length.

Here is a quick way to reproduce the WARNING:
python -c "print('A' * 0x400000)" > /sys/fs/smackfs/netlabel

Reported-by: default avatar <syzbot+a71a442385a0b2815497@syzkaller.appspotmail.com>
Signed-off-by: default avatarSabyrzhan Tasbolatov <snovitoll@gmail.com>
Signed-off-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarChen Jun <chenjun102@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 05c104e3
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment