Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp388365pxk; Fri, 11 Sep 2020 09:34:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx133/ZHLsKgbPq1qKcV8SIo2+jQnW8oaR1ZqG8JMqAAFrz53ODIwqE1wGfvjYqOPKNwxh1 X-Received: by 2002:a17:906:2dc1:: with SMTP id h1mr2814164eji.436.1599842049340; Fri, 11 Sep 2020 09:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599842049; cv=none; d=google.com; s=arc-20160816; b=mDdbnRpa2MelDCqjL1IHOPLfMZQzGO3Bm8d/vKFW3Flmcwbqu82JV3FBxiQni3T4rJ Em6jLT5YmUlzrTeiPxSQqQ1zyamkXRimA3SzUehxDA0NNDw5MWLFA0CKJGebcwscK/6f 6sKyaBP08xJY0O2JDyjUHwEJyTtpb9VMqFnecU2LmwM2G33H4t/jm7WvT6ViSCMq/O94 6OIT6YzdKqJB0y8UtvEJpFq4rrlVone36VI3QQIaq6R7fUdtH2ImF15iuL2U66H2GAS7 Qi/fXGmMsFkCFLtYE0psIbFD49auyPlC43ybD/Wv8zBjVTWYfNW1eRU/mP1xKxjsLtV0 L2Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-filter; bh=rn2/11iyB80xjjWmB2FZpna0kZoGcD9AZ+z/2TAkwFE=; b=FD7SEklkvY2hmuNQREDXO43yyYF5c43NeBlVhFpqhAUejW725GeHbp0jv326f1co0s iyzQnkcKVHEx1gnzmRBC62Vh9vk6vRxt7g/Yah8ktXzTOpfKxOOLD287MNv/BOx1XEZW sUPmCqfmiaTo6jOEDteTnf1cSh/dn8gptDfcGjVpL5AR6+2H0/jv7DRexEEKbWBXIjYy ybJF++HV5KjZwnUCY6Cntv9Q/UrDdo6H4SmG3MT3VHUVdb/dfG4utnStZXAab07u0CuX PW9AcRfdis08EPV7Oh4ZLsODjuKOE4b6PPagSRCP/YwRZ68ex3cDeUrcneuVv95Hjr3Q d5GA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=omprussia.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qt23si1663718ejb.285.2020.09.11.09.33.45; Fri, 11 Sep 2020 09:34:09 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=omprussia.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726658AbgIKQdC (ORCPT + 99 others); Fri, 11 Sep 2020 12:33:02 -0400 Received: from mxout04.lancloud.ru ([89.108.124.63]:53730 "EHLO mxout04.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbgIKQcz (ORCPT ); Fri, 11 Sep 2020 12:32:55 -0400 X-Greylist: delayed 4420 seconds by postgrey-1.27 at vger.kernel.org; Fri, 11 Sep 2020 12:32:52 EDT Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout04.lancloud.ru 27D1B20A0DEC Received: from LanCloud Received: from LanCloud Subject: Re: [RFC PATCH v9 0/3] Add introspect_access(2) (was O_MAYEXEC) To: Matthew Wilcox , Al Viro CC: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= , Mimi Zohar , , Aleksa Sarai , Alexei Starovoitov , Andrew Morton , Andy Lutomirski , Arnd Bergmann , Casey Schaufler , Christian Brauner , Christian Heimes , Daniel Borkmann , Deven Bowers , Dmitry Vyukov , Eric Biggers , Eric Chiang , Florian Weimer , James Morris , Jan Kara , Jann Horn , Jonathan Corbet , Kees Cook , Lakshmi Ramasubramanian , Matthew Garrett , Michael Kerrisk , Miklos Szeredi , =?UTF-8?Q?Philippe_Tr=c3=a9buchet?= , Scott Shell , Sean Christopherson , Shuah Khan , Steve Dower , Steve Grubb , Tetsuo Handa , Thibaut Sautereau , Vincent Strubel , , , , , References: <20200910164612.114215-1-mic@digikod.net> <20200910170424.GU6583@casper.infradead.org> <880bb4ee-89a2-b9b0-747b-0f779ceda995@digikod.net> <20200910184033.GX6583@casper.infradead.org> <20200910200010.GF1236603@ZenIV.linux.org.uk> <20200910200543.GY6583@casper.infradead.org> From: Igor Zhbanov Message-ID: Date: Fri, 11 Sep 2020 17:15:10 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200910200543.GY6583@casper.infradead.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: ru-RU Content-Transfer-Encoding: 8bit X-Originating-IP: [89.179.245.198] X-ClientProxiedBy: LFEXT01.lancloud.ru (fd00:f066::141) To LFEX15.lancloud.ru (fd00:f066::45) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10.09.2020 23:05, Matthew Wilcox wrote: > On Thu, Sep 10, 2020 at 09:00:10PM +0100, Al Viro wrote: >> On Thu, Sep 10, 2020 at 07:40:33PM +0100, Matthew Wilcox wrote: >>> On Thu, Sep 10, 2020 at 08:38:21PM +0200, Mickaël Salaün wrote: >>>> There is also the use case of noexec mounts and file permissions. From >>>> user space point of view, it doesn't matter which kernel component is in >>>> charge of defining the policy. The syscall should then not be tied with >>>> a verification/integrity/signature/appraisal vocabulary, but simply an >>>> access control one. >>> >>> permission()? >> >> int lsm(int fd, const char *how, char *error, int size); >> >> Seriously, this is "ask LSM to apply special policy to file"; let's >> _not_ mess with flags, etc. for that; give it decent bandwidth >> and since it's completely opaque for the rest of the kernel, >> just a pass a string to be parsed by LSM as it sees fit. > > Hang on, it does have some things which aren't BD^W^WLSM. It lets > the interpreter honour the mount -o noexec option. I presume it's > not easily defeated by > cat /home/salaun/bin/bad.pl | perl - Hi! It could be bypassed this way. There are several ways of executing some script: 1) /unsigned.sh (Already handled by IMA) 2) bash /unsigned.sh (Not handled. Works even with "-o noexec" mount) 3) bash < /unsigned.sh (Not handled. Works even with "-o noexec" mount) 4) cat /unsigned.sh | bash (Not handled. Works even with "-o noexec" mount) AFAIK, the proposed syscall solves #2 and may be #3. As for #4 in security critical environments there should be system-wide options to disable interpreting scripts from the standard input. I suppose, executing commands from the stdin is a rare case, and could be avoided entirely in security critical environments. And yes, some help from the interpreters is needed for that. As for the usage of the system call, I have a proposal to extend its usage to validate systemd unit files. Because a unit file could specify what UID to use for a service, also it contains ExecStartPre which is actually a script and is running as root (for the system session services). For the syscall name it could be: - trusted_file() - trusted_file_content() - valid_file() - file_integrity() because what we are checking here is the file content integrity (IMA) and may be file permissions/attrs integrity (EVM).