All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com
Subject: security/apparmor/af_unix.c:764:50: sparse: warning: incorrect type in argument 1 (different address spaces)
Date: Tue, 01 Dec 2026 05:57:23 +0100	[thread overview]
Message-ID: <20261201054651.Cbj4629p-lkp@intel.com> (raw)

:::::: 
:::::: Manual check reason: "low confidence static check warning: security/apparmor/af_unix.c:764:50: sparse: warning: incorrect type in argument 1 (different address spaces)"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: John Johansen <john.johansen@canonical.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   19cc08c1a6a650f8e54c0461ff198be6448f425d
commit: 4483efe4f21510b30c24bc97d9fd0e8feab94125 apparmor: fix shadowing of plabel that prevents cache from being updated
date:   6 months ago
:::::: branch date: 8 hours ago
:::::: commit date: 6 months ago
config: x86_64-randconfig-2300-20261130 (https://download.01.org/0day-ci/archive/20261201/20261201054651.Cbj4629p-lkp@intel.com/config)
compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
sparse: v0.6.5-rc1-94-g0d159c10
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261201/20261201054651.Cbj4629p-lkp@intel.com/reproduce)

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
| Fixes: 4483efe4f215 ("apparmor: fix shadowing of plabel that prevents cache from being updated")
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/20261201054651.Cbj4629p-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> security/apparmor/af_unix.c:764:50: sparse: warning: incorrect type in argument 1 (different address spaces)
   security/apparmor/af_unix.c:764:50: sparse:    expected struct aa_label *l
   security/apparmor/af_unix.c:764:50: sparse:    got struct aa_label [noderef] __rcu *label

vim +764 security/apparmor/af_unix.c

88fec3526e84123 John Johansen 2025-06-19  705  
bc6e5f6933b8e7b John Johansen 2025-04-01  706  /* This fn is only checked if something has changed in the security
bc6e5f6933b8e7b John Johansen 2025-04-01  707   * boundaries. Otherwise cached info off file is sufficient
bc6e5f6933b8e7b John Johansen 2025-04-01  708   */
c05e705812d179f John Johansen 2022-09-07  709  int aa_unix_file_perm(const struct cred *subj_cred, struct aa_label *label,
c05e705812d179f John Johansen 2022-09-07  710  		      const char *op, u32 request, struct file *file)
c05e705812d179f John Johansen 2022-09-07  711  {
c05e705812d179f John Johansen 2022-09-07  712  	struct socket *sock = (struct socket *) file->private_data;
bc6e5f6933b8e7b John Johansen 2025-04-01  713  	struct sockaddr_un *addr, *peer_addr;
bc6e5f6933b8e7b John Johansen 2025-04-01  714  	int addrlen, peer_addrlen;
88fec3526e84123 John Johansen 2025-06-19  715  	struct aa_label *plabel = NULL;
c05e705812d179f John Johansen 2022-09-07  716  	struct sock *peer_sk = NULL;
c05e705812d179f John Johansen 2022-09-07  717  	u32 sk_req = request & ~NET_PEER_MASK;
bc6e5f6933b8e7b John Johansen 2025-04-01  718  	struct path path;
c05e705812d179f John Johansen 2022-09-07  719  	bool is_sk_fs;
c05e705812d179f John Johansen 2022-09-07  720  	int error = 0;
c05e705812d179f John Johansen 2022-09-07  721  
c05e705812d179f John Johansen 2022-09-07  722  	AA_BUG(!label);
c05e705812d179f John Johansen 2022-09-07  723  	AA_BUG(!sock);
c05e705812d179f John Johansen 2022-09-07  724  	AA_BUG(!sock->sk);
c05e705812d179f John Johansen 2022-09-07  725  	AA_BUG(sock->sk->sk_family != PF_UNIX);
c05e705812d179f John Johansen 2022-09-07  726  
bc6e5f6933b8e7b John Johansen 2025-04-01  727  	/* investigate only using lock via unix_peer_get()
bc6e5f6933b8e7b John Johansen 2025-04-01  728  	 * addr only needs the memory barrier, but need to investigate
bc6e5f6933b8e7b John Johansen 2025-04-01  729  	 * path
bc6e5f6933b8e7b John Johansen 2025-04-01  730  	 */
c05e705812d179f John Johansen 2022-09-07  731  	unix_state_lock(sock->sk);
c05e705812d179f John Johansen 2022-09-07  732  	peer_sk = unix_peer(sock->sk);
c05e705812d179f John Johansen 2022-09-07  733  	if (peer_sk)
c05e705812d179f John Johansen 2022-09-07  734  		sock_hold(peer_sk);
c05e705812d179f John Johansen 2022-09-07  735  
c05e705812d179f John Johansen 2022-09-07  736  	is_sk_fs = is_unix_fs(sock->sk);
bc6e5f6933b8e7b John Johansen 2025-04-01  737  	addr = aa_sunaddr(unix_sk(sock->sk), &addrlen);
bc6e5f6933b8e7b John Johansen 2025-04-01  738  	path = unix_sk(sock->sk)->path;
bc6e5f6933b8e7b John Johansen 2025-04-01  739  	unix_state_unlock(sock->sk);
bc6e5f6933b8e7b John Johansen 2025-04-01  740  
c05e705812d179f John Johansen 2022-09-07  741  	if (is_sk_fs && peer_sk)
c05e705812d179f John Johansen 2022-09-07  742  		sk_req = request;
bc6e5f6933b8e7b John Johansen 2025-04-01  743  	if (sk_req) {
bc6e5f6933b8e7b John Johansen 2025-04-01  744  			error = aa_unix_label_sk_perm(subj_cred, label, op,
6456ccbd2ff7281 John Johansen 2025-06-04  745  						      sk_req, sock->sk,
6456ccbd2ff7281 John Johansen 2025-06-04  746  						      is_sk_fs ? &path : NULL);
bc6e5f6933b8e7b John Johansen 2025-04-01  747  	}
c05e705812d179f John Johansen 2022-09-07  748  	if (!peer_sk)
bc6e5f6933b8e7b John Johansen 2025-04-01  749  		goto out;
bc6e5f6933b8e7b John Johansen 2025-04-01  750  
bc6e5f6933b8e7b John Johansen 2025-04-01  751  	peer_addr = aa_sunaddr(unix_sk(peer_sk), &peer_addrlen);
bc6e5f6933b8e7b John Johansen 2025-04-01  752  
bc6e5f6933b8e7b John Johansen 2025-04-01  753  	struct path peer_path;
c05e705812d179f John Johansen 2022-09-07  754  
bc6e5f6933b8e7b John Johansen 2025-04-01  755  	peer_path = unix_sk(peer_sk)->path;
c05e705812d179f John Johansen 2022-09-07  756  	if (!is_sk_fs && is_unix_fs(peer_sk)) {
c05e705812d179f John Johansen 2022-09-07  757  		last_error(error,
c05e705812d179f John Johansen 2022-09-07  758  			   unix_fs_perm(op, request, subj_cred, label,
6456ccbd2ff7281 John Johansen 2025-06-04  759  					is_unix_fs(peer_sk) ? &peer_path : NULL));
c05e705812d179f John Johansen 2022-09-07  760  	} else if (!is_sk_fs) {
c05e705812d179f John Johansen 2022-09-07  761  		struct aa_sk_ctx *pctx = aa_sock(peer_sk);
c05e705812d179f John Johansen 2022-09-07  762  
88fec3526e84123 John Johansen 2025-06-19  763  		rcu_read_lock();
4483efe4f21510b John Johansen 2025-10-22 @764  		plabel = aa_get_newest_label(pctx->label);
88fec3526e84123 John Johansen 2025-06-19  765  		rcu_read_unlock();
bc6e5f6933b8e7b John Johansen 2025-04-01  766  		/* no fs check of aa_unix_peer_perm because conditions above
bc6e5f6933b8e7b John Johansen 2025-04-01  767  		 * ensure they will never be done
bc6e5f6933b8e7b John Johansen 2025-04-01  768  		 */
c05e705812d179f John Johansen 2022-09-07  769  		last_error(error,
bc6e5f6933b8e7b John Johansen 2025-04-01  770  			xcheck(unix_peer_perm(subj_cred, label, op,
bc6e5f6933b8e7b John Johansen 2025-04-01  771  					      MAY_READ | MAY_WRITE, sock->sk,
6456ccbd2ff7281 John Johansen 2025-06-04  772  					      is_sk_fs ? &path : NULL,
bc6e5f6933b8e7b John Johansen 2025-04-01  773  					      peer_addr, peer_addrlen,
6456ccbd2ff7281 John Johansen 2025-06-04  774  					      is_unix_fs(peer_sk) ?
6456ccbd2ff7281 John Johansen 2025-06-04  775  							&peer_path : NULL,
88fec3526e84123 John Johansen 2025-06-19  776  					      plabel),
88fec3526e84123 John Johansen 2025-06-19  777  			       unix_peer_perm(file->f_cred, plabel, op,
bc6e5f6933b8e7b John Johansen 2025-04-01  778  					      MAY_READ | MAY_WRITE, peer_sk,
6456ccbd2ff7281 John Johansen 2025-06-04  779  					      is_unix_fs(peer_sk) ?
6456ccbd2ff7281 John Johansen 2025-06-04  780  							&peer_path : NULL,
6456ccbd2ff7281 John Johansen 2025-06-04  781  					      addr, addrlen,
6456ccbd2ff7281 John Johansen 2025-06-04  782  					      is_sk_fs ? &path : NULL,
6456ccbd2ff7281 John Johansen 2025-06-04  783  					      label)));
88fec3526e84123 John Johansen 2025-06-19  784  		if (!error && !__aa_subj_label_is_cached(plabel, label))
88fec3526e84123 John Johansen 2025-06-19  785  			update_peer_ctx(peer_sk, pctx, label);
c05e705812d179f John Johansen 2022-09-07  786  	}
c05e705812d179f John Johansen 2022-09-07  787  	sock_put(peer_sk);
c05e705812d179f John Johansen 2022-09-07  788  
bc6e5f6933b8e7b John Johansen 2025-04-01  789  out:
bc6e5f6933b8e7b John Johansen 2025-04-01  790  
88fec3526e84123 John Johansen 2025-06-19  791  	/* update peer cache to latest successful perm check */
88fec3526e84123 John Johansen 2025-06-19  792  	if (error == 0)
88fec3526e84123 John Johansen 2025-06-19  793  		update_sk_ctx(sock->sk, label, plabel);
88fec3526e84123 John Johansen 2025-06-19  794  	aa_put_label(plabel);
88fec3526e84123 John Johansen 2025-06-19  795  
c05e705812d179f John Johansen 2022-09-07  796  	return error;
c05e705812d179f John Johansen 2022-09-07  797  }
88fec3526e84123 John Johansen 2025-06-19  798  

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

                 reply	other threads:[~2026-12-01  4:57 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=20261201054651.Cbj4629p-lkp@intel.com \
    --to=lkp@intel.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.