Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp796176rwr; Thu, 4 May 2023 09:38:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6p6PnMNOgQPCSfBXS7RbsPKGQTRuXq6qJl2+i5LaUHDpZfjRb9Ulj8evvhcH0JITzOsq2L X-Received: by 2002:a17:90b:f12:b0:24e:12f4:b74f with SMTP id br18-20020a17090b0f1200b0024e12f4b74fmr2646015pjb.20.1683218328324; Thu, 04 May 2023 09:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683218328; cv=none; d=google.com; s=arc-20160816; b=dfxn5+GWNUBPUpBAaLlBx6kEOR0PUsMsSameOHdImI9540fBcUMGH5f8ZE+Pn+FK7F Qvdp2GXEJS0NmATK07Yt0gXf8YRxB6GYhfhJ0a8V55NyIg1JrrhdbsKXUByQcWdpJWSh veZEMbI6fRYk8GLRZhOSrKXE95QiZ6yoJAz8W2AgmsiH7tmFAFPXVVg6kSm8/LIG8Wcw roz1VpCmFvX2dAuKR9IPg02nXE05UUKOQBpdbvlexrgVMokR59J09J9FWKry3wBvmaz1 fHBQm8HUiFICDVenWCLc8xn/jaq86OwaZGuoiBDi4jab2GEwNVedUB5AF+3Ad0PYD/QP 9vrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=FCERTes3cUqeH2NVPYErrzXP04o1ceM5Rm63oz0hrwA=; b=fZL8LZESksAKu1bNQ2uGgXC5+r39LSZZKdxUA4Gq/FcEFAo5qja/C9wWIdsUg0LwfM eRpW3YUdwHOWRXMd8m0jR3o3NHmNhoZ0mww16jn4zmPHm9ZrQsiLgANSVYvJvZlF3rdK xV0ni8+F/DqZgdHxBgTEVzPz7T1/jtdwqYztFb7gQD0uD9GrI+qFZ6BCd5ieeQlNtsEq m8CBi1Ds4Zssorv8MUvP+hQrias2A2CIJoEWNW7/H7LAVuUVUIoEjHZ1XRwNxyFA/V4G EXgscuDDNa0C2MXIwwNnSaScU6swCu+U+m6UBr1VzHBWB8lw8d7ijAkR6boX6viTZ5Sh CWng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=T0NuVRqB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mg24-20020a17090b371800b0024b3c34ca20si4269060pjb.55.2023.05.04.09.38.35; Thu, 04 May 2023 09:38:48 -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=@redhat.com header.s=mimecast20190719 header.b=T0NuVRqB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229522AbjEDQOW (ORCPT + 99 others); Thu, 4 May 2023 12:14:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbjEDQOU (ORCPT ); Thu, 4 May 2023 12:14:20 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A03F759FB for ; Thu, 4 May 2023 09:13:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683216809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FCERTes3cUqeH2NVPYErrzXP04o1ceM5Rm63oz0hrwA=; b=T0NuVRqB3i+D2acfpbAuysJIjFR2JjMP9v0+kmnSJLAeNHhFawks18kKL2uUTXQIAIkRse 11XbFFhopDe52xGsiORtT4Tkl0kEt/40y999hkFh2Z9lsmQTIgvxfoCsq5KLhSct9Bk3po Yb+e4UbnSuyUQHdsqVeQg/6dgsUWlAI= Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-185-XtILlN8hPlOI2SLFkPXC7Q-1; Thu, 04 May 2023 12:13:28 -0400 X-MC-Unique: XtILlN8hPlOI2SLFkPXC7Q-1 Received: by mail-vk1-f199.google.com with SMTP id 71dfb90a1353d-44fbe281e05so15971e0c.1 for ; Thu, 04 May 2023 09:13:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683216808; x=1685808808; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=FCERTes3cUqeH2NVPYErrzXP04o1ceM5Rm63oz0hrwA=; b=V0HTyh9Mu1Pg5xvOwmyZCkwVJqIZvvt41JZpu4+2ONuj7NYnoptAQxp9aJmlYCI4Wf 3lR/R45VkkkBpZa8QKpra59JszGqM6K/woJrzN7vmIc1OKXdBw3gPkQlCe9fBgB7Rmrp 0hlXvkY0WDRY1Op4/78P3EpVTLr4MeQ/KdsOTE7R/Z769kbV18HV++/adLXcT4Uf9yCW 0qtkRa4v0wdKuMsIx9X4bOdzJ9y96qQkJtfwSk+An+dtduWSeoGWCMUYTFhIaTR+0IlN 3/peInaQewrdyZhSXH+ZrINo5EQ4COAt6TPtF7k3VCWe73CLeb4vkzix7BU84zRA0xio O3rw== X-Gm-Message-State: AC+VfDwN1bqbt28ELrHzDXkLShVIahphAeWB43/sNVHE0uxuPIew7NcD 5ffsR+FU3LZOxvWpAiHKCni75Bhg2KcEve4AYFuvVgnXvGEtdvHTuEqPWRc959l+odGsaBN+yD/ ciE4Otob++JrFzCT3DD6+QW0q X-Received: by 2002:a1f:b646:0:b0:448:1241:47ae with SMTP id g67-20020a1fb646000000b00448124147aemr3069416vkf.1.1683216807871; Thu, 04 May 2023 09:13:27 -0700 (PDT) X-Received: by 2002:a1f:b646:0:b0:448:1241:47ae with SMTP id g67-20020a1fb646000000b00448124147aemr3069388vkf.1.1683216807461; Thu, 04 May 2023 09:13:27 -0700 (PDT) Received: from gerbillo.redhat.com (146-241-244-79.dyn.eolo.it. [146.241.244.79]) by smtp.gmail.com with ESMTPSA id 75-20020a370b4e000000b0074df3f7e14esm11694249qkl.67.2023.05.04.09.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 09:13:27 -0700 (PDT) Message-ID: <11201df515ec41db88ad915fd1e425e62c4f81e5.camel@redhat.com> Subject: Re: [PATCH LSM v2 0/2] security: SELinux/LSM label with MPTCP and accept From: Paolo Abeni To: Ondrej Mosnacek , Matthieu Baerts Cc: Paul Moore , James Morris , "Serge E. Hallyn" , Stephen Smalley , Eric Paris , "David S. Miller" , Eric Dumazet , Jakub Kicinski , mptcp@lists.linux.dev, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Date: Thu, 04 May 2023 18:13:23 +0200 In-Reply-To: References: <20230419-upstream-lsm-next-20230419-mptcp-sublows-user-ctx-v2-0-e7a3c8c15676@tessares.net> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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 On Thu, 2023-05-04 at 16:14 +0200, Ondrej Mosnacek wrote: > On Thu, Apr 20, 2023 at 7:17=E2=80=AFPM Matthieu Baerts > wrote: > >=20 > > In [1], Ondrej Mosnacek explained they discovered the (userspace-facing= ) > > sockets returned by accept(2) when using MPTCP always end up with the > > label representing the kernel (typically system_u:system_r:kernel_t:s0)= , > > while it would make more sense to inherit the context from the parent > > socket (the one that is passed to accept(2)). Thanks to the > > participation of Paul Moore in the discussions, modifications on MPTCP > > side have started and the result is available here. > >=20 > > Paolo Abeni worked hard to refactor the initialisation of the first > > subflow of a listen socket. The first subflow allocation is no longer > > done at the initialisation of the socket but later, when the connection > > request is received or when requested by the userspace. This was a > > prerequisite to proper support of SELinux/LSM labels with MPTCP and > > accept. The last batch containing the commit ddb1a072f858 ("mptcp: move > > first subflow allocation at mpc access time") [2] has been recently > > accepted and applied in netdev/net-next repo [3]. > >=20 > > This series of 2 patches is based on top of the lsm/next branch. Despit= e > > the fact they depend on commits that are in netdev/net-next repo to > > support the new feature, they can be applied in lsm/next without > > creating conflicts with net-next or causing build issues. These two > > patches on top of lsm/next still passes all the MPTCP-specific tests. > > The only thing is that the new feature only works properly with the > > patches that are on netdev/net-next. The tests with the new labels have > > been done on top of them. > >=20 > > Regarding the two patches, the first one introduces a new LSM hook > > called from MPTCP side when creating a new subflow socket. This hook > > allows the security module to relabel the subflow according to the owin= g > > process. The second one implements this new hook on the SELinux side. > >=20 > > Link: https://lore.kernel.org/netdev/CAFqZXNs2LF-OoQBUiiSEyranJUXkPLcCf= BkMkwFeM6qEwMKCTw@mail.gmail.com/ [1] > > Link: https://git.kernel.org/netdev/net-next/c/ddb1a072f858 [2] > > Link: https://lore.kernel.org/netdev/20230414-upstream-net-next-2023041= 4-mptcp-refactor-first-subflow-init-v1-0-04d177057eb9@tessares.net/ [3] > > Signed-off-by: Matthieu Baerts > > --- > > Changes in v2: > > - Address Paul's comments, see the notes on each patch > > - Link to v1: https://lore.kernel.org/r/20230419-upstream-lsm-next-2023= 0419-mptcp-sublows-user-ctx-v1-0-9d4064cb0075@tessares.net > >=20 > > --- > > Paolo Abeni (2): > > security, lsm: Introduce security_mptcp_add_subflow() > > selinux: Implement mptcp_add_subflow hook > >=20 > > include/linux/lsm_hook_defs.h | 1 + > > include/linux/security.h | 6 ++++++ > > net/mptcp/subflow.c | 6 ++++++ > > security/security.c | 17 +++++++++++++++++ > > security/selinux/hooks.c | 16 ++++++++++++++++ > > security/selinux/netlabel.c | 8 ++++++-- > > 6 files changed, 52 insertions(+), 2 deletions(-) > > --- > > base-commit: d82dcd9e21b77d338dc4875f3d4111f0db314a7c > > change-id: 20230419-upstream-lsm-next-20230419-mptcp-sublows-user-ctx-e= ee658fafcba > >=20 > > Best regards, > > -- > > Matthieu Baerts > >=20 >=20 > I haven't yet looked closer at the code in this series, but I can at > least confirm that with the series (applied on top of net-next) the > selinux-testsuite now passes when run under mptcpize, with one caveat: >=20 > The "client" test prog in the inet_socket subtest sets the SO_SNDTIMEO > socket option on the client socket, but the subtest takes > significantly longer to complete than when run without mptcpize. That > suggests to me that there is possibly some (pre-existing) issue with > MPTCP where the send/receive timeouts are not being passed to the > subflow socket(s), leading to a longer wait (I guess the default is > higher?)=C2=A0 Indeed the behavior you describe is due to some mptcp bug in handling the SO_{SND,RCV}TIMEO socket tions, and it's really unrelated to the initially reported selinux issue. If you could file an issue on our tracker, that would help ;) Thanks! Paolo