Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754508Ab0LHMuW (ORCPT ); Wed, 8 Dec 2010 07:50:22 -0500 Received: from out3.smtp.messagingengine.com ([66.111.4.27]:32939 "EHLO out3.smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752521Ab0LHMuU (ORCPT ); Wed, 8 Dec 2010 07:50:20 -0500 X-Sasl-enc: ILJS6nB/8eVYbiVP2vxxmaeXlWzKijU4LgReKUFhCyRD 1291812619 To: Stephen Smalley Subject: [RFC][PATCH 1/2] selinux: call may_context_mount_inode_relabel() if fscontext_sid is defined From: Roberto Sassu Organization: Politecnico di Torino Date: Wed, 8 Dec 2010 13:45:42 +0100 Cc: James Morris , Eric Paris , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, selinux@tycho.nsa.gov MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart5650041.haMKPnGbek"; protocol="application/pkcs7-signature"; micalg=sha1 Content-Transfer-Encoding: 7bit Message-Id: <201012081345.51190.roberto.sassu@polito.it> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8772 Lines: 147 --nextPart5650041.haMKPnGbek Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable One purpose of the function may_context_mount_inode_relabel() is to check if the 'associate' permission can be granted to security contexts set in some SELinux defined mount parameters that affect the inode labeling behavior. =46or instance, the 'context' mount parameter allows to label all inodes wi= th the specified security context, the 'defcontext' mount parameter permits to assign a label to inodes, in a filesystem with the 'SECURITY_FS_USE_XATTR' labeling behavior, that do not have the getxattr() method defined or lack the SELinux's specific extended attribute. The 'fscontext' parameter also is involved in the inode labeling process, specifically in case the labeling behavior is 'SECURITY_FS_USE_TRANS' and the security_transition_sid() function returns an error or in the 'default' case for all filesystems except 'proc'. This patch adds the missing call of the may_context_mount_inode_relabel() function for the security context specified with the mount parameter 'fscontext' and it should not break any existent functionality because the required permission is already granted in the SELinux reference policy by the following rule in the file 'policy/modules/kernel/filesystem.te': allow filesystem_type self:filesystem associate; Signed-off-by: Roberto Sassu =2D-- security/selinux/hooks.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 65fa8bf..9486f38 100644 =2D-- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -682,6 +682,11 @@ static int selinux_set_mnt_opts(struct super_block *sb, if (rc) goto out; =20 + rc =3D may_context_mount_inode_relabel(fscontext_sid, sbsec, + cred); + if (rc) + goto out; + sbsec->sid =3D fscontext_sid; } =20 =2D-=20 1.7.3.2 --nextPart5650041.haMKPnGbek Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIQCTCCBLMw ggOboAMCAQICARQwDQYJKoZIhvcNAQEFBQAwQTEQMA4GA1UEChMHRXVyb1BLSTEtMCsGA1UEAxMk RXVyb1BLSSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTAyNDEzMzEzM1oXDTEw MTIzMTEyNTk1OVowUTELMAkGA1UEBhMCSVQxEDAOBgNVBAoTB0V1cm9QS0kxMDAuBgNVBAMTJ0V1 cm9QS0kgSXRhbGlhbiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQAD ggEPADCCAQoCggEBAPbJ3y5bE0iL2iFW59R4KGHS3iTc22mq2GlDaOZLE3Xz1wTvB/yBl5e4ntMZ eEeWTW9JInNRTtfC3mcLk0gnEdK1rQZbe4lQwBVHdkG8LvRQDWHIkZNuccoUpQXMv+JbZjI6m7rH fU2CN/YCvFY9QL08xXsfDxvX2Ee4S7EwJiSEEJSiy+R00uTfvfn27d8a6LCqYLzlInRlz4C2CUbk +U2UAw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iG9w0BAQEFAASCAQBL mtt4y/tznP4Gx+wHSZkFI2jHbJjxap9OOevGdv66g7QqS46VUef7nu3JrLaAuKa+ZBbuojUhnrdO i4clxtBv4B2c03IqyncBd0qqoUnwDMrNNXs3VTi1oqJ11c2pDHHNKkqckmzMhLjpHla5Am1LohIn 7FN9JWqjbjdTVC+zwrwFUOjGQvUweT5QRsX1WolzDWJf5+HvXyh4ohw+KvVRzO44zy7faVJpCflB 9ZwcHEvFjMWIcQOLlRA+E9oFTtwaZz5mV7bBfqmIm9F9s7hulKaO63M+UXoVQDAHP2KJHv6FgPBy CCrNHcPfezxIaN191AP4UfILej3l1LKTsk62AAAAAAAA --nextPart5650041.haMKPnGbek-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/