Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.17 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795992393; b=tBX1M3Ts6GcBgbjhyfQYsm1ikcpeIhFnoPcSL5QcyBfFkaKrFjqK11LtBRyn9zEz7max 2Po9aE8s6XpAhwCbrqUyCbXNd//UWR/R/PYV6rc5Lftqc5BfPplvS8TMqSuPyM2v7GxsH VLlYrZOkGHq6nj/IyZTyiK6QLhD/MU4wzs+mo/q5zTTLR1mQY5p+JtGjzhlwBopSyee5j eJAoi/RQ+ekCbCybTEuHrSqWEGPUqPmdt/nvStq1MwP+9PkIvCCuXv3FuiqohOZ4SRwrx W8Ky76wSR7e5teWM1VpYwq1GiCbLLSa/HIiRnMB96hgmdrX7lxdWesGDgZ0hBuvpcAQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795992393; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Received:Date:From:To: Cc:Subject:Message-ID:User-Agent; bh=9egi5i8Kyw20dO6r6ZUk5yG6lG1yXVcwJqDalEEjRGg=; b=WABRVr99FrvqA+sWeOa21x9L7CiftYYUsZqd8pOPspk9eiXM6stzaVb1qHP7dn7GhrEp eqiGj3YMi/JAvCMj6NzhMBX5ADlTFJT2HnOgAE8oiAe5O1jvTRH6cjF8kl53jq5oiEhtA hA59LYNd9YvQ3Ehgzcy/t1i35YfYG8vtwd3HnSADldG4hGxcay5TarP1Q116lpm4V1es5 1IC4ac4DyBUqWamh0HrOx6lmEo4pHrrD2TlRlJfL9/vIKLvGpRNFCxqKQ6zV5XR242qU1 PqtUFzB5SvdU4EozuhYuLrrA2bN5AWw40hIjs9oAdBiGXpCADRlNCrFo0QitgOE12og== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=g4GgxDE5; arc=none smtp.remote-ip=198.175.65.17 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD51B606A31C for ; Sun, 29 Nov 2026 22:46:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BD51B606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=g4GgxDE5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1795992391; x=1827528391; h=date:from:to:cc:subject:message-id; bh=dt70vWiRxZTejemweORnV2QIeMmZObRxDKox+f/Tl3U=; b=g4GgxDE5hqyWFxDyIjaxZs1WPA86NE0TlX8xFNWklE9i4Mzqbap8Tk++ srp81hND/ixQuzVsOfUzed8dVUgy8XhTCxtMYP1UofqGT3aWa3T3LPA+O Eau8e3O7XIrYsLMkCry/NyA5iyMGeVNrDf74ffoNsN1XGGMszNLwSTrB+ AKc6MRvo698e/BrScpfoLWqhT+ZPKIOmy9Db/A9E6KT0ImL2vm7sJ+2ag ug6XSFP5j4+xSXEMwZW06M/SMSbTX+ktFWOwnnkv2NntDXnHTci5U5CPx L8x8e4iqJY/fEobPbbiWGOOVH18+7K+SjIaCLqYQMrOT/Zy2w8HXoea6U w==; X-CSE-ConnectionGUID: Vg6FmCkJTHa+vRBt4Lg3Aw== X-CSE-MsgGUID: olxJ4jobQnmGJHDGU9pisg== X-IronPort-AV: E=McAfee;i="6800,10657,11981"; a="4812986" X-IronPort-AV: E=Sophos;i="6.27,241,1787036400"; d="scan'208";a="4812986" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2026 14:46:30 -0800 X-CSE-ConnectionGUID: WsNlAZQsTaORkEtVUdJoGA== X-CSE-MsgGUID: pMhQXHmeRiG3ERlszGryrw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,241,1787036400"; d="scan'208";a="13026419" Received: from igk-lkp-server01.igk.intel.com (HELO 146cf1e082f1) ([10.211.93.152]) by fmviesa003.fm.intel.com with ESMTP; 29 Nov 2026 14:46:29 -0800 Received: from kbuild by 146cf1e082f1 with local (Exim 4.98.2) (envelope-from ) id 1xXnf8-00000000198-38Lt; Sun, 29 Nov 2026 22:46:26 +0000 Date: Sun, 29 Nov 2026 23:46:26 +0100 From: kernel test robot To: oe-kbuild@lists.linux.dev Cc: lkp@intel.com, Dan Carpenter 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) Message-ID: <20261129234100.GJEXuiuA-lkp@intel.com> User-Agent: s-nail v14.9.25 X-Mailing-List: oe-kbuild@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 | Reported-by: Dan Carpenter | 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 :::::: CC: Jarkko Sakkinen -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki