Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1454148rwb; Tue, 27 Sep 2022 13:22:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM65bKssYHebVNTOPICdDmgBeEumrGw87CZG/Op8T1uv52AJX5Se9rGO+aim+1SLmHsy65fw X-Received: by 2002:a17:90b:3b90:b0:202:8a60:c852 with SMTP id pc16-20020a17090b3b9000b002028a60c852mr6437483pjb.169.1664310121919; Tue, 27 Sep 2022 13:22:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664310121; cv=none; d=google.com; s=arc-20160816; b=Iu5HbRggKZANbMdRnsFCRG6RNkotx5MrOktl4d6zIFqSHPVBsA4yB49/74qDbxWGJb F6pzbbFACVgUTnLc70rZQTs4qVV4z2kNLkTSOY5YMoQMfbrHbbF9rc8V3+fHr/bcivmK YVU0dxn244qwQVF7r6T55rqyfdRI1uX1N90fHhRFI9gIzAz3lNYQFcRwV1YiUT82gOfM lr6inSy1h26+04dnAvSImsY8XmGvVKOGEBMQfQUrm9qfPWZsz1lSM0Ddur9AGSio8Ab7 O+1om1Pj6emls1k5pqstsQdfH29ZKmIKXEfG0flqvnUk/eiBCxrCuUWmrBuUL45978gc /3LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kZmX5D8gvn+IorW7ZBc7wQ4cuZ2xPhtzeLbcbM3NOUA=; b=tRkx4D++XFik+5ZyYghY9vLk3j8Ei9LH0xk2NtoE9AzDY0+uMXYLXl/lVedKJDvMUO Mi4IogcVbNbJUouuXAKjvKctrVAo2xE4y8Ys1WA1ix3cL0j7lwZAcLv/hrIEMvrP4U4v SkK3m3rFOZmpC/5QzdSJmVow0vCbn+4I12xyorFODatFdKdOJECm5N/LTgsGO8B1AzN3 jSwyhB0130+YZ49m5PnHSAUAIpsV2IPIsy8J2DPiGa+Dpa9YRSE1Pig6cZJoqaJhdqpd fc7MLsFeMhhTF0G1kFbV9+8a8qT52ifFPJHC598a8u1fVUexQl1wvcnOnvZXtyXXjB7x zMsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=T7tZKSPF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id np16-20020a17090b4c5000b001fd7ae1ae32si3316550pjb.126.2022.09.27.13.21.50; Tue, 27 Sep 2022 13:22:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=T7tZKSPF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232924AbiI0UKu (ORCPT + 99 others); Tue, 27 Sep 2022 16:10:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232906AbiI0UKU (ORCPT ); Tue, 27 Sep 2022 16:10:20 -0400 Received: from sonic306-27.consmr.mail.ne1.yahoo.com (sonic306-27.consmr.mail.ne1.yahoo.com [66.163.189.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1E931E0C59 for ; Tue, 27 Sep 2022 13:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1664309351; bh=kZmX5D8gvn+IorW7ZBc7wQ4cuZ2xPhtzeLbcbM3NOUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=T7tZKSPF06+f/UG5dasdwtipQs1cmeqXRf5Xr3NXLTcVxpl2vg2k7vQ1r7BR4g81yVVY2VzDd4hPKUAJy3iTk2INCRdbPglo9cBLr9G+iRkdF9ed6b9eLWUEOwcNWGNXhCWn9uFFeRshr8XIGy6Kt0p6sjxjWM9lpdNVMtUEWYSgVp06SweakP9wR/sD7CgnpkJ3dzq7f/ooUz1Ep5xg/GgQU+L0zQ9SZ2kt+BV1TSqDhwjycaW44zl6+MUWbql4ikDr/l1NbZp2FfYDNn3dH9WEI2F1M9tRXQBIU3mQOwK80aGsrSoJe65/rUZO/hlvI4Kzmj7jyVClZlspniJe0A== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1664309351; bh=jyyKoViioSEMtD728aWLJQuwwJ3bHww7hlonDVU+/Kt=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=d3PFDzcSCQcvEt1dWy3FH4RrQ2fRMC5hZhloB81WOQj6bO7leyPm9VfufmkenTk3tmEpBa+WLgiGF1SopexV5qn01PHbq5Q2tkmYwPA+9rZFNiuaO4XbTSetp8zXybEO6UahZ+uyW2vs0ggPdgo7mBlg9AKj0OzdFuYfdJaVkT7iQUqwpqTo7Aax/LIgUX1EUNAM8bedE4TCVjCmFmJPf4u79V07JUKvQF9YBQoIPZbMlpD9/5d4d7YN7fkjxSNqOZ2VUaJHf4rljyBX86Pi6Bx/MxQu3jQ7dAkXYbNLYsono0vb6NtkUWPWA54/6MZtG7hzLOTO6EeU6t3xePycGQ== X-YMail-OSG: fHNfqrYVM1lak68bp2UhuO4XTccAU8de_.KxvxBk40UeIRhLxlEvXHJ5Fgvatyl CDJxrAsRMeDw0KJyk_ttzvugnLHqnjt81oaBzI07yoce8FbI6tc9PrOoqc6hOQHv_w8eFFigwChL fRjjAmzMVkk02T0xP7wN1qQ_EFndEQF8.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htWafI X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.ne1.yahoo.com with HTTP; Tue, 27 Sep 2022 20:09:11 +0000 Received: by hermes--production-ne1-6dd4f99767-x2f2n (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 962ba498c220faeab9c55c1f2e7ba390; Tue, 27 Sep 2022 20:09:09 +0000 (UTC) From: Casey Schaufler To: casey.schaufler@intel.com, paul@paul-moore.com, linux-security-module@vger.kernel.org Cc: casey@schaufler-ca.com, linux-audit@redhat.com, jmorris@namei.org, selinux@vger.kernel.org, keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, stephen.smalley.work@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH v38 27/39] binder: Pass LSM identifier for confirmation Date: Tue, 27 Sep 2022 12:54:09 -0700 Message-Id: <20220927195421.14713-28-casey@schaufler-ca.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220927195421.14713-1-casey@schaufler-ca.com> References: <20220927195421.14713-1-casey@schaufler-ca.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Send an identifier for the security module interface_lsm along with the security context. This allows the receiver to verify that the receiver and the sender agree on which security module's context is being used. If they don't agree the message is rejected. Signed-off-by: Casey Schaufler --- drivers/android/binder.c | 21 +++++++++++++++++++++ drivers/android/binder_internal.h | 1 + 2 files changed, 22 insertions(+) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 5cfdaec0f9b5..ff8f35b9bd1b 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -3222,6 +3222,7 @@ static void binder_transaction(struct binder_proc *proc, ALIGN(extra_buffers_size, sizeof(void *)) - ALIGN(lsmctx.len, sizeof(u64)); + t->security_interface = lsm_task_ilsm(current); t->security_ctx = (uintptr_t)t->buffer->user_data + buf_offset; err = binder_alloc_copy_to_buffer(&target_proc->alloc, t->buffer, buf_offset, @@ -4667,6 +4668,26 @@ static int binder_thread_read(struct binder_proc *proc, tr.secctx = t->security_ctx; if (t->security_ctx) { + int to_ilsm = lsm_task_ilsm(current); + int from_ilsm = t->security_interface; + + if (to_ilsm == LSMBLOB_INVALID) + to_ilsm = 0; + if (from_ilsm == LSMBLOB_INVALID) + from_ilsm = 0; + /* + * The sender provided a security context from + * a different security module than the one this + * process wants to report if these don't match. + */ + if (from_ilsm != to_ilsm) { + if (t_from) + binder_thread_dec_tmpref(t_from); + + binder_cleanup_transaction(t, "security context mismatch", + BR_FAILED_REPLY); + return -EINVAL; + } cmd = BR_TRANSACTION_SEC_CTX; trsize = sizeof(tr); } diff --git a/drivers/android/binder_internal.h b/drivers/android/binder_internal.h index abe19d88c6ec..152d0b55e050 100644 --- a/drivers/android/binder_internal.h +++ b/drivers/android/binder_internal.h @@ -528,6 +528,7 @@ struct binder_transaction { long saved_priority; kuid_t sender_euid; struct list_head fd_fixups; + int security_interface; binder_uintptr_t security_ctx; /** * @lock: protects @from, @to_proc, and @to_thread -- 2.37.3