X-Received: by 2002:aa7:c582:0:b0:40a:92b2:1bc4 with SMTP id g2-20020aa7c582000000b0040a92b21bc4mr1417599edq.202.1645653657086; Wed, 23 Feb 2022 14:00:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645653657; cv=none; d=google.com; s=arc-20160816; b=ercWeEJ7YmJKTpF1z7YPzzqUMY8c2udWKeFbJJ9iZxEffFsOi5HgtxZMKeXzjMocdn cFM/0kkHNHHLgzmaKxvXWsHv947Krwexkzr8mKsT0oiGA7xCUZ33MugJ2g4qA9XQtnmY RfAhuCkZRY5MEuT36lcBA6TShNLn/vLFjN+NBSnCsmHyshFF2S3EN0upA9/JYxZaH3Og ph6rydguJj7hwe5OzWhTnCa7z0xut3vuJMOjnO/3P6k+ZetXOg+VmwVLZJnQ72z7yeiN y+cv8PxZ8XHPmsu+MpVvnL8oZEq1m6zCHEFrEJNjeX1z3JL9epq8qOkmBbG1EDcRjFbQ Jbjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2bJacL1gK1myHV6cmtvqCkNpKIOqEyVm+DidPJT3PKU=; b=vsUuJhaG4T7tVk/pjWAW47CIx1pdrB4nh0+fBsQTDC5muFJ/ECLlbRLztE/TKVqW+9 E4kwSlew5h6Wihf1a+NULU1h00tGU8hVuobX1c/kAWZjzeH7cuXrFG/XqbGputMxp8k1 WCiFuD256x+jWV20n5r2+OubzxfsWPsdJ2WqNOKPrUcIYfRRzTfy/tdijPpgUBEHo6pp Lf9YpjGplIPkh5v2H4mvXgXnwLXeWDGfKVGbcD6tXhRD4FboeRLv8wNWrmlZvHT9qWx4 0QDtnNl76GKay6jv8esDzpi1TdpGgY2bZnTIfUWklplH+hPh+ryhHtcSpiw596mSMIl6 OQGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b=sF8l6ITl; 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 e7si540501edk.407.2022.02.23.14.00.33; Wed, 23 Feb 2022 14:00:57 -0800 (PST) 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=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b=sF8l6ITl; 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 S242970AbiBWVoI (ORCPT + 99 others); Wed, 23 Feb 2022 16:44:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237684AbiBWVoG (ORCPT ); Wed, 23 Feb 2022 16:44:06 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B34B35240 for ; Wed, 23 Feb 2022 13:43:38 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id gb39so249176ejc.1 for ; Wed, 23 Feb 2022 13:43:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2bJacL1gK1myHV6cmtvqCkNpKIOqEyVm+DidPJT3PKU=; b=sF8l6ITl0deyEMbxKkVIBrcWScHYUlwGQ8IQ5KmZ0HCOlbjdfOy9WsrDyQj6LWGhcv XHvcMFnlKmcsJSmgsY1rmpKshkAg8cYruw0wsuugbnkkzHD7MgPdOC6tAdEgHg45WR+3 m2k4uZAbXdat+d3aXBzZTuFw6/XegOEvHgQR0tzcTRKAFhVFLNB2IjLo9pHyoUtVqGMB UOAT9gfzUxBjmOblb6206DPGuu+3UnRppOf3g1ywhHao8I/RF1TKAzOGE12ktriKt6mU Ml+BO4wJnQjK5FTt9k1MqxRe7WHHjEMoa10RhXV7MpH16ah7JM3J00tfLRBaLWVSYivY JAIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2bJacL1gK1myHV6cmtvqCkNpKIOqEyVm+DidPJT3PKU=; b=aEyFKg1RPwVkucm5bUYa1u3Tdz0Ive24yUWEk9qrds/Y5KXU5UDo5YAX3xAangqPXe UXIOCnVYqBm5CYhSupMQS+4MFZQQkwvrKysejFUslk8rF0wT2qhdX2p5VRygL4oWcQMn mbThKN+Bp6fk0gj0CzMmyb8gAF7y5XjYQk9oaM52MWnuDBq3D+DoHnUH3ThROleGrBPx 7BoqGKV4HPNsjnqyjRRUJ9Nhx4/hjrOumntyB4pW5CB8nibnVjzKO1MvjS8NpE3xDkrM EqaNVpbsloq9AgYEdhDHrfBDzvWXbE068acFPnvbZXXImKYjE306IaMQE5vHv88XKwyJ BD/Q== X-Gm-Message-State: AOAM533+o9h66RMC8anSV145XIvO/XDZGUjL23hBv9tedF7drXOPl1kQ vSKJrV91/ue/kJwlInm1EOtuZcf0mnTVbKEEKyKY X-Received: by 2002:a17:906:6b8f:b0:6cd:7984:26fc with SMTP id l15-20020a1709066b8f00b006cd798426fcmr1203566ejr.701.1645652616571; Wed, 23 Feb 2022 13:43:36 -0800 (PST) MIME-Version: 1.0 References: <20220221131533.74238-1-richard_c_haines@btinternet.com> <20396305e71619dbee4fa3c612925b57f4bb0a4b.camel@btinternet.com> <2b45951fceea5f535550f8ab3f3d25c3ff12a8c5.camel@btinternet.com> In-Reply-To: From: Paul Moore Date: Wed, 23 Feb 2022 16:43:25 -0500 Message-ID: Subject: Re: [PATCH V2] security/selinux: Always allow FIOCLEX and FIONCLEX To: Richard Haines Cc: Ondrej Mosnacek , Stephen Smalley , Eric Paris , demiobenour@gmail.com, SElinux list , Linux kernel mailing list , selinux-refpolicy@vger.kernel.org, Jeff Vander Stoep Content-Type: text/plain; charset="UTF-8" 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=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 On Wed, Feb 23, 2022 at 4:36 PM Paul Moore wrote: > On Wed, Feb 23, 2022 at 7:43 AM Richard Haines > wrote: > > On Wed, 2022-02-23 at 13:12 +0100, Ondrej Mosnacek wrote: > > > On Wed, Feb 23, 2022 at 12:58 PM Richard Haines > > > wrote: > > > > On Tue, 2022-02-22 at 18:28 -0500, Paul Moore wrote: > > > > > On Mon, Feb 21, 2022 at 8:15 AM Richard Haines > > > > > wrote: > > > > > > > > > > > > These ioctls are equivalent to fcntl(fd, F_SETFD, flags), which > > > > > > SELinux > > > > > > always allows too. Furthermore, a failed FIOCLEX could result > > > > > > in a > > > > > > file > > > > > > descriptor being leaked to a process that should not have > > > > > > access to > > > > > > it. > > > > > > > > > > > > As this patch removes access controls, a policy capability > > > > > > needs to > > > > > > be > > > > > > enabled in policy to always allow these ioctls. > > > > > > > > > > > > Based-on-patch-by: Demi Marie Obenour > > > > > > Signed-off-by: Richard Haines > > > > > > --- > > > > > > V2 Change: Control via a policy capability. See this thread for > > > > > > discussion: > > > > > > https://lore.kernel.org/selinux/CAHC9VhQEPxYP_KU56gAGNHKQaxucY8gSsHiUB42PVgADBAccRQ@mail.gmail.com/T/#t > > > > > > > > > > > > With this patch and the polcap enabled, the selinux-testsuite > > > > > > will > > > > > > fail: > > > > > > ioctl/test at line 47 - Will need a fix. > > > > > > > > > > > > security/selinux/hooks.c | 7 +++++++ > > > > > > security/selinux/include/policycap.h | 1 + > > > > > > security/selinux/include/policycap_names.h | 3 ++- > > > > > > security/selinux/include/security.h | 7 +++++++ > > > > > > 4 files changed, 17 insertions(+), 1 deletion(-) > > > > > > > > > > Thanks Richard for putting together the v2 of this patch. > > > > > > > > > > As far as the test is concerned, it seems like the quick-n-dirty > > > > > fix > > > > > is to simply remove the ioctl(FIOCLEX) test in test_noioctl.c; is > > > > > everyone okay with that? At least that is what I'm going to do > > > > > with > > > > > my local copy that I use to validate the kernel-secnext builds > > > > > unless > > > > > someone has a better patch :) > > > > > > > > To fix this I was planning to submit a patch that would change the > > > > ioctl(FIOCLEX) tests to ioctl(FS_IOC_GETFSLABEL) as that would > > > > continue > > > > to test the xperms. > > > > > > That one seems to be implemented only by some filesystems. Is there > > > any more generic one we could use? > > > > What about FS_IOC_GETFLAGS > > Unless I'm mistaken, FIGETBSZ should be largely fs independent. Bah, nevermind, FIGETBSZ ends up in a FILE__GETATTR check. FS_IOC_GETFLAGS has the same problem. How about FIOQSIZE? -- paul-moore.com