From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8375EC433DF for ; Mon, 12 Oct 2020 20:39:38 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E866F20BED for ; Mon, 12 Oct 2020 20:39:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E866F20BED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=schaufler-ca.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=linux-audit-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-146-Scur6EaMOLKlQbtFOBdZxw-1; Mon, 12 Oct 2020 16:39:35 -0400 X-MC-Unique: Scur6EaMOLKlQbtFOBdZxw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B1927107AFA5; Mon, 12 Oct 2020 20:39:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9505510013D7; Mon, 12 Oct 2020 20:39:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5F6F558108; Mon, 12 Oct 2020 20:39:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09CKdSrF020570 for ; Mon, 12 Oct 2020 16:39:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id AD1632166BCC; Mon, 12 Oct 2020 20:39:28 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7C4E2166BA4 for ; Mon, 12 Oct 2020 20:39:25 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A88D7805F5F for ; Mon, 12 Oct 2020 20:39:25 +0000 (UTC) Received: from sonic317-38.consmr.mail.ne1.yahoo.com (sonic317-38.consmr.mail.ne1.yahoo.com [66.163.184.49]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-35-C8g078xrO_SX2GJFAeTV4g-1; Mon, 12 Oct 2020 16:39:23 -0400 X-MC-Unique: C8g078xrO_SX2GJFAeTV4g-1 X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1602535162; bh=0PJ9AFdRMre7GhsH6aN6X2O33I0af5NZeHHH832pqBG=; h=From:To:Subject:Date; b=ttPtl3egXdr6E+0C63JwairKF5OViS7LMqJDvQrAEDO/YSOddiUuox31DY7y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HHvcRAPioDVYD_X_e3gny0WKulZwza.ROKgqValWg_B2 MXFlZCAtBchGXaq4Y7lfXirwBJOhWRvd_RFv6CHDUBUkjJVVbSfaW9sgc5gQu5t_7ZeHIlqHZ_1s HNpFsT0ACBYnM_LbCydzxzrJvi7DAloA4Gq9Y22oTpnM3B0pEgLrzygXTxIJNdLiRMA0eysAk5rP 3D8np2nxs7VdirWtsUbz5soPQfGiCEWLiOXr5pDjOo_kRmlk_8qRDwsTqFsj0GDpgqroJBAKloXb wEHC2vHENgeri4JqIB5Aip6hsv6Md6qznoyXml_5rb4kLX3pjcA._jjrIQOpK7v27Scqpk.WMDLm KrPbTbz.88SMG_x3HR0CQv.G_aT61tELabp0eFUHlzA9p4i0ASjv3CHD7YI8H9B9IpKVwgwF2Nr4 zwDO0CUiCVsze1FEC9CRXuxXEoZRVJ3WgGz60whGJlOXxLlmmYNcqjMTzlibKqA8BLkccOIUDn.f 4v7YDiM4bYl2XDaRhHLcDXyiw5zLjgNBQyaF2DzmwpPmD2q8CAMqAlVBjc3goYtkxhxlSbW6I2eQ dltgzzBQGy9ltE0_PANiU2qH9KHhTTc.IzfTeTyZAqgojLgsWG2zBJGrR9Ad1swC2rq6jV2CYhs4 094ZchHCLcBajCyCkezt3z3jnFzHgW2wIvJktM2_0Q6QWIA2rDMsBZCEaCEj2gZgo5Vq5Jr3DUlJ yMHWN31pQFuEePRC0b1BazqxQ_jSaDUIDNWSNXTao2u6yR5nV6faIfi3seJPMbi8K6xE4cfHnuDF fCJAgY8IE1Z5U_P05qX70.iOo_LcnvcQnUq4AwB5AYSQ9aOFoHR70gA-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.ne1.yahoo.com with HTTP; Mon, 12 Oct 2020 20:39:22 +0000 Received: by smtp409.mail.gq1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 9dd356bd13123518a23f9b8c99e8481d; Mon, 12 Oct 2020 20:39:17 +0000 (UTC) From: Casey Schaufler To: casey.schaufler@intel.com, jmorris@namei.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Subject: [PATCH v21 18/23] LSM: Verify LSM display sanity in binder Date: Mon, 12 Oct 2020 13:19:19 -0700 Message-Id: <20201012201924.71463-19-casey@schaufler-ca.com> In-Reply-To: <20201012201924.71463-1-casey@schaufler-ca.com> References: <20201012201924.71463-1-casey@schaufler-ca.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: linux-audit@redhat.com Cc: john.johansen@canonical.com, linux-audit@redhat.com, sds@tycho.nsa.gov X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=linux-audit-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Verify that the tasks on the ends of a binder transaction use the same "display" security module. This prevents confusion of security "contexts". Reviewed-by: Kees Cook Reviewed-by: John Johansen Acked-by: Stephen Smalley Acked-by: Paul Moore Signed-off-by: Casey Schaufler --- security/security.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/security/security.c b/security/security.c index 022af5ae8525..d8a813ba076c 100644 --- a/security/security.c +++ b/security/security.c @@ -790,9 +790,38 @@ int security_binder_set_context_mgr(struct task_struct *mgr) return call_int_hook(binder_set_context_mgr, 0, mgr); } +/** + * security_binder_transaction - Binder driver transaction check + * @from: source of the transaction + * @to: destination of the transaction + * + * Verify that the tasks have the same LSM "display", then + * call the security module hooks. + * + * Returns -EINVAL if the displays don't match, or the + * result of the security module checks. + */ int security_binder_transaction(struct task_struct *from, struct task_struct *to) { + int from_display = lsm_task_display(from); + int to_display = lsm_task_display(to); + + /* + * If the display is LSMBLOB_INVALID the first module that has + * an entry is used. This will be in the 0 slot. + * + * This is currently only required if the server has requested + * peer contexts, but it would be unwieldly to have too much of + * the binder driver detail here. + */ + if (from_display == LSMBLOB_INVALID) + from_display = 0; + if (to_display == LSMBLOB_INVALID) + to_display = 0; + if (from_display != to_display) + return -EINVAL; + return call_int_hook(binder_transaction, 0, from, to); } -- 2.24.1 -- Linux-audit mailing list Linux-audit@redhat.com https://www.redhat.com/mailman/listinfo/linux-audit