<feed xmlns='http://www.w3.org/2005/Atom'>
<title>wireguard-linux/security/apparmor, branch stable</title>
<subtitle>WireGuard for the Linux kernel</subtitle>
<id>https://git.zx2c4.com/wireguard-linux/atom/security/apparmor?h=stable</id>
<link rel='self' href='https://git.zx2c4.com/wireguard-linux/atom/security/apparmor?h=stable'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/'/>
<updated>2026-10-31T04:50:13Z</updated>
<entry>
<title>Merge tag 'apparmor-pr-2026-10-29' of git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor</title>
<updated>2026-10-31T04:50:13Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2026-10-31T04:50:13Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=60aba79a50127e92d8c4a663d35b855e52a9da01'/>
<id>urn:sha1:60aba79a50127e92d8c4a663d35b855e52a9da01</id>
<content type='text'>
Pull AppArmor fixes from John Johansen:
 "Leaks:
   - fix a leak on a rejected string table entry
   - fix refcount leak in aa_get_newest_profile()
   - fix profile leak when a policy load fails
   - remove fs entries created by a failed policy load
   - on failed load ensure profile files are removed before parent
   - Fix namespace reference leak in __aa_find_or_create_ns()

  Use after free/double free:
   - fix a use-after-free in aa_lookupn_ns()
   - avoid potential double free when remapping DFA tables

  Bounds checking by-passes:
   - fix table_size() integer overflow on 32 bit
   - check accept index + 1 is in bounds

  Mediation fixes:
   - Fix AF_UNSPEC mediation
      - check address length before reading AF_UNSPEC bind address
      - mediate AF_UNSPEC socket disconnects
   - Fix sctp connect/bind by-passess
      - advertise that sctp is being mediated
      - fix check SCTP bind, and connect permission checks
      - check connect permission for SCTP
   - incorrect state machine traversal
      -  convert duplicated dfa transitions to match_char()
   - locking issues
      - don't revalidate inherited files under files-&gt;file_lock
      - fix uninitialized variable warning in aa_inherit_files
   - Bad dereferences
      - fix NULL ctx-&gt;peer derefs in unix socket ctx updates

  Unnecessary warnings:
   - remove unconfined_profile() check in inet socket mediation

  Kernel Doc:
   - Fix the return value in split_token_from_name() kernel-doc

  Misc:
   - fix query_data() output overlapping the lookup key
   - report a label allocation failure as -ENOMEM"

* tag 'apparmor-pr-2026-10-29' of git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor: (23 commits)
  apparmor: fix uninitialized variable warning in aa_inherit_files
  apparmor: fix profile leak when a policy load fails
  apparmor: on failed load ensure profile files are removed before parent
  apparmor: remove fs entries created by a failed policy load
  apparmor: fix query_data() output overlapping the lookup key
  apparmor: advertise that sctp is being mediated
  apparmor: fix check SCTP bind, and connect permission checks
  apparmor: check connect permission for SCTP
  apparmor: fix a use-after-free in aa_lookupn_ns()
  apparmor: Fix namespace reference leak in __aa_find_or_create_ns()
  apparmor: check accept index + 1 is in bounds
  apparmor: Fix the return value in split_token_from_name() kernel-doc
  apparmor: convert duplicated dfa transitions to match_char()
  apparmor: fix table_size() integer overflow on 32 bit
  apparmor: avoid potential double free when remapping DFA tables
  apparmor: report a label allocation failure as -ENOMEM
  apparmor: fix a leak on a rejected string table entry
  apparmor: remove unconfined_profile() check in inet socket mediation
  apparmor: fix refcount leak in aa_get_newest_profile()
  apparmor: check address length before reading AF_UNSPEC bind address
  ...
</content>
</entry>
<entry>
<title>apparmor: fix uninitialized variable warning in aa_inherit_files</title>
<updated>2026-10-30T00:02:50Z</updated>
<author>
<name>John Johansen</name>
<email>john.johansen@canonical.com</email>
</author>
<published>2026-10-29T23:53:12Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=ed35bbe7d06e6505401eff3f3c7a36bd1f167a17'/>
<id>urn:sha1:ed35bbe7d06e6505401eff3f3c7a36bd1f167a17</id>
<content type='text'>
Fix the following warning

All warnings (new ones prefixed by &gt;&gt;):

&gt;&gt; security/apparmor/file.c:737:53: warning: variable 'file' is uninitialized when used here [-Wuninitialized]
     737 |                 int error = aa_file_perm(OP_INHERIT, cred, label, file,
         |                                                                   ^~~~
   security/apparmor/file.c:724:36: note: initialize the variable 'file' to silence this warning
     724 |         struct file *devnull = NULL, *file;
         |                                           ^
         |                                            = NULL
   1 warning generated.

vim +/file +737 security/apparmor/file.c

   719
   720	/* based on selinux's flush_unauthorized_files */
   721	void aa_inherit_files(const struct cred *cred, struct files_struct *files)
   722	{
   723		struct aa_label *label = aa_get_newest_cred_label(cred);
   724		struct file *devnull = NULL, *file;
   725		bool devnull_tried = false;
   726		unsigned int n = 0;
   727
   728		revalidate_tty(cred, label);
   729
   730		/*
   731		 * Revalidate access to inherited open files. Each file is
   732		 * revalidated holding only a reference to it, with no locks
   733		 * held, as revalidation may sleep (e.g. unix socket mediation
   734		 * dropping path refs, or allocating path buffers).
   735		 */
   736		while ((n = iterate_fd(files, n, get_next_file, &amp;file)) != 0) {
 &gt; 737			int error = aa_file_perm(OP_INHERIT, cred, label, file,

Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Closes: https://lore.kernel.org/oe-kbuild-all/202610292346.ehqNujiE-lkp@intel.com/
Fixes: a913281f60015 ("apparmor: don't revalidate inherited files under files-&gt;file_lock")
Signed-off-by: John Johansen &lt;john.johansen@canonical.com&gt;
</content>
</entry>
<entry>
<title>apparmor: fix profile leak when a policy load fails</title>
<updated>2026-10-29T17:44:18Z</updated>
<author>
<name>Georgia Garcia</name>
<email>georgia.garcia@canonical.com</email>
</author>
<published>2026-10-14T22:08:21Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=ce94927fa4173fcc1eca27bdc65a140064c8f1e6'/>
<id>urn:sha1:ce94927fa4173fcc1eca27bdc65a140064c8f1e6</id>
<content type='text'>
The error paths of aa_replace_profiles() and aa_unpack() do not break
the refcount cycle between label and proxy. They just aa_put_profile()
the new profiles, which drops the label refcount from 2 to 1, and the
proxy keeps the profile alive. Every failed atomic policy load
(e.g. "profile can not be replaced", or a later profile in the blob
failing to unpack) leaks every new profile in the set, along with its
proxy, rules and its loaddata reference.

The leak is usually not visible from userspace, because the raw_data
directory for a failed load is not created, but it becomes visible
when the blob is deduplicated onto an existing loaddata, which then
keeps its policy/raw_data/&lt;rev&gt; directory forever.

Add aa_put_unpublished_profile(), which drops the profile's own proxy
before putting the profile, and use it on those error paths. The
proxy of an unpacked profile is always freshly allocated and not
referenced by anything else before the profile is published, so
putting it is safe.

Fixes: 637f688dc3dc ("apparmor: switch from profiles to using labels on contexts")
Cc: stable@vger.kernel.org
Signed-off-by: Georgia Garcia &lt;georgia.garcia@canonical.com&gt;
Signed-off-by: John Johansen &lt;john.johansen@canonical.com&gt;
</content>
</entry>
<entry>
<title>apparmor: on failed load ensure profile files are removed before parent</title>
<updated>2026-10-29T17:40:00Z</updated>
<author>
<name>John Johansen</name>
<email>john.johansen@canonical.com</email>
</author>
<published>2026-10-29T15:13:55Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=97ba44a2aa4c7ab011a93ce94cb595200fe4ea4f'/>
<id>urn:sha1:97ba44a2aa4c7ab011a93ce94cb595200fe4ea4f</id>
<content type='text'>
The load interface does not guarantee the order profiles are loaded.
When a parent is loaded after its child, and the load fails, the
current code will issue a warning, and leak a dentry.

For the loaded set of profiles, ensure that on failure list is ordered
is traversed in reverse so any children processed after their parent
is freed first. We do not need to deal with the cases where the
children are processed before their parent, because either a parent
outside the list already exists or a dummy parent outside of the list
is created, and the list walk will not put those parents before their
children.

Fixes: 6ec46f8f1977d ("apparmor: remove fs entries created by a failed policy load")
Signed-off-by: John Johansen &lt;john.johansen@canonical.com&gt;
</content>
</entry>
<entry>
<title>apparmor: remove fs entries created by a failed policy load</title>
<updated>2026-10-29T16:25:25Z</updated>
<author>
<name>Georgia Garcia</name>
<email>georgia.garcia@canonical.com</email>
</author>
<published>2026-10-14T22:08:20Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=6ec46f8f1977d218bf2494ce276152b2d01424af'/>
<id>urn:sha1:6ec46f8f1977d218bf2494ce276152b2d01424af</id>
<content type='text'>
aa_replace_profiles() creates the raw_data/&lt;rev&gt; directory for the
loaddata and the profile directories for new profiles before the last
checks that can fail. When one of those checks fails, the fail path
releases the ns lock without removing what this load created.

The raw_data directory is named after the current ns revision, and the
revision is only bumped by a successful load. The stale directory is
only removed once the loaddata's last profile reference is dropped, from
a workqueue. Until then, every load fails to create raw_data/&lt;rev&gt; with
-EEXIST. If the new profiles are never freed, which is the case when
their dents are left behind pinning the proxy, that never happens and no
policy can be loaded until reboot.

While still holding the ns lock in the fail path, remove the profile
directories of the new profiles and, if this load created it, the
raw_data directory.

Fixes: 5d5182cae401 ("apparmor: move to per loaddata files, instead of replicating in profiles")
Cc: stable@vger.kernel.org
Signed-off-by: Georgia Garcia &lt;georgia.garcia@canonical.com&gt;
Signed-off-by: John Johansen &lt;john.johansen@canonical.com&gt;
</content>
</entry>
<entry>
<title>apparmor: fix query_data() output overlapping the lookup key</title>
<updated>2026-10-29T16:25:25Z</updated>
<author>
<name>Cen Zhang (Microsoft)</name>
<email>cenzhang@linux.microsoft.com</email>
</author>
<published>2026-10-12T21:57:03Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=d30844001360a403a511cf24fc75ecaa6a7a7544'/>
<id>urn:sha1:d30844001360a403a511cf24fc75ecaa6a7a7544</id>
<content type='text'>
In query_data(), buf and query point into the same multi_transaction
buffer: buf at the start, query a few bytes in, and the lookup key
right after the label string that query points to. Reusing the buffer
is by design and is safe as long as the query is fully parsed before
buf is written to, but the key is not: it is dereferenced on every
iteration of label_for_each_confined(), after output has already been
written. So when the label has more than one profile with a data
table, the data of the first matching profile is written to buf while
the key is still needed, and overwrites it if the data is large enough.
The later lookups then run on a corrupted key. Besides, if the data has
no NUL byte from the key's position to the end of the allocation,
strhash() -&gt; strlen() -&gt; jhash() reads past the 4096-byte slab object,
triggering an out-of-bound read:

  BUG: KASAN: slab-out-of-bounds in jhash+0x595/0x5e0
  Read of size 1 at addr ff1100001159d000 by task exploit/155
  CPU: 0 UID: 1000 PID: 155 Comm: exploit Not tainted 7.3.0-rc7 #1
  Call Trace:
   jhash+0x595/0x5e0
   aa_write_access+0x880/0x1400
   vfs_write+0x26f/0xd20
   ksys_write+0x115/0x210

Writing to the .access file is unprivileged (0666), but triggering this
requires loaded profiles that carry a data table, which needs
CAP_MAC_ADMIN and is not the case on default distribution policies.

Fix by copying the key with kstrdup() before writing any output to buf,
so the key stays valid across all loop iterations regardless of what
gets written to the overlapping buffer.

Fixes: 317d9a054e1c ("apparmor: update query interface to support label queries")
Cc: stable@vger.kernel.org # v4.13+
Cc: Francis Perron &lt;francis@akrites.dev&gt;
Reported-by: AutonomousCodeSecurity@microsoft.com
Signed-off-by: Cen Zhang (Microsoft) &lt;cenzhang@linux.microsoft.com&gt;
Signed-off-by: John Johansen &lt;john.johansen@canonical.com&gt;
</content>
</entry>
<entry>
<title>apparmor: advertise that sctp is being mediated</title>
<updated>2026-10-29T16:24:51Z</updated>
<author>
<name>John Johansen</name>
<email>john.johansen@canonical.com</email>
</author>
<published>2026-09-30T15:49:43Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=35b8ab3f36ac0fcd8fc910da0bed889b6c75c426'/>
<id>urn:sha1:35b8ab3f36ac0fcd8fc910da0bed889b6c75c426</id>
<content type='text'>
Enable the test harness to detect that the kernel should be properly
mediating sctp.

Fixes: 7a82f9a06459f ("apparmor: fix check SCTP bind, and connect permission checks")
Signed-off-by: John Johansen &lt;john.johansen@canonical.com&gt;
</content>
</entry>
<entry>
<title>apparmor: fix check SCTP bind, and connect permission checks</title>
<updated>2026-10-29T16:03:55Z</updated>
<author>
<name>John Johansen</name>
<email>john.johansen@canonical.com</email>
</author>
<published>2026-10-29T16:03:55Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=7a82f9a06459ff1c37b5e97b204430442cc076e3'/>
<id>urn:sha1:7a82f9a06459ff1c37b5e97b204430442cc076e3</id>
<content type='text'>
SCTP mediation of bind is not being checked correctly because bind
permission needs to be checked in the sctp_bind_connect() hook.

Require for bind permissions when CTP_SET_PEER_PRIMARY_ADDR, and
SCTP_SOCKOPT_BINDX_ADD are asked for.

The peer initialized ASCONF cases (SCTP_PARAM_ADD_IP and
SCTP_PARAM_SET_PRIMARY) are processed in softirq context and are not
mediated atm. SCTP_PRIMATEY_ADDR, and SCTP_SET_PEER_PRIMARY_ADDR only
select among address already in the association.

Fixes: 56974a6fcfef ("apparmor: add base infastructure for socket mediation")
Signed-off-by: John Johansen &lt;john.johansen@canonical.com&gt;
</content>
</entry>
<entry>
<title>apparmor: check connect permission for SCTP</title>
<updated>2026-10-29T15:30:53Z</updated>
<author>
<name>Jérémy Jean</name>
<email>Jeremy.Jean@oss.cyber.gouv.fr</email>
</author>
<published>2026-09-25T20:54:48Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=2f764c08bb191a8c8f4051926dba0d25d195f39b'/>
<id>urn:sha1:2f764c08bb191a8c8f4051926dba0d25d195f39b</id>
<content type='text'>
SCTP can start an association through sendmsg() or CONNECTX. These paths
call the SCTP-specific sctp_bind_connect hook instead of the normal socket
connect hook, but AppArmor does not register it. As a result, a profile can
deny connect and allow send or setopt, yet a task can still create an SCTP
association.

Register the SCTP hook. Ask for connect permission when SENDMSG_CONNECT
or CONNECTX creates an association.

Fixes: 56974a6fcfef ("apparmor: add base infastructure for socket mediation")
Assisted-by: LLM
Signed-off-by: Jérémy Jean &lt;Jeremy.Jean@oss.cyber.gouv.fr&gt;
Signed-off-by: John Johansen &lt;john.johansen@canonical.com&gt;
</content>
</entry>
<entry>
<title>apparmor: fix a use-after-free in aa_lookupn_ns()</title>
<updated>2026-10-29T15:30:53Z</updated>
<author>
<name>Binbin Deng</name>
<email>18983559317@163.com</email>
</author>
<published>2026-09-23T05:46:23Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=f292873ceb4bd3a1a0f75f884361cd556e457692'/>
<id>urn:sha1:f292873ceb4bd3a1a0f75f884361cd556e457692</id>
<content type='text'>
aa_lookupn_ns() takes a reference on the namespace it finds with
aa_get_ns(), which is kref_get() on the reference count that the
namespace is released through, without checking whether the namespace
is still in use.  A concurrent removal of a ":"-prefixed namespace
looks the same namespace up and only then takes the parent lock to
remove it, so the last reference can be dropped between the lookup and
the aa_get_ns() call: the reference count then reports the increment on
a zero count and the kernel classifies the following use of the object
as a use-after-free.  A user with CAP_MAC_ADMIN can trigger this by
writing a ":&lt;name&gt;" removal and a ":&lt;name&gt;/&lt;profile&gt;" removal to
/sys/kernel/security/apparmor/.remove concurrently.

refcount_t: addition on 0; use-after-free.
WARNING: lib/refcount.c:25 at refcount_warn_saturate+0xc0/0xe0, CPU#6
Call Trace:
 &lt;TASK&gt;
 aa_lookupn_ns+0xa9/0xc0
 aa_remove_profiles+0x4fb/0x730
 ? __kvmalloc_node_noprof+0x219/0x5c0
 ? __pfx_aa_remove_profiles+0x10/0x10
 ? aa_loaddata_alloc+0x65/0x1f0
 ? _copy_from_user+0x2d/0x80
 ? aa_loaddata_alloc+0x111/0x1f0
 profile_remove+0x2ee/0x4a0
 vfs_write+0x21e/0xcf0
 ? rcu_core+0x29c/0x1740
 ? timerqueue_linked_add+0x1f4/0x3d0
 ? __pfx_vfs_write+0x10/0x10
 ? mutex_lock+0x81/0xe0
 ? __pfx_mutex_lock+0x10/0x10
 ? __pfx_rcu_core+0x10/0x10
 ? __pfx_hrtimer_update_next_event+0x10/0x10
 ? mutex_unlock+0x7b/0xd0
 ? fdget_pos+0x24d/0x4b0
 ksys_write+0xf7/0x1c0
 ? __pfx_ksys_write+0x10/0x10
 ? restore_fpregs_from_fpstate+0x37/0xc0
 do_syscall_64+0xf9/0x540
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
 &lt;/TASK&gt;

Fix by rejecting a namespace whose reference count is zero.

Fixes: 3664268f19ea0 ("apparmor: add namespace lookup fns()")
Cc: stable@vger.kernel.org
Signed-off-by: Binbin Deng &lt;18983559317@163.com&gt;
Signed-off-by: John Johansen &lt;john.johansen@canonical.com&gt;
</content>
</entry>
</feed>
