Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4979254pxb; Wed, 26 Jan 2022 02:00:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBfmwP1QAg9SEjjbMPKWJjTnwkCc5Twf/GmQaEGZ4SVX9pasj+ZWwReVexOqcmSKjIQxrk X-Received: by 2002:a17:90a:5913:: with SMTP id k19mr7857044pji.176.1643191223883; Wed, 26 Jan 2022 02:00:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643191223; cv=none; d=google.com; s=arc-20160816; b=l0vmRsELCY/vWSauliLrzbYtiAV6M6rhADRPMMRM9H8eZa8Go3Wdf1iqUqe7rDHACV TFhQ1oDtv+ZlDQxq0ZqWNRltAamZQ2rtrrpixBT3W+dq1I8bG+PB/fWiTjUdZTbmKjTk IdSm2bBitnay/y5gnEEDXIoBJfWGgUTpx8+tQkOcFIE7H2lmOa7PFMYdEgMITyU/BSbI mRYTcZu8NDJN1lr9gBHpbznZRAXZsDqE2PFWjHhukjxtnlmc3X6v3ZwxQC7RkBkZ//UL C/5Ltv2C1bN1lq2o2nUf3rJGKWxwj+S2Eb9ofOItjqjhMq4dB8lokgZPkO/vCKWC5wuR 62KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language:cc:to :subject:from:user-agent:mime-version:date:message-id:dkim-signature; bh=JOQ3PmaJtbdtPUYBzN8lYyLwqfEwyWGHTqG8SXs6IXQ=; b=MoWL4KEkhUV3JX6Zo1ThEsxnZ5knm/l+lReA7RdHz0/ZYuAD/xUBYX76w19qRdIlsv MKnZEZUGR/jRgk6xwJ2+ywCx2poTxlcsiJCK6jH7UsQW9p3EJPyk+c/A/oWgp2X8r9EL t/jEnHDqk7Na7RNpWvFOd3G3mD2PIU2w1m9fEurbPG1WRzYEylA6CU8BYwrP+NT8s2dC n45pKKhnuFvXvyFRIK14WO8ifbvp4P5bn0bQjTJkBE51vNUXcU/lEk/T2qw1bU6WSdv4 N2WrSq6fACMi67Kczt4Et/p1acAmNEji5pNuM5kGQL2C3f+Nnuy5fREABjrKj8xjnT7g 7kAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="DLJtQB/i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id i4si14505527plb.489.2022.01.26.02.00.11; Wed, 26 Jan 2022 02:00:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="DLJtQB/i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233176AbiAYVeR (ORCPT + 99 others); Tue, 25 Jan 2022 16:34:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233148AbiAYVeQ (ORCPT ); Tue, 25 Jan 2022 16:34:16 -0500 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C447BC06173B; Tue, 25 Jan 2022 13:34:15 -0800 (PST) Received: by mail-qk1-x72c.google.com with SMTP id w8so12731808qkw.8; Tue, 25 Jan 2022 13:34:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to:cc :content-language:content-transfer-encoding; bh=JOQ3PmaJtbdtPUYBzN8lYyLwqfEwyWGHTqG8SXs6IXQ=; b=DLJtQB/iPbudM4U5QdnFTufb8Ay0mLqmLcSVPxmc8P4p1gEtaJ3bvEx3FZmixDmyHF 03V4e0Z1BRn8noHW/vGg3uurht3vEnpwnxqQ7PrgKZO1YWOfsFKTB66vM829GeKyWqJw 4ON1cEHGSIqbJ0x5IjCNI9aQr+Ickgpp64iXjee09+YjZe44jJlFRwlY1uhlLj/t2vs1 D7NzK4h+/rwbpDQ5rJ1Fi4JdbHBgVXTHjywfRsw2k0GgC9mbefixvwlliCNETQBRqjtI K2xD6FdmnbyJDmyvPfb+O2lwAm1FoE4b0BAbv9l5IAhi8F20h5lasjHSkCNajCc2KwUm CiCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:cc:content-language:content-transfer-encoding; bh=JOQ3PmaJtbdtPUYBzN8lYyLwqfEwyWGHTqG8SXs6IXQ=; b=HATUK3x3CjTkjMUACxuqhOQBb2Vs9N0x5Mm0u5YMjU+Qy5c3AlQWUvTpZGX2AqIXdH 5NViHIqycNlmSvs9hZHJBNIp3ZQcjQ0VuT1kvwBro2N9LnonP+F67wk+R4jETsFeX3+a 41GkBuEfzy60byN8/P3uwfk9HmS2/cqpZghzqt6LK4jKqXRwRNupydta2+CJX4p5xFQs YMa4pcRQnEOkSjRwCeaMRpd8aBc2eVu15GVOQYXa2UqPlht1pTrSF8sDrJHMOFBdlF/g 33fXbTA5VzKG9W0Kk+60AM31dKUqUybDcnd61/jezYTtEpBh1L85Fnca6mR3X8P6700o pjqA== X-Gm-Message-State: AOAM532QaaX8t4uogOZaoDumPwuS7ticFzn416mCwHA1dBq9G77HWSIU zreT56OyGVwl6t22GeOX62k= X-Received: by 2002:a37:996:: with SMTP id 144mr8982462qkj.247.1643146455014; Tue, 25 Jan 2022 13:34:15 -0800 (PST) Received: from [10.139.255.254] ([89.187.171.240]) by smtp.gmail.com with ESMTPSA id h21sm9484295qth.16.2022.01.25.13.34.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Jan 2022 13:34:14 -0800 (PST) Message-ID: <4df50e95-6173-4ed1-9d08-3c1c4abab23f@gmail.com> Date: Tue, 25 Jan 2022 16:34:12 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 From: Demi Marie Obenour Subject: [PATCH] SELinux: Always allow FIOCLEX and FIONCLEX To: Paul Moore , Stephen Smalley , Eric Paris Cc: Demi Marie Obenour , selinux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Demi Marie Obenour --- security/selinux/hooks.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 5b6895e4fc29..8f3b2f15c1f3 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3728,6 +3728,11 @@ static int selinux_file_ioctl(struct file *file, unsigned int cmd, error = file_has_perm(cred, file, FILE__GETATTR); break; + /* must always succeed */ + case FIOCLEX: + case FIONCLEX: + break; + case FS_IOC_SETFLAGS: case FS_IOC_SETVERSION: error = file_has_perm(cred, file, FILE__SETATTR); -- Sincerely, Demi Marie Obenour