From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: [jarkko-tpmdd:keyring_gc 18/19] security/keys/keyring.c:1096 keyring_restrict() error: we previously assumed 'restrict_link' could be null (see line 1082)
Date: Sun, 29 Nov 2026 23:46:26 +0100 [thread overview]
Message-ID: <20261129234100.GJEXuiuA-lkp@intel.com> (raw)
Unfiltered warning: this smatch report is sent as-is and has not been
reviewed for false positives, so please treat it with due skepticism.
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Jarkko Sakkinen <jarkko@kernel.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git keyring_gc
head: 977007b8a422c1f6cb8a43989b90192e98b4de60
commit: 8ed834d1b69de743e345d84a9310f3ba8cc5ae97 [18/19] KEYS: Pin the backing kernel module for a key type
:::::: branch date: 8 hours ago
:::::: commit date: 8 hours ago
config: m68k-randconfig-2200-20261129 (https://download.01.org/0day-ci/archive/20261129/20261129234100.GJEXuiuA-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 8.5.0
smatch: v0.5.0-9187-g5189e3fb
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/20261129234100.GJEXuiuA-lkp@intel.com/
New smatch warnings:
security/keys/keyring.c:1096 keyring_restrict() error: we previously assumed 'restrict_link' could be null (see line 1082)
Old smatch warnings:
security/keys/keyring.c:1274 keyring_detect_cycle() warn: passing zero to 'PTR_ERR'
vim +/restrict_link +1096 security/keys/keyring.c
6563c91fd64555 Mat Martineau 2017-03-01 1036
6563c91fd64555 Mat Martineau 2017-03-01 1037 /**
6563c91fd64555 Mat Martineau 2017-03-01 1038 * keyring_restrict - Look up and apply a restriction to a keyring
9fd165379eff95 David Howells 2019-05-22 1039 * @keyring_ref: The keyring to be restricted
9fd165379eff95 David Howells 2019-05-22 1040 * @type: The key type that will provide the restriction checker.
6563c91fd64555 Mat Martineau 2017-03-01 1041 * @restriction: The restriction options to apply to the keyring
9fd165379eff95 David Howells 2019-05-22 1042 *
9fd165379eff95 David Howells 2019-05-22 1043 * Look up a keyring and apply a restriction to it. The restriction is managed
9fd165379eff95 David Howells 2019-05-22 1044 * by the specific key type, but can be configured by the options specified in
9fd165379eff95 David Howells 2019-05-22 1045 * the restriction string.
6563c91fd64555 Mat Martineau 2017-03-01 1046 */
6563c91fd64555 Mat Martineau 2017-03-01 1047 int keyring_restrict(key_ref_t keyring_ref, const char *type,
6563c91fd64555 Mat Martineau 2017-03-01 1048 const char *restriction)
6563c91fd64555 Mat Martineau 2017-03-01 1049 {
6563c91fd64555 Mat Martineau 2017-03-01 1050 struct key *keyring;
6563c91fd64555 Mat Martineau 2017-03-01 1051 struct key_type *restrict_type = NULL;
6563c91fd64555 Mat Martineau 2017-03-01 1052 struct key_restriction *restrict_link;
6563c91fd64555 Mat Martineau 2017-03-01 1053 int ret = 0;
6563c91fd64555 Mat Martineau 2017-03-01 1054
6563c91fd64555 Mat Martineau 2017-03-01 1055 keyring = key_ref_to_ptr(keyring_ref);
6563c91fd64555 Mat Martineau 2017-03-01 1056 key_check(keyring);
6563c91fd64555 Mat Martineau 2017-03-01 1057
6563c91fd64555 Mat Martineau 2017-03-01 1058 if (keyring->type != &key_type_keyring)
6563c91fd64555 Mat Martineau 2017-03-01 1059 return -ENOTDIR;
6563c91fd64555 Mat Martineau 2017-03-01 1060
6563c91fd64555 Mat Martineau 2017-03-01 1061 if (!type) {
6563c91fd64555 Mat Martineau 2017-03-01 1062 restrict_link = keyring_restriction_alloc(restrict_link_reject);
6563c91fd64555 Mat Martineau 2017-03-01 1063 } else {
6563c91fd64555 Mat Martineau 2017-03-01 1064 restrict_type = key_type_lookup(type);
6563c91fd64555 Mat Martineau 2017-03-01 1065
6563c91fd64555 Mat Martineau 2017-03-01 1066 if (IS_ERR(restrict_type))
6563c91fd64555 Mat Martineau 2017-03-01 1067 return PTR_ERR(restrict_type);
6563c91fd64555 Mat Martineau 2017-03-01 1068
6563c91fd64555 Mat Martineau 2017-03-01 1069 if (!restrict_type->lookup_restriction) {
6563c91fd64555 Mat Martineau 2017-03-01 1070 ret = -ENOENT;
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1071 goto out;
6563c91fd64555 Mat Martineau 2017-03-01 1072 }
6563c91fd64555 Mat Martineau 2017-03-01 1073
6563c91fd64555 Mat Martineau 2017-03-01 1074 restrict_link = restrict_type->lookup_restriction(restriction);
6563c91fd64555 Mat Martineau 2017-03-01 1075 }
6563c91fd64555 Mat Martineau 2017-03-01 1076
6563c91fd64555 Mat Martineau 2017-03-01 1077 if (IS_ERR(restrict_link)) {
6563c91fd64555 Mat Martineau 2017-03-01 1078 ret = PTR_ERR(restrict_link);
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1079 goto out;
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1080 }
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1081
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 @1082 if (restrict_link && restrict_link->keytype &&
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1083 !try_module_get(restrict_link->keytype->owner)) {
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1084 ret = -ENOENT;
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1085 goto out_free_restriction;
6563c91fd64555 Mat Martineau 2017-03-01 1086 }
6563c91fd64555 Mat Martineau 2017-03-01 1087
6563c91fd64555 Mat Martineau 2017-03-01 1088 down_write(&keyring->sem);
6563c91fd64555 Mat Martineau 2017-03-01 1089 down_write(&keyring_serialise_restrict_sem);
6563c91fd64555 Mat Martineau 2017-03-01 1090
f7e47677e39a03 David Howells 2020-01-14 1091 if (keyring->restrict_link) {
6563c91fd64555 Mat Martineau 2017-03-01 1092 ret = -EEXIST;
f7e47677e39a03 David Howells 2020-01-14 1093 } else if (keyring_detect_restriction_cycle(keyring, restrict_link)) {
6563c91fd64555 Mat Martineau 2017-03-01 1094 ret = -EDEADLK;
f7e47677e39a03 David Howells 2020-01-14 1095 } else {
e36bf5d3721f0b Jarkko Sakkinen 2026-11-04 @1096 if (restrict_link->keytype)
e36bf5d3721f0b Jarkko Sakkinen 2026-11-04 1097 atomic_inc(&restrict_link->keytype->nr_keys);
6563c91fd64555 Mat Martineau 2017-03-01 1098 keyring->restrict_link = restrict_link;
f7e47677e39a03 David Howells 2020-01-14 1099 notify_key(keyring, NOTIFY_KEY_SETATTR, 0);
f7e47677e39a03 David Howells 2020-01-14 1100 }
6563c91fd64555 Mat Martineau 2017-03-01 1101
6563c91fd64555 Mat Martineau 2017-03-01 1102 up_write(&keyring_serialise_restrict_sem);
6563c91fd64555 Mat Martineau 2017-03-01 1103 up_write(&keyring->sem);
6563c91fd64555 Mat Martineau 2017-03-01 1104
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1105 if (ret < 0)
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1106 goto out_put_module;
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1107
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1108 goto out;
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1109
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1110 out_put_module:
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1111 if (restrict_link && restrict_link->keytype)
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1112 module_put(restrict_link->keytype->owner);
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1113
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1114 out_free_restriction:
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1115 if (restrict_link)
6563c91fd64555 Mat Martineau 2017-03-01 1116 key_put(restrict_link->key);
6563c91fd64555 Mat Martineau 2017-03-01 1117 kfree(restrict_link);
6563c91fd64555 Mat Martineau 2017-03-01 1118
8ed834d1b69de7 Jarkko Sakkinen 2026-11-03 1119 out:
6563c91fd64555 Mat Martineau 2017-03-01 1120 if (restrict_type)
6563c91fd64555 Mat Martineau 2017-03-01 1121 key_type_put(restrict_type);
6563c91fd64555 Mat Martineau 2017-03-01 1122
6563c91fd64555 Mat Martineau 2017-03-01 1123 return ret;
6563c91fd64555 Mat Martineau 2017-03-01 1124 }
6563c91fd64555 Mat Martineau 2017-03-01 1125 EXPORT_SYMBOL(keyring_restrict);
6563c91fd64555 Mat Martineau 2017-03-01 1126
:::::: The code at line 1096 was first introduced by commit
:::::: e36bf5d3721f0bb5e53c0d030c705472d7c721a5 KEYS: Add key_gc_flush() for draining RCU callbacks
:::::: TO: Jarkko Sakkinen <jarkko@kernel.org>
:::::: CC: Jarkko Sakkinen <jarkko@kernel.org>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2026-11-29 22:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261129234100.GJEXuiuA-lkp@intel.com \
--to=lkp@intel.com \
--cc=error27@gmail.com \
--cc=oe-kbuild@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.