Received: by 2002:ac8:6216:0:b0:41c:c224:f26f with SMTP id ks22csp76920qtb; Thu, 2 Nov 2023 12:02:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGf3ZN257GvL+CPc4oG3BCE9Dt6mIkhMCpUZxxiUt62Q3lwaJQJxMRsnefRifh6EUSEhmB0 X-Received: by 2002:a17:902:f7cb:b0:1bd:e258:a256 with SMTP id h11-20020a170902f7cb00b001bde258a256mr705821plw.32.1698951723273; Thu, 02 Nov 2023 12:02:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698951723; cv=none; d=google.com; s=arc-20160816; b=IyiCVyvf2FX59cGr1krliZpnCzIFJd+ROX4n2GYHcDXXNOP1jKcKQqA3jHIM02nhOv KqgWAlFf4F+7XBPZrmgB1E9Eg0JxPOv+76ogGIaVVfdy9z3S58zQ7FzqYH8XyWYK83vV ZiWHWW8ZvRGhpUrLtyaDYFjWIddifaW6pbMGoxbd36R6XKqdU+okr9jppYkSSj3Z/BRP b+WtCyEpx9WM5P00wEeRZyhOzGPu08wH6znXpJXnj26rtxNJ/QmgMSWgeeALYfzCcBBt urv/3RjyGwRRev2443thCLY58frjr955vGcTb4sJl+VdamsmChUN6U5e1rxKmd/vVyws BEmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GEm2sns0/+Gc/wAqvpwT2aL5eohIrGGeBjAVrS1qrIg=; fh=6Cbyn49NVdxHfmni1sX+95M9op1OaowVFNpzfQbDR/o=; b=blm1jMjgZe9NaAfYf8Q3XpagfRpgFSSw8y+sfPc3vES+az/N6Acydh5NR4yEbM+0Q+ 9tAukoDt1NWUbtdaO1SXRGBukBvfa2G51hb9OIARNuWTjc8k+H0fnI5lvboz8glyPwKN iAuYqKs4ixBuH8/uiH4o/SMO6/aWEOqOX+h7gbiYS9QelhB6k16hQvzbjg5ACfpHok8I 2ZrxhlBaMp+WZgMjePU2KCw4313jW6t8wv4XuCRHL8Yu+XjgP4b+EGXMYatWA81tLNe1 47eXrMwPYW65LvgVQ2jAd159NbztCONktK6XoFK1hbW1nUHCOAvZz9wCY0GGzDIptcTN 34Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="RKT24J/Y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id q4-20020a170902c9c400b001cc23d2bb92si105369pld.650.2023.11.02.12.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 12:02:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="RKT24J/Y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1AFFA822743B; Thu, 2 Nov 2023 12:01:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377450AbjKBTBO (ORCPT + 99 others); Thu, 2 Nov 2023 15:01:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234450AbjKBTAz (ORCPT ); Thu, 2 Nov 2023 15:00:55 -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 C2431136 for ; Thu, 2 Nov 2023 12:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698951603; 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: in-reply-to:in-reply-to:references:references; bh=GEm2sns0/+Gc/wAqvpwT2aL5eohIrGGeBjAVrS1qrIg=; b=RKT24J/YA8tgkmRA5P+QKii9K51KwpNUdtRbpCykQXwQo180fb62meU2S0MC9PiqT8Qeh+ 63xD6qgPgF0jF6NDzA1pkCHWfO2LwN4lGBKYWPUx+iXxIPYQNdwj1y/wlgC/gCIHfe/ggc pgiN5KuljTd6iShl/hlLJgtGryykldU= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-145-qQusuTHxM-iWiJrtw1honw-1; Thu, 02 Nov 2023 14:59:54 -0400 X-MC-Unique: qQusuTHxM-iWiJrtw1honw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4084d08235fso7998385e9.3 for ; Thu, 02 Nov 2023 11:59:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698951594; x=1699556394; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=GEm2sns0/+Gc/wAqvpwT2aL5eohIrGGeBjAVrS1qrIg=; b=TSP3POq3SHIr2O/ALSTNQHKnquqQAHyVJckD1rajWkqLV3u6xLlYu8fCaFT+OVnDKd Vv6U9/m+ksAX7moo/fknEXagIpPffrnjUrr1HxMJkB1PRxnsNb9hOPY9aTBF0jwOv2KS mEdQVlUEA22lxupSPzEYsQvbAIL6hyme30HbIgf9QqBiS0u1fTec1b6/55gAp+/B5Y6A AbHTokJcFTRFel0g6joEnU/DnCJuOkZplb05rnWzSeto4rNmwti6cCJNYm7y2/zVjac5 jsju2PC8oynnkQdRaK2yOnJ47URPuGaFakvlCrQWJ09XZUAgAI/jfPbUrPTnholCFzV5 zZJw== X-Gm-Message-State: AOJu0YzPt3hA01NtTw51y1598/9mcWOu0wf43gWN2OzP2M9UkSlLFUcQ yFyR21VNuyJR1TeKOruUoC5ufRRyTAgmtENQEOVg+bsWg4XDt/NjJ+Mz8njlUyDgFsMMNDXgSzy ejCtCWO4O7YdfyESfT72LgnoG X-Received: by 2002:a05:600c:354c:b0:408:4cf7:4f91 with SMTP id i12-20020a05600c354c00b004084cf74f91mr16063506wmq.16.1698951593781; Thu, 02 Nov 2023 11:59:53 -0700 (PDT) X-Received: by 2002:a05:600c:354c:b0:408:4cf7:4f91 with SMTP id i12-20020a05600c354c00b004084cf74f91mr16063485wmq.16.1698951593366; Thu, 02 Nov 2023 11:59:53 -0700 (PDT) Received: from redhat.com ([2a02:14f:174:efc3:a5be:5586:34a6:1108]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c19d100b00405c7591b09sm31517wmq.35.2023.11.02.11.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 11:59:52 -0700 (PDT) Date: Thu, 2 Nov 2023 14:59:46 -0400 From: "Michael S. Tsirkin" To: Maxime Coquelin Cc: Casey Schaufler , jasowang@redhat.com, xuanzhuo@linux.alibaba.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, stephen.smalley.work@gmail.com, eparis@parisplace.org, xieyongji@bytedance.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, david.marchand@redhat.com, lulu@redhat.com Subject: Re: [PATCH v4 4/4] vduse: Add LSM hooks to check Virtio device type Message-ID: <20231102145932-mutt-send-email-mst@kernel.org> References: <20231020155819.24000-1-maxime.coquelin@redhat.com> <20231020155819.24000-5-maxime.coquelin@redhat.com> <923f87a1-1871-479e-832e-db67b5ae87fd@redhat.com> <64626db9-e37a-4c65-a455-fc3985382216@schaufler-ca.com> <7524dee3-7c48-4864-8182-1b166b0f6faa@redhat.com> <76572500-5f90-46fe-9bf2-b090bf1b616b@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <76572500-5f90-46fe-9bf2-b090bf1b616b@redhat.com> X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 02 Nov 2023 12:01:45 -0700 (PDT) On Thu, Nov 02, 2023 at 06:56:59PM +0100, Maxime Coquelin wrote: > > > On 10/24/23 17:30, Casey Schaufler wrote: > > On 10/24/2023 2:49 AM, Maxime Coquelin wrote: > > > > > > > > > On 10/23/23 17:13, Casey Schaufler wrote: > > > > On 10/23/2023 12:28 AM, Maxime Coquelin wrote: > > > > > > > > > > > > > > > On 10/21/23 00:20, Casey Schaufler wrote: > > > > > > On 10/20/2023 8:58 AM, Maxime Coquelin wrote: > > > > > > > This patch introduces LSM hooks for devices creation, > > > > > > > destruction and opening operations, checking the > > > > > > > application is allowed to perform these operations for > > > > > > > the Virtio device type. > > > > > > > > > > > > Why do you think that there needs to be a special LSM check for virtio > > > > > > devices? What can't existing device attributes be used? > > > > > > > > > > Michael asked for a way for SELinux to allow/prevent the creation of > > > > > some types of devices [0]. > > > > > > > > > > A device is created using ioctl() on VDUSE control chardev. Its type is > > > > > specified via a field in the structure passed in argument. > > > > > > > > > > I didn't see other way than adding dedicated LSM hooks to achieve this, > > > > > but it is possible that their is a better way to do it? > > > > > > > > At the very least the hook should be made more general, and I'd have to > > > > see a proposal before commenting on that. security_dev_destroy(dev) > > > > might > > > > be a better approach. If there's reason to control destruction of vduse > > > > devices it's reasonable to assume that there are other devices with the > > > > same or similar properties. > > > > > > VDUSE is different from other devices as the device is actually > > > implemented by the user-space application, so this is very specific in > > > my opinion. > > > > This is hardly unique. If you're implementing the device > > in user-space you may well be able to implement the desired > > controls there. > > > > > > > > > > > > > Since SELinux is your target use case, can you explain why you can't > > > > create SELinux policy to enforce the restrictions you're after? I > > > > believe > > > > (but can be proven wrong, of course) that SELinux has mechanism for > > > > dealing > > > > with controls on ioctls. > > > > > > > > > > I am not aware of such mechanism to deal with ioctl(), if you have a > > > pointer that would be welcome. > > > > security/selinux/hooks.c > > We might be able to extend selinux_file_ioctl(), but that will only > covers the ioctl for the control file, this patch also adds hook for the > device file opening that would need dedicated hook as the device type > information is stored in the device's private data. > > Michael, before going further, I would be interested in your feedback. > Was this patch what you had in mind when requesting for a way to > allow/deny devices types for a given application? > > Regards, > Maxime Yes, this is more or less what I had in mind. > > > > > > > > Thanks, > > > Maxime > > > > > > > > > > > > > > > > > Thanks, > > > > > Maxime > > > > > > > > > > [0]: > > > > > https://lore.kernel.org/all/20230829130430-mutt-send-email-mst@kernel.org/ > > > > > > > > > > > > > > > > > > >