Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 250E023D28B for ; Fri, 31 Oct 2025 15:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761925256; cv=none; b=DSts5Iw6eNNZEhSt1X2ZU40chZ4RBs/Es0JKG7hud32GCQj8isbhYzxlOmwDSXlC++fL/Z06J6AOmDNvcNd9PP+Vot21bGYlB//qxfmw9K+8zRq9e29pNs2Sgq+ikPSW4M8oxXZTmqB206l0KdZEFOjE4gpIntDu8H03eh4/NpY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761925256; c=relaxed/simple; bh=rctMRcL1iZRdy7Xjz2/Qu3TGhTfiomU0B+iIv+NP5Q4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Ul79ahE7io56RTYb6hlk2ixnYMHxn5LT8XyqyqQctgtb7/zjac1pDasw6S9AfHfSx9rrcHiKt6TglbflFQ65JlpBzCBpUUpbnN5R+1R04JOIKgFWAuhaTcwzxjeWubYcj/Q9H9mdri8ohgzcemMeIumkyq8D9toUZ03NK4YD1Xw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ieee.org; spf=pass smtp.mailfrom=ieee.org; dkim=pass (1024-bit key) header.d=ieee.org header.i=@ieee.org header.b=X+jcJb2o; arc=none smtp.client-ip=209.85.160.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ieee.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ieee.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ieee.org header.i=@ieee.org header.b="X+jcJb2o" Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-4ecf03363c9so18443491cf.1 for ; Fri, 31 Oct 2025 08:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ieee.org; s=google; t=1761925252; x=1762530052; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=sv+W6Xemk2mIzDg2vtTBh79kVlVXiN2u25/+YSPwY04=; b=X+jcJb2ouRCLhdMo2nk4nBbGutEhPict1cpT1ajVNtsjsPpq1HdN6idG3dT6WnveuT d7mulkyMR9r8msUs3/X2ncM7mlmjmYrVkXgGViGL7XscL42WWGlN9AdQGSUaBfew2ZJQ uaJVkGIXqKFSWY88XvbROFkffxxIhfRfR2tnI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761925252; x=1762530052; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sv+W6Xemk2mIzDg2vtTBh79kVlVXiN2u25/+YSPwY04=; b=nxnl2NW4/6qy7wa7AbInuDS+i3Uo4G8nA+yqHKxKbPNZTi+KOCAcQa+asDK0PGXMI7 W88C7NyNpXroTXNmWfqecC+fFgX0n/8PA3v+igtoCqaNVDio3WNUNG9aI8H4SaVWeUN4 kz1kl18OgPiSG0eR1gIReSuOIZRkSq8lO+nEuYzR5lw68YFS+TdZ2cWfXk/6ut5V4oj1 X5B95MIjQFvr7mG/mIo20RXOAC85yE6vBXmWD5Qopcum2uaEtSufb17U4eTcGZaKApUC LzuSTMFdo9YIZ7WLLz+64f8W6pCKC7/+QQt1LhdilLgHR4FCER/yaBBzymycS8frWYPM Tmkg== X-Forwarded-Encrypted: i=1; AJvYcCW4eoBul+GSKDt78KOChWzF05WChh2PeZQcMZfADEIlR0Kdkv8Ul9a/mkHtF0frdNnFVRtXRm7ZYC9zqJ5SbxsxhA==@vger.kernel.org X-Gm-Message-State: AOJu0YwnshI+OaFcQDN3pemL8+1M3RR5z3ExSGdfusZZ48Mv/c0P4UXU 4PVl0UR8FS2DixUJ4anx1ktTtKk7b3RF+TST/sfUmqdwVmB/J7WdigDO+8pCLOkATrWj0K8oiPn ic9KzzA== X-Gm-Gg: ASbGncuHX5EHVukFa4Nk72WyWYJg7NcP8rNPasYNRdgHXcn9no8lfmXQOwr7+BGDX8G Dea/SEt6mVooD/15rITlDtT2i6/W5ZD9J81ytDz0qAm+kWqEyr3f5/DG0wz80H+q1kLf5kE6iGK 2lsnnAiMaUayPgQY22kGMejhJaI/oqkkrpDTwrrlhSWzCi8C4ri95RZPFvDu/kwoXncr1kyiUxS rQWLM4mdpKd3fh4d3DGNH47d41peSPW6ukGhKZjbMzWb8744WkBObryIK40Z+YyPppoR65hvaUC 2slbYD0c4nTq5KjhRMPJiTHFvpcprNBGfkvUK09nN0z2voypWqc4gyAAIvOFe/A8EKlPzeXLLOu 4hX/NIkZQH0tu79vHhC+gWv24TNlB9bEvPz4Udq3c+j0Lp6F/QPHLY1hermFIJ08wnaCACV0Q4O 2sjrYiZ8Hd1sAXr+F5BTax34oZeoFycNmSUE44gLMlH2opNLghroMwVIpG3Bot X-Google-Smtp-Source: AGHT+IGB3xPe3zQtTJ5oO1+Wm0Ceo9ICrP2ibIiJlByTHszB3bJ6ctUkSmpZ7nqV7yCH9Ilo8NZ4jg== X-Received: by 2002:a05:622a:1a9b:b0:4e7:2dac:95b7 with SMTP id d75a77b69052e-4ed30f2a150mr44661401cf.37.1761925251862; Fri, 31 Oct 2025 08:40:51 -0700 (PDT) Received: from ?IPV6:2601:145:c282:5650:db86:5c8a:31ca:2959? ([2601:145:c282:5650:db86:5c8a:31ca:2959]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4ed35285faasm12486141cf.19.2025.10.31.08.40.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 31 Oct 2025 08:40:51 -0700 (PDT) Message-ID: <9e69696a-cbee-4bc5-8679-5e5407490c3d@ieee.org> Date: Fri, 31 Oct 2025 11:40:48 -0400 Precedence: bulk X-Mailing-List: selinux-refpolicy@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH refpolicy] kernel: remove some unused initial SID contexts To: Stephen Smalley , selinux-refpolicy@vger.kernel.org Cc: paul@paul-moore.com, omosnace@redhat.com References: <20251030200720.18719-2-stephen.smalley.work@gmail.com> Content-Language: en-US From: Chris PeBenito In-Reply-To: <20251030200720.18719-2-stephen.smalley.work@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 10/30/2025 4:07 PM, Stephen Smalley wrote: > Remove some unused initial SID contexts that can be safely removed > without compatibility issues. This does not remove any initial SID > declarations, only the corresponding initial SID context assignment. > > Linux kernel commit e3e0b582c321ae ("selinux: remove unused initial > SIDs and improve handling"), merged in Linux v5.7, removed unused > initial SIDs from the kernel and improved the handling to support > safely reclaiming and reusing of many of the initial SIDs without > compatibility issues as well as enabling future addition of new > initial SIDs. > > SELinux userspace commit 8677ce5e8f5929 ("libsepol,checkpolicy: > support omitting unused initial sid contexts"), merged in userspace > release 3.1 (20200710), supported omitting unused initial SID contexts > from the kernel binary policy. Previously this was treated as an error > at policy compilation/linking time. > > Since refpolicy already specifies a minimum SELinux userspace of 3.2, > we can finally remove the unused initial SID contexts from the > refpolicy kernel module. This does not depend on the kernel commit; it > will work with kernels before and after that commit. > > This change retains the initial SID contexts for the init SID and the > any_socket SID. Kernel use of the init SID was restored by Linux > kernel commit ae254858ce0745 ("selinux: introduce an initial SID for > early boot processes") although this is transparently remapped to the > kernel SID context unless the "userspace_initial_context" policy > capability is enabled. Since this policy capability is not currently > enabled by default in refpolicy, we leave the init SID with the > unlabeled context for now but it should be assigned some other context > if this policy capability is ever enabled. Kernel use of the > any_socket SID was reintroduced by Linux kernel commit d28d1e080132f28 > ("[LSM-IPSec]: Per-packet access control.") to provide a default > socket label for use in checks when no socket is available. > > This change also retains the initial SID contexts for the fs and > sysctl initial SIDs for backward compatibility until such a time as > refpolicy increases its minimum supported kernel version to one that > includes the aforementioned Linux kernel commit. > > Signed-off-by: Stephen Smalley > --- > policy/modules/kernel/kernel.te | 19 ++++--------------- > 1 file changed, 4 insertions(+), 15 deletions(-) > > diff --git a/policy/modules/kernel/kernel.te b/policy/modules/kernel/kernel.te > index 26578a26d..6e7302bf5 100644 > --- a/policy/modules/kernel/kernel.te > +++ b/policy/modules/kernel/kernel.te > @@ -215,23 +215,12 @@ sid file gen_context(system_u:object_r:unlabeled_t,s0) > sid unlabeled gen_context(system_u:object_r:unlabeled_t,mls_systemhigh) > neverallow * unlabeled_t:file entrypoint; > > -# These initial sids are no longer used, and can be removed: > +# Default socket label if no kernel sock is available > sid any_socket gen_context(system_u:object_r:unlabeled_t,mls_systemhigh) > -sid file_labels gen_context(system_u:object_r:unlabeled_t,s0) > -sid icmp_socket gen_context(system_u:object_r:unlabeled_t,mls_systemhigh) > -sid igmp_packet gen_context(system_u:object_r:unlabeled_t,mls_systemhigh) > + > +# Label for userspace tasks surviving from early boot if > +# userspace_initial_context policycap is defined. > sid init gen_context(system_u:object_r:unlabeled_t,s0) > -sid kmod gen_context(system_u:object_r:unlabeled_t,mls_systemhigh) > -sid policy gen_context(system_u:object_r:unlabeled_t,mls_systemhigh) > -sid scmp_packet gen_context(system_u:object_r:unlabeled_t,mls_systemhigh) > -sid sysctl_modprobe gen_context(system_u:object_r:unlabeled_t,s0) > -sid sysctl_fs gen_context(system_u:object_r:unlabeled_t,s0) > -sid sysctl_kernel gen_context(system_u:object_r:unlabeled_t,s0) > -sid sysctl_net gen_context(system_u:object_r:unlabeled_t,s0) > -sid sysctl_net_unix gen_context(system_u:object_r:unlabeled_t,s0) > -sid sysctl_vm gen_context(system_u:object_r:unlabeled_t,s0) > -sid sysctl_dev gen_context(system_u:object_r:unlabeled_t,s0) > -sid tcp_socket gen_context(system_u:object_r:unlabeled_t,mls_systemhigh) Merged. -- Chris PeBenito