All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-next:master 1673/2307] security/apparmor/apparmorfs.c:590 policy_update() warn: passing zero to 'PTR_ERR'
@ 2026-07-01  6:50 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-07-01  6:50 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: "Maxime Bélair" <maxime.belair@canonical.com>
CC: John Johansen <john.johansen@canonical.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   be5c93fa674f0fc3c8f359c2143abce6bbb422e6
commit: 17b5758bf35c7a113363cd7a350b7e6a251b80f4 [1673/2307] apparmor: Initial support for compressed policies
:::::: branch date: 13 hours ago
:::::: commit date: 2 days ago
config: x86_64-randconfig-161-20260701 (https://download.01.org/0day-ci/archive/20260701/202607011451.icwPyCIk-lkp@intel.com/config)
compiler: clang version 22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb4502213fcf902a211)
smatch: v0.5.0-9185-gbcc58b9c

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/202607011451.icwPyCIk-lkp@intel.com/

smatch warnings:
security/apparmor/apparmorfs.c:590 policy_update() warn: passing zero to 'PTR_ERR'

vim +/PTR_ERR +590 security/apparmor/apparmorfs.c

63e2b423771ab0 John Johansen 2010-07-29  548  
18e99f191a8e66 John Johansen 2017-05-26  549  static ssize_t policy_update(u32 mask, const char __user *buf, size_t size,
6601e13e828418 John Johansen 2025-11-07  550  			     loff_t *pos, struct aa_ns *ns,
6601e13e828418 John Johansen 2025-11-07  551  			     const struct cred *ocred)
63e2b423771ab0 John Johansen 2010-07-29  552  {
5ac8c355ae0013 John Johansen 2017-01-16  553  	struct aa_loaddata *data;
637f688dc3dc30 John Johansen 2017-06-09  554  	struct aa_label *label;
637f688dc3dc30 John Johansen 2017-06-09  555  	ssize_t error;
17b5758bf35c7a Maxime Bélair 2024-02-01  556  	char *compressed_data = NULL;
17b5758bf35c7a Maxime Bélair 2024-02-01  557  	__le32 magic_le;
17b5758bf35c7a Maxime Bélair 2024-02-01  558  	bool is_compressed;
cf797c0e5e3125 John Johansen 2017-06-09  559  
637f688dc3dc30 John Johansen 2017-06-09  560  	label = begin_current_label_crit_section();
cf797c0e5e3125 John Johansen 2017-06-09  561  
5ac8c355ae0013 John Johansen 2017-01-16  562  	/* high level check about policy management - fine grained in
5ac8c355ae0013 John Johansen 2017-01-16  563  	 * below after unpack
5ac8c355ae0013 John Johansen 2017-01-16  564  	 */
6601e13e828418 John Johansen 2025-11-07  565  	error = aa_may_manage_policy(current_cred(), label, ns, ocred, mask);
5ac8c355ae0013 John Johansen 2017-01-16  566  	if (error)
c6b39f070722ea Xiyu Yang     2020-04-20  567  		goto end_section;
63e2b423771ab0 John Johansen 2010-07-29  568  
17b5758bf35c7a Maxime Bélair 2024-02-01  569  	/* If the policy is userspace compressed we start by decompressing it
17b5758bf35c7a Maxime Bélair 2024-02-01  570  	 * to make the required checks (computing hash, verifying profile, ...)
17b5758bf35c7a Maxime Bélair 2024-02-01  571  	 *
17b5758bf35c7a Maxime Bélair 2024-02-01  572  	 * Getting a userspace-compressed version then decompressing it in the
17b5758bf35c7a Maxime Bélair 2024-02-01  573  	 * kernel actually makes sense since zstd decompression is ~3.5x faster
17b5758bf35c7a Maxime Bélair 2024-02-01  574  	 * than compression. This also allow to increase the compression level.
17b5758bf35c7a Maxime Bélair 2024-02-01  575  	 */
17b5758bf35c7a Maxime Bélair 2024-02-01  576  
17b5758bf35c7a Maxime Bélair 2024-02-01  577  	if (size >= sizeof(__le32) &&
17b5758bf35c7a Maxime Bélair 2024-02-01  578  	    !copy_from_user(&magic_le, buf, sizeof(magic_le)) &&
17b5758bf35c7a Maxime Bélair 2024-02-01  579  	    le32_to_cpu(magic_le) == ZSTD_MAGICNUMBER)
17b5758bf35c7a Maxime Bélair 2024-02-01  580  		is_compressed = true;
17b5758bf35c7a Maxime Bélair 2024-02-01  581  	else
17b5758bf35c7a Maxime Bélair 2024-02-01  582  		is_compressed = false;
17b5758bf35c7a Maxime Bélair 2024-02-01  583  
17b5758bf35c7a Maxime Bélair 2024-02-01  584  	if (is_compressed) {
17b5758bf35c7a Maxime Bélair 2024-02-01  585  
17b5758bf35c7a Maxime Bélair 2024-02-01  586  		data = aa_get_data_from_compressed(buf, size, pos, &compressed_data);
17b5758bf35c7a Maxime Bélair 2024-02-01  587  		error = PTR_ERR(data);
17b5758bf35c7a Maxime Bélair 2024-02-01  588  	} else {
5ef50d014c5924 John Johansen 2017-01-16  589  		data = aa_simple_write_to_buffer(buf, size, size, pos);
63e2b423771ab0 John Johansen 2010-07-29 @590  		error = PTR_ERR(data);
17b5758bf35c7a Maxime Bélair 2024-02-01  591  	}
17b5758bf35c7a Maxime Bélair 2024-02-01  592  
63e2b423771ab0 John Johansen 2010-07-29  593  	if (!IS_ERR(data)) {
17b5758bf35c7a Maxime Bélair 2024-02-01  594  		error = aa_replace_profiles(ns, label, mask, data,
17b5758bf35c7a Maxime Bélair 2024-02-01  595  					    compressed_data, size);
a0b7091c4de45a John Johansen 2026-02-24  596  		/* put pcount, which will put count and free if no
a0b7091c4de45a John Johansen 2026-02-24  597  		 * profiles referencing it.
a0b7091c4de45a John Johansen 2026-02-24  598  		 */
a0b7091c4de45a John Johansen 2026-02-24  599  		aa_put_profile_loaddata(data);
63e2b423771ab0 John Johansen 2010-07-29  600  	}
c6b39f070722ea Xiyu Yang     2020-04-20  601  end_section:
637f688dc3dc30 John Johansen 2017-06-09  602  	end_current_label_crit_section(label);
63e2b423771ab0 John Johansen 2010-07-29  603  
63e2b423771ab0 John Johansen 2010-07-29  604  	return error;
63e2b423771ab0 John Johansen 2010-07-29  605  }
63e2b423771ab0 John Johansen 2010-07-29  606  

:::::: The code at line 590 was first introduced by commit
:::::: 63e2b423771ab0bc7ad4d407f3f6517c6d05cdc0 AppArmor: userspace interfaces

:::::: TO: John Johansen <john.johansen@canonical.com>
:::::: CC: James Morris <jmorris@namei.org>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-01  6:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-01  6:50 [linux-next:master 1673/2307] security/apparmor/apparmorfs.c:590 policy_update() warn: passing zero to 'PTR_ERR' kernel test robot

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.