device_cgroup: Roll back to original exceptions after copy failure
authorWang Weiyang <wangweiyang2@huawei.com>
Tue, 25 Oct 2022 11:31:01 +0000 (19:31 +0800)
committerPaul Moore <paul@paul-moore.com>
Wed, 16 Nov 2022 23:28:55 +0000 (18:28 -0500)
commite68bfbd3b3c3a0ec3cf8c230996ad8cabe90322f
tree38c521ea4ca6b0b842517a26d1833c9a3e9feef2
parent86ef3c735ec81566cd38174ed5e90e9721473064
device_cgroup: Roll back to original exceptions after copy failure

When add the 'a *:* rwm' entry to devcgroup A's whitelist, at first A's
exceptions will be cleaned and A's behavior is changed to
DEVCG_DEFAULT_ALLOW. Then parent's exceptions will be copyed to A's
whitelist. If copy failure occurs, just return leaving A to grant
permissions to all devices. And A may grant more permissions than
parent.

Backup A's whitelist and recover original exceptions after copy
failure.

Cc: stable@vger.kernel.org
Fixes: 4cef7299b478 ("device_cgroup: add proper checking when changing default behavior")
Signed-off-by: Wang Weiyang <wangweiyang2@huawei.com>
Reviewed-by: Aristeu Rozanski <aris@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/device_cgroup.c