From nobody Fri Nov 29 17:48:40 2024 Received: from sonic314-27.consmr.mail.ne1.yahoo.com (sonic314-27.consmr.mail.ne1.yahoo.com [66.163.189.153]) (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 B69DD18BC15 for ; Tue, 17 Sep 2024 23:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.163.189.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726617231; cv=none; b=SCUtIGYRiOIHgINisynSmTKOWqJSvnyJAKvYRVjZNkXZGcYkbAk3fO3lL1CowBN3SKzSV8Qoj6h1VQqEoRZJLPIfFdH2BoxO+Ec2iD6V31DbiSipwNI6R7sr22ExEBa04nSpnc882yN75gpQp6QXM0MIBOyY0jH0djqURdX9mMQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726617231; c=relaxed/simple; bh=0ubI3dLuiFvQb7cQkSFUkzrhPW2VRR0XtYlRe5c/A60=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T/RsRXygtAwWP7TQ9pIOcwSHOxkG2UgMyUkMZg8T4jgQWgwmLP2oirSuUai4gv/HAb8n5NoiKLKqHKJ7y1wIqM0b8bc2YYVmGQMqlyqDla7EUethT6ylGBfSGTNQD8usX+AFgo7uyTm9yBlJU7V42pAeShtmpVbA3g5X2aTA9EQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=schaufler-ca.com; spf=none smtp.mailfrom=schaufler-ca.com; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.b=WNu/t09m; arc=none smtp.client-ip=66.163.189.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=schaufler-ca.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=schaufler-ca.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.b="WNu/t09m" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1726617229; bh=j5lakjbtg6bbgJzgWkUYPqrQ2XuCHA+KwbbiISmMicI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=WNu/t09mU2N8i4PkfTkEorYUtEYxQNFyyM2ShL7vIjDgCXAHd9DabnUMLYn7b8YOkY1DodoOzRF113LhMfhbbgw4iHRkK/Ek5wiZMUHH0i5u7rvXXRUyZhQOfL08APHIY4LaDqdHNzLCHIA39ofUAGz/OCTjpMsz9RBxxyYs1XP0r9dhUvS5xPkKEQ2k7yYNwXJafj9ryBCvxHLisnQ8tm5YYw0q3N5yh68yCP04Sy4q6yTjbGg8Ex0NwLpksxgPP28hVUCDOcnDkYiyPTHXkMvcVwEJFwYZLK/PUQi1gJl+9e6o04x7hKZZxk4GsMpQQNlX8WIegXSpwZDPKrOoyQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1726617229; bh=Ep+ZvFh/ISGZYSQyDBEElpQcODGAFa1l29UXn8gjXqq=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=DyhLhibN3kHXKunzSbhQhmdqH6bfH6AAELUjx8HFM47oWAn8KECvLh5j4odUJ9FTAI+1O8xMxS81WBGtxsihLX3YfgCvNNiElxl8a+ffQwoJgHmVA89CL0aP9xiyUxZWNknBDay4JWZBQx9Q/AfqjjbmY1EUfJ8Hn+e78QoRXzuT8HXCSf0IP8Ob3+2QvCSIgIxRj/WH59fJXnJO4HCWCcekAbgU0DF6rrdlhmPjXDmL8d+B7ib3wrqwrZWDvHgTjj0FnDKwqc5t8kwZZC++b1hWuHBfz+Zjl+tZM/juqRMFbecFlfOfXDcF8FY0lc9SBNC4WoJNaPkla2IvG7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Zz5GkkVCS 5mbUDbrosrMaXoztZfCQmHXL1ztj6Z7YFnmPY1ZNRiCzOnWZK9HB1pJUli_jkDuHTeP4lFGHgrbP GdPfU83AmkrTt..I6ww.pA0fpqd0W027HA61gfOOFGi91m_ouvvXqy2NoAy1oVPs7TOrFnXpdl8e s2noqDsEjXTDnhb2_P3OZBCIRoUC9_yUHBaUvB_DeY2hY5tXXgRp4HWXIXK7BHmO6lWpc9ixvUJT tmx3PSYVvod_TdTROdfxAG3OVmfiY5GMBUQ-- X-Sonic-MF: X-Sonic-ID: cf539a59-42e7-4664-afc7-13ba7b38f727 Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ne1.yahoo.com with HTTP; Tue, 17 Sep 2024 23:53:49 +0000 Received: by hermes--production-gq1-5d95dc458-rvnnh (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 41ac41609d6122fff099bda257412a4d; Tue, 17 Sep 2024 23:53:44 +0000 (UTC) From: Casey Schaufler To: casey@schaufler-ca.com, paul@paul-moore.com, linux-security-module@vger.kernel.org Cc: jmorris@namei.org, serge@hallyn.com, keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, stephen.smalley.work@gmail.com, linux-kernel@vger.kernel.org, selinux@vger.kernel.org, mic@digikod.net Subject: [PATCH 4/5] LSM: secctx provider check on release Date: Tue, 17 Sep 2024 16:52:01 -0700 Message-ID: <20240917235202.32578-5-casey@schaufler-ca.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240917235202.32578-1-casey@schaufler-ca.com> References: <20240917235202.32578-1-casey@schaufler-ca.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Verify that the LSM releasing the secctx is the LSM that allocated it. This was not necessary when only one LSM could create a secctx, but once there can be more than one it is. Signed-off-by: Casey Schaufler --- security/apparmor/secid.c | 10 ++-------- security/selinux/hooks.c | 10 ++-------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/security/apparmor/secid.c b/security/apparmor/secid.c index 5d92fc3ab8b4..974f802cbe5a 100644 --- a/security/apparmor/secid.c +++ b/security/apparmor/secid.c @@ -122,14 +122,8 @@ int apparmor_secctx_to_secid(const char *secdata, u32 = seclen, u32 *secid) =20 void apparmor_release_secctx(struct lsm_context *cp) { - /* - * stacking scaffolding: - * When it is possible for more than one LSM to provide a - * release hook, do this check: - * if (cp->id =3D=3D LSM_ID_APPARMOR || cp->id =3D=3D LSM_ID_UNDEF) - */ - - kfree(cp->context); + if (cp->id =3D=3D LSM_ID_APPARMOR) + kfree(cp->context); } =20 /** diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index e56403659164..93188e124f99 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -6649,14 +6649,8 @@ static int selinux_secctx_to_secid(const char *secda= ta, u32 seclen, u32 *secid) =20 static void selinux_release_secctx(struct lsm_context *cp) { - /* - * stacking scaffolding: - * When it is possible for more than one LSM to provide a - * release hook, do this check: - * if (cp->id =3D=3D LSM_ID_SELINUX || cp->id =3D=3D LSM_ID_UNDEF) - */ - - kfree(cp->context); + if (cp->id =3D=3D LSM_ID_SELINUX) + kfree(cp->context); } =20 static void selinux_inode_invalidate_secctx(struct inode *inode) --=20 2.46.0