Received: by 10.192.165.148 with SMTP id m20csp3434309imm; Mon, 23 Apr 2018 06:35:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx48gnk4rQgX0T6XCZKJl4rFepgsZcDjZUIxQWZ5ZwsyhrzF6bl3lvLVWT8qbREQHxSB5gBWt X-Received: by 10.98.111.137 with SMTP id k131mr17012110pfc.81.1524490517887; Mon, 23 Apr 2018 06:35:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524490517; cv=none; d=google.com; s=arc-20160816; b=rCNHZZyBsVFbNzFu8R+cjUMwk9PD1STEpxAzJAqR44b8HQbKV5uZl09S1pPYSeE/r+ FGzS9oXc+gATbpj7qzNVP5QSTrfSmFjZuJHTxmtV5iaO/A9DsbIKfsGAiQZxVeCNlbd5 i3gGloB7RkGF4grNA6NYXumNGJFEiAY7orRaaxp/2N2BRmN9ePlZvkHQ0Ay5jOu+SOQL 3iV6zxRRuGQ0ZutYH3qrKFaQQ5g5fGsrHeNBj6c1yIs4TSY+GWjUmauCms7qrYW66o8/ LGVKIJJ49DLwMpsVTsjB3prrsRozG7Pz0yAjsViYgMtdOyTevY/pe4WZYscpK/R9vlp2 +elg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=BWXPXjWiEQD+a58osTk1tBXulHZ8/HrYkd6QUVi/1NE=; b=QgXHLpvQNWflTaGPn3MVz8fuLI05/QwG1wCakQjCrV0lR4APT3ghSII5M6TBuCz9Jk lDFrft+z0wQBWpK/yNbwO5oW+vBXSe0T4TV/aC2sSq8usYJQHtQCC0XNdsP4Ao0WWqqY VJbKSsznxxCeXIzAsGUxh7dDUGo2XxkicOtqz6yGUMhZfIlvM3MbCsCmFbI4V7a+1gXL kOk+lEYDca2dctvxu71oC6x1Y0oBaXp6oQ0Mk21nOJpXosH88s+RXkZ9gmosJPAf3stz Ms5QioeLpPS0mqY/spO627kPGX/JHu7YpdYatK2bjayA5QSf/O0DKT3mNUG4UDWJhhvd ySnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aQ6rQxOd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 132si9553765pgb.470.2018.04.23.06.34.33; Mon, 23 Apr 2018 06:35:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aQ6rQxOd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755369AbeDWNbL (ORCPT + 99 others); Mon, 23 Apr 2018 09:31:11 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:42461 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755059AbeDWNbA (ORCPT ); Mon, 23 Apr 2018 09:31:00 -0400 Received: by mail-wr0-f196.google.com with SMTP id s18-v6so41301800wrg.9; Mon, 23 Apr 2018 06:31:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BWXPXjWiEQD+a58osTk1tBXulHZ8/HrYkd6QUVi/1NE=; b=aQ6rQxOdgcqg2WBmqGYVAHtkp5ghLbzl7/2IHSt8eqE1Q9yBPmkAfCOPRBfltD9vtN rt7gaS8YaKpTlgrN2j2jYqksnzmWiWBsJqMx3NXF1wQFkU8xjOjDUUvmnpe1mzSYmOip fhS4mzNvjVQodHMeC51j8eIkcxle/q4UsHwJqSxMtyXA45GpTx6N37md4SSYpqRM6fWF AOS/TtJs6PaeH2PagDMpGIpE9zSlw6l44t6WWI6WZMCOnOa0kiOvn7RgQ8MbTMSsLctd 7Iu9oYmdaX2YHHCB2wh65mnUL6jC4nt7FM2vrYLgscCsJdRcT+3LfN1uJSZISHcmL+be zjJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BWXPXjWiEQD+a58osTk1tBXulHZ8/HrYkd6QUVi/1NE=; b=kivZSe1Gk/Bbgg1+Z8DQnJVT8rvxxWp9ZEEO6EIeJSOXVu/dIE0jM36fUqc7rfOJl1 1ZqpoewilxjES10qwEU28yfsk+5LW8crs4SFkvAisDScMY7ODFKwcSxeOkSt75/Eun/e VldIlWCzZ04u9OCNpGUktWCMKVXDz09k99WzNWYMjKwappq5/Vccq0S4drcmN9/myqEO MbzOeSmfX5edUrOOHTHVnwnIVDuju/QkFOIXw+t9oVHuD9qC/MLwXINvrLiTZzf6xRQM A1zHAER3eP5VoK0r03Pv3oUxCucMDUZQbej7ntDPLzzRBeqyT2gES1KNyN1SZYDYEckV n1pA== X-Gm-Message-State: ALQs6tAzWAmzVgjhKIxWsZC9sx+YUPYXaPQyS3mx1Qdt/r4PzsyaB4u8 ufbKN/Sm3w6hazPX6CumknNVWg== X-Received: by 2002:adf:c908:: with SMTP id m8-v6mr16775966wrh.6.1524490258755; Mon, 23 Apr 2018 06:30:58 -0700 (PDT) Received: from david-x1.fritz.box (p200300C2A3FE3000ECB787D771B96788.dip0.t-ipconnect.de. [2003:c2:a3fe:3000:ecb7:87d7:71b9:6788]) by smtp.gmail.com with ESMTPSA id 78sm10262548wmm.19.2018.04.23.06.30.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 06:30:58 -0700 (PDT) From: David Herrmann To: linux-kernel@vger.kernel.org Cc: James Morris , Paul Moore , teg@jklm.no, Stephen Smalley , selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org, Eric Paris , serge@hallyn.com, davem@davemloft.net, netdev@vger.kernel.org, David Herrmann Subject: [PATCH 3/3] selinux: provide unix_stream_socketpair callback Date: Mon, 23 Apr 2018 15:30:15 +0200 Message-Id: <20180423133015.5455-4-dh.herrmann@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180423133015.5455-1-dh.herrmann@gmail.com> References: <20180423133015.5455-1-dh.herrmann@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make sure to implement the new unix_stream_socketpair callback so the SO_PEERSEC call on socketpair(2)s will return correct information. Signed-off-by: David Herrmann --- security/selinux/hooks.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 4cafe6a19167..828881d9a41d 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -4905,6 +4905,18 @@ static int selinux_socket_unix_stream_connect(struct sock *sock, return 0; } +static int selinux_socket_unix_stream_socketpair(struct sock *socka, + struct sock *sockb) +{ + struct sk_security_struct *sksec_a = socka->sk_security; + struct sk_security_struct *sksec_b = sockb->sk_security; + + sksec_a->peer_sid = sksec_b->sid; + sksec_b->peer_sid = sksec_a->sid; + + return 0; +} + static int selinux_socket_unix_may_send(struct socket *sock, struct socket *other) { @@ -6995,6 +7007,8 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = { LSM_HOOK_INIT(inode_getsecctx, selinux_inode_getsecctx), LSM_HOOK_INIT(unix_stream_connect, selinux_socket_unix_stream_connect), + LSM_HOOK_INIT(unix_stream_socketpair, + selinux_socket_unix_stream_socketpair), LSM_HOOK_INIT(unix_may_send, selinux_socket_unix_may_send), LSM_HOOK_INIT(socket_create, selinux_socket_create), -- 2.17.0