Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp900518iol; Thu, 9 Jun 2022 17:06:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOQKjG6aUhrDKIYpiox/k5WsX9jhRHzghUWhjGSILOkj5bX26Y5A/R8Cbte8Ib0DU+1KfX X-Received: by 2002:a05:6402:f97:b0:431:8d1d:397d with SMTP id eh23-20020a0564020f9700b004318d1d397dmr18874997edb.423.1654819590332; Thu, 09 Jun 2022 17:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654819590; cv=none; d=google.com; s=arc-20160816; b=SyoJGf/l4sr8ze/yFz8pLz/M76cp/HJJn6iS2jGwj6eplodhBM5p7io3lYQc0fSIEH THqWSBveuql1DyGBCkOQ2peDeVTTfuQ0uhgRJcq0WXYNEqtoG1ckzmoO84bRGNh9HLIf 9rEGKIQx8AAMNOqwD+aMltQFgAQzslMDI+Vd3pYdc1RlPqZMv5ksO69Vgz9BvGJ1Tf85 AibMNScauRyxSHF+owKVqqRjfLa2mAdobkHMWyux5qKlsLxeF2D+nXjwFosWGWn/a3d1 ixtEJDoBwEUFVqPp7mBkmDxswLKhwieTo55er41FOThY3IF6+JVVq1hf9sTw03NmxNf4 fKmA== 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=lFb6izMu4S7T4jlacKPy5JLTz0oyrcHEb/BCqA/yNBc=; b=GmzlI258SXOTozlbiaxMNYgcpR40Zv1+//bnCkLFmKywaEgXsIUuIu5dMsZItsuIxi TexMUHxgu+b09h57SAHorhH3kFoCSPxXHsqqmZY79OXFZMd2hdcuZtfUMXUC7VCXgP+R FZiOqfXr4UPGVmiwzIpKbvigodL0oEMOCON6xSakp0QcDeitutx9MOCnXn8l3qUgdGae 91KFU0w+LB5ZJqhR8hN05YnmKLkTQcP1XQxtLdhDFLWHG7lVzqp/FDe8vWjkhizQvyTD hmM/Vm121XrFkKZmwdmSMAE4PlRd50t++Vx77lixLOEFsdhgokWwD3WbWuAr8Ck0cAFo s4cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b="ZRH/BUfd"; 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 go31-20020a1709070d9f00b00711fa454fb3si6637860ejc.889.2022.06.09.17.06.04; Thu, 09 Jun 2022 17:06:30 -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="ZRH/BUfd"; 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 S1345836AbiFIXOO (ORCPT + 99 others); Thu, 9 Jun 2022 19:14:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346009AbiFIXNl (ORCPT ); Thu, 9 Jun 2022 19:13:41 -0400 Received: from sonic304-28.consmr.mail.ne1.yahoo.com (sonic304-28.consmr.mail.ne1.yahoo.com [66.163.191.154]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF50662A2A for ; Thu, 9 Jun 2022 16:13:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1654816400; bh=lFb6izMu4S7T4jlacKPy5JLTz0oyrcHEb/BCqA/yNBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=ZRH/BUfdnpP/anfcjtGjOf4iG14nWLl+qdLWVT5en6XWEa5uFo9VljKs1d8ilmKyjMsaYbQdDCUGeaXa+MjHunmnU0Kbc6/hGIzFWvr8yk1Fj2i2xLKGYJhdeefC2FH8u24vD0jBRKxtawHW4Ev3kyvYns9aJ9qOSLCLQd/GsWgufZWcBlZGqWlm9oVUj54dH62wVXSthTVVP0Hq1Yt79FRtYpOK/9l+7thq83T6rWjzTkwdxdhPcbLOz5nBKcHj4L/EsRQyiNt8/x5qI9ETi1oefYAU2Yv0x8SEfA01xIUVLFW+ZvA4aWsglDOgeBitoI87gYJS3hdsxKA19x27QQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1654816400; bh=lEvHMldb+W9PmTRN957mHexexGunXVJAe4MsrCSSt+R=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=Am4VvxXkNwGSiOFDPOL4468pJ5yYU/qlvLNmBJvq487d6etFntB8Y4NY2Rr0GD0trIlaH48Z6A+tt9rW6LgbJ3v1m7S6Qk7HHZEmia6843hOivTz1WGpm16f393JUdTa6zMsYdVeVZUU4iCNxAjiACFYuMGO4SM5eTgQtCws3U18jmlRiVa1s5533Xzyo/ghzR2Ncn8LUtKx6X6EONS7qjaC1/rwC9Rd0yN9VcA3EJSozrX7R/bGfBALyAkWk1tqgAJvNZn3prTe4ApEXB/DWDgQSFWYn+xLWptV5sS2GIitO+pnOGGGIt8UZMyAyMLVG28FU9JGXgxAq57oBXvZ3A== X-YMail-OSG: eniDTmcVM1myeZhnvC48CMTpgGrDMHUiWujYgiUTrf7Giv_1NZpepqohiirDJuN bdWNPPb8ctsR2w5vUK9ngJXY5x1wzvgmiIURyply9mmWiFOfdGClA..L1wAsi21mSLPZN19s3JOK HXeTpejPWZtaGLN0nul21u2zeJTHlIsVDHUFrdue_.aO2JBjQX5aVJwVMfp7vpKndbX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_JyA4prFrjCebmaOq POZZcpAM3D3WTEHONSk79LOht2TiNPm7hqeUUcd_5PUCHBXIcxi.Tjy7VQQ-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ne1.yahoo.com with HTTP; Thu, 9 Jun 2022 23:13:20 +0000 Received: by hermes--canary-production-gq1-54945cc758-szwwf (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 2f409ca26a6c68d04d9ee89cddfc02e1; Thu, 09 Jun 2022 23:13:14 +0000 (UTC) From: Casey Schaufler To: casey.schaufler@intel.com, jmorris@namei.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Cc: casey@schaufler-ca.com, linux-audit@redhat.com, keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, paul@paul-moore.com, stephen.smalley.work@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH v36 21/33] binder: Pass LSM identifier for confirmation Date: Thu, 9 Jun 2022 16:01:34 -0700 Message-Id: <20220609230146.319210-22-casey@schaufler-ca.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220609230146.319210-1-casey@schaufler-ca.com> References: <20220609230146.319210-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, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 8ae1a624cd37..f2a0faf6d9c6 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -3107,6 +3107,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, @@ -4552,6 +4553,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 8dc0bccf8513..7233bfdb72db 100644 --- a/drivers/android/binder_internal.h +++ b/drivers/android/binder_internal.h @@ -550,6 +550,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.35.1