]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
smackfs: restrict bytes count in smackfs write functions
authorSabyrzhan Tasbolatov <snovitoll@gmail.com>
Thu, 28 Jan 2021 11:58:01 +0000 (17:58 +0600)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Apr 2021 16:31:44 +0000 (18:31 +0200)
commit6508110166c6311192f7adbe37fb86cebf6f9cb3
tree7a3183f15a07afe2241f94cc23572bfdf4d939ce
parente533dc0b3bc73401cbd1529e193b825a50aa0b0e
smackfs: restrict bytes count in smackfs write functions

BugLink: https://bugs.launchpad.net/bugs/1920235
commit 7ef4c19d245f3dc233fd4be5acea436edd1d83d8 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: syzbot+a71a442385a0b2815497@syzkaller.appspotmail.com
Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
security/smack/smackfs.c