提交 197123c9 编写于 作者: L Linus Torvalds 提交者: Xie XiuQi

security: don't use a negative Opt_err token index

mainline inclusion
from mainline-4.20
commit 94c13f66e13ca0f3d5b7b9e7e385fe5db35abe3c
category: bugfix
bugzilla: 6257
CVE: NA

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

The code uses a bitmap to check for duplicate tokens during parsing, and
that doesn't work at all for the negative Opt_err token case.

There is absolutely no reason to make Opt_err be negative, and in fact
it only confuses things, since some of the affected functions actually
return a positive Opt_xyz enum _or_ a regular negative error code (eg
-EINVAL), and using -1 for Opt_err makes no sense.

There are similar problems in ima_policy.c and key encryption, but they
don't have the immediate bug wrt bitmap handing, and ima_policy.c in
particular needs a different patch to make the enum values match the
token array index.  Mimi is sending that separately.

Reported-by: syzbot+a22e0dc07567662c50bc@syzkaller.appspotmail.com
Reported-by: NEric Biggers <ebiggers@kernel.org>
Fixes: 5208cc83 ("keys, trusted: fix: *do not* allow duplicate key options")
Fixes: 00d60fd3b932 ("KEYS: Provide keyctls to drive the new key type ops for asymmetric keys [ver #2]")
Cc: James Morris James Morris <jmorris@namei.org>
Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>

Conflicts:
	security/keys/keyctl_pkey.c

commit 00d60fd3b932 ("KEYS: Provide keyctls to drive the new key type ops for
asymmetric keys [ver #2]") has not been merged to 4.19, so no file
security/keys/keyctl_pkey.c at all.
Signed-off-by: NJason Yan <yanaijie@huawei.com>
Reviewed-by: NZhang xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 37692be9
...@@ -707,7 +707,7 @@ static int key_unseal(struct trusted_key_payload *p, ...@@ -707,7 +707,7 @@ static int key_unseal(struct trusted_key_payload *p,
} }
enum { enum {
Opt_err = -1, Opt_err,
Opt_new, Opt_load, Opt_update, Opt_new, Opt_load, Opt_update,
Opt_keyhandle, Opt_keyauth, Opt_blobauth, Opt_keyhandle, Opt_keyauth, Opt_blobauth,
Opt_pcrinfo, Opt_pcrlock, Opt_migratable, Opt_pcrinfo, Opt_pcrlock, Opt_migratable,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册