Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp93278pxh; Thu, 7 Apr 2022 15:04:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnvTa3bx29boEBxF7D2NQFbXdCsHhhhGHf7p+azkQMZx8u9WNXjtXMEY9Iy5+AyJsMmhaL X-Received: by 2002:a05:6a00:2d0:b0:4f4:1f34:e39d with SMTP id b16-20020a056a0002d000b004f41f34e39dmr16300354pft.14.1649369068233; Thu, 07 Apr 2022 15:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649369068; cv=none; d=google.com; s=arc-20160816; b=aliLJm6maTaGXxp7cFFJp+/DL7bZcte91PWMHIwALanOIT0X6Ho6C9KJMb+GHAfiHK dG2AHyaHG23f34zzM+86iSfjA7efCo23d9Ehwll8OmfMhVbwNC1jvQ7+KuwEVYBEk6mw OU+HQExcYbbIqs3ofBZJ0nVU655KJfcMpK3q06pqCDjfjpXUTjPSm4xQVO1WkMRyJqVd k1D0CbaR+HWe2cqaCKvykl4CIZMq1gnf5j5BdMjIdSr3LeQlfxiGQG/9HWVdcKNUvxPr +KweNXwNF2aPsvqsYcK+A19wZGimbBWBkGUJSLAnK0K6gNEHufI54RKYrdCI0H2HbO/K RCog== 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=4/A9RMlo2VDUS+eJ3c9f9QVdqHvAgQb0ICSOChfHCEA=; b=YhEwf1dAqIFC2RIL2UUH2Yy5vO36BPcBzhmdNrisuU/qFW9ATH8Ujhg9D9a3FEHmd0 CLBxrypimNJKHwQ31tob6aczga+4mulkLP5rZfAOx0t76aP3qp/yins9xroClfBErwbK rriE7asyjPA0i7zFkjNl9rZjDnRf6k31DjAgNW2mMMa+GDHpbg+l5/zDfBtl1StT3XvW 9/lLGlSZ9EMZ/mZyb+DkhN5k2RBqN3/rTb68ggwqILBld/kwdlTRzkxbmKhWbVDH/m7n vPD5y2o3GccKQB766FdwnOOuRc8W8OTVWMk1SCWZBJqfCMQ3ejdLxzFLu5SmZWfXtEw7 Ky+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=Ryn8OaAK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 188-20020a6308c5000000b003816043ef0dsi20233125pgi.258.2022.04.07.15.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 15:04:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=Ryn8OaAK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 047401AE613; Thu, 7 Apr 2022 14:33:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231684AbiDGVev (ORCPT + 99 others); Thu, 7 Apr 2022 17:34:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231610AbiDGVek (ORCPT ); Thu, 7 Apr 2022 17:34:40 -0400 Received: from sonic310-30.consmr.mail.ne1.yahoo.com (sonic310-30.consmr.mail.ne1.yahoo.com [66.163.186.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F15136E4C5 for ; Thu, 7 Apr 2022 14:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1649367154; bh=4/A9RMlo2VDUS+eJ3c9f9QVdqHvAgQb0ICSOChfHCEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=Ryn8OaAKc10C1bsMQSYLoZj9HdSKxoThkl1wq0R8liO9n42Ea3/t+el342QAjKnVIkOrsod0zqYvD/n6XbgqGuRapoYj4MNYp0p+Heuj+BatkHM/HfbEcHxthtgzwS0w1ReZqxnjzjIuZDnUGuRUiwXmESsZYgH+2Gwb5dH1U84DIr10irbZNip5C0KTJm80KoKTvbiZXcOAbiAcJGG0ryR/g5VSRZpc0uT7L2IUnKwBNXKtLX7QLQmmL4jr5O+MhzJAvi6ea6hZowRqZhYA9kCGZmlWInhlHKW2zRCoHnCjTkVNn6cSa5oN9Npq0ZXVB2QdTJROXFIP3xIsM/CR9Q== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1649367154; bh=TeBf3nA4zzz7/MT6VzgAZ5JxMa8Xw9dWH1edEmqrXlP=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=pwrnLS8XONKJyYMCbYpn6NJx1lG3oKnZTuR0qEBQk9IYnUwMeJhQvPuTkzt0h+nUGvh2wPts+MhfUkUsJ//xm3e/d/uwafwfGBmaBXBIOPYkjXUfF1Pupqr+Q4bhktD8RAv2s4vr0k6KW8HivqaTPfLLlMIIeZgoCXhMYbdQF1+b7CTnMwRF6LtegWGaPoc6EeFtPs3Fg+hA2GDOv+g6FB525qmNRWRQQ73dzQexu2DWMhU+JH1f1P2JbG/jnFQ9OfLQKVo3xWgTZdEm64ek/XubTZvb499sgJJMujXwxKQWT6gr+W6W+AJz0iiJLjMqWngHI3kfG3xbcdNYQbDM3w== X-YMail-OSG: y9XejpMVM1lC7m5Gb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_tg2AyPMUTjAWuiXlezDsDr w_RZI0ZNKZmtJ_sWQga_WXp8lnzg3j_sQgzvPric7ryMy3KExbNIJViYv.mhHZ.v.a_iVd8Ehwm9 ZZRNb71HyWt76q1Srfa.JMGl7xtPf4nVexfVu8NIv4PM7oO1pk1oPOouuI70j3X2qhmqgobXWh82 R0wgbedOtaTKBBmsnQxoVbe.Ize7V_q0- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ne1.yahoo.com with HTTP; Thu, 7 Apr 2022 21:32:34 +0000 Received: by kubenode527.mail-prod1.omega.gq1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 1c3e27710c5567bf7ba0bbb257134c66; Thu, 07 Apr 2022 21:32:32 +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 v34 20/29] binder: Pass LSM identifier for confirmation Date: Thu, 7 Apr 2022 14:22:21 -0700 Message-Id: <20220407212230.12893-21-casey@schaufler-ca.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407212230.12893-1-casey@schaufler-ca.com> References: <20220407212230.12893-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,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 b0b0c132a247..259f5e38e6ba 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -3024,6 +3024,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, @@ -4453,6 +4454,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 d6b6b8cb7346..e3a0718ce17c 100644 --- a/drivers/android/binder_internal.h +++ b/drivers/android/binder_internal.h @@ -545,6 +545,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