Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7619659rdb; Thu, 4 Jan 2024 02:14:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbKRDLi5WeYJgVm87/c6Dy3G9poTNAc6HYOqUpXKYGCu+q6F8/8Bzuv2JMaYVlgSj8PN2l X-Received: by 2002:a17:906:6b0a:b0:a28:d438:ad07 with SMTP id q10-20020a1709066b0a00b00a28d438ad07mr106165ejr.90.1704363279566; Thu, 04 Jan 2024 02:14:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704363279; cv=none; d=google.com; s=arc-20160816; b=Ey/UDmhUV6iLFBKCw4KGqIaBL/6BO0RK4JXoxdXptS/rLsyvKZNpNEkZiahBLq/dLd 5VnsLdBpRXpAascCmDQF0tBx/J3OMDRu49j/EVUWyQR6NAFJCmN7HvvSh6bC5g/N6AzD tm3FRJqG7AHoGjsyi9X7lHq7nCnY4WkCJYwH+b8LM/LFr8E6Wyg9PnFvSndAYS29WoTz bUBfnwKTLO45RmvBdYFPu7CHbm5Gs4e2GhUEREnAKVnGMaq4VJXb/iU3wId0kgY6xu5/ 4RAwvGrBxwm/6nrWJKblBb2Q/383axyi8CTuLkP4r4Hzw9pz6pgLXc/334tWfQX27AfN dX6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=PWIZgkdEOSVSvpSxZ+udYcnfwuRlZRM5xhaqenz67Qg=; fh=NWiF+v/jRCpL+FvLFY2x45SC/B83lZQahAO+m9dv1gw=; b=mbrVT8QXkWBpHpXZ7JDVK15ymo9q4GRmH5UB3XW6TOj0F0rusuQks6Cc4y2Pd46m5P 8W3RoXvcsqgdXXxs9kGcbf+z0JE2wuZBjrBloTAvOzLpjzagVpLr4vL+XBcA2TlzNek6 sc8t0GmsaHYl5hdPwVxJFIp8QONl3wMg4ZA+uj4iguQSD5e7a0E5IXfBG5+L357EH68c yWQNXsaZknIHYJOWTDsZUbBxB63PpypOdWH9hhgjE7xO3qU6uUiPxUAAqubJvxDV55yg 5nA9RLzpLgBleBJZ+xFFb5aw1DNuCPITLlpKfuh7WxCE9gOkvm/Z4IfcxhhKQfmYuxXi SlqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Dhbugndx; spf=pass (google.com: domain of linux-kernel+bounces-16495-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16495-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id rs25-20020a170907037900b00a28b7fc45casi827761ejb.897.2024.01.04.02.14.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 02:14:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16495-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Dhbugndx; spf=pass (google.com: domain of linux-kernel+bounces-16495-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16495-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2338A1F25022 for ; Thu, 4 Jan 2024 10:14:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 255AD20B26; Thu, 4 Jan 2024 10:14:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Dhbugndx" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B940B20B0B for ; Thu, 4 Jan 2024 10:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704363266; 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:autocrypt:autocrypt; bh=PWIZgkdEOSVSvpSxZ+udYcnfwuRlZRM5xhaqenz67Qg=; b=DhbugndxdKMRR+6MzJd1ju6paXGI5R9sSYGkllM2DztgsXQ/4AOU4HhNruCQtQG+8GEY80 THyOi0LSdtouMV6GeGs/g99PcoB6H7VyovhfJCwIwYPM2CdOpKSmehGEo260AUOJmiimq4 7ixpjjJIt/YNRuecGd2xw3A2f39XZr4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-98-l3towWsLNQ2R-GPqFO4umA-1; Thu, 04 Jan 2024 05:14:23 -0500 X-MC-Unique: l3towWsLNQ2R-GPqFO4umA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 97A578350E1; Thu, 4 Jan 2024 10:14:22 +0000 (UTC) Received: from [10.39.208.29] (unknown [10.39.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D0C92492BC6; Thu, 4 Jan 2024 10:14:18 +0000 (UTC) Message-ID: <89b2e124-a570-4bea-874b-d60e2d3cbf5a@redhat.com> Date: Thu, 4 Jan 2024 11:14:16 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 4/4] vduse: Add LSM hook to check Virtio device type Content-Language: en-US To: Stephen Smalley , Ondrej Mosnacek Cc: mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, 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, casey@schaufler-ca.com References: <20231212131712.1816324-1-maxime.coquelin@redhat.com> <20231212131712.1816324-5-maxime.coquelin@redhat.com> From: Maxime Coquelin Autocrypt: addr=maxime.coquelin@redhat.com; keydata= xsFNBFOEQQIBEADjNLYZZqghYuWv1nlLisptPJp+TSxE/KuP7x47e1Gr5/oMDJ1OKNG8rlNg kLgBQUki3voWhUbMb69ybqdMUHOl21DGCj0BTU3lXwapYXOAnsh8q6RRM+deUpasyT+Jvf3a gU35dgZcomRh5HPmKMU4KfeA38cVUebsFec1HuJAWzOb/UdtQkYyZR4rbzw8SbsOemtMt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XtVMUPuae/+UwvIt0urk1mXi6DnrAN50TmQqvdjcPTQ6uoZ8zjgGeASZg jj0/bJGhgUr9U7oG7Hh2F8vzpOqZrdd65MRkxmc7bWj1k81tOU2woR/Gy8xLzi0k0KUa8ueB iYOcZcIGTcs9CssVwQjYaXRoeT65LJnTxYZif2pfNxfINFzCGw42s3EtZFteczClKcVSJ1+L +QUY/J24x0/ocQX/M1PwtZbB4c/2Pg/t5FS+s6UB1Ce08xsJDcwyOPIH6O3tccZuriHgvqKP yKz/Ble76+NFlTK1mpUlfM7PVhD5XzrDUEHWRTeTJSvJ8TIPL4uyfzhjHhlkCU0mw7Pscyxn DE8G0UYMEaNgaZap8dcGMYH/96EfE5s/nTX0M6MXV0yots7U2BDb4soLCxLOJz4tAFDtNFtA wLBhXRSvWhdBJZiig/9CG3dXmKfi2H+wdUCSvEFHRpgo7GK8/Kh3vGhgKmnnxhl8ACBaGy9n fxjSxjSO6rj4/MeenmlJw1yebzkX8ZmaSi8BHe+n6jTGEFNrbiOdWpJgc5yHIZZnwXaW54QT UhhSjDL1rV2B4F28w30jYmlRmm2RdN7iCZfbyP3dvFQTzQ4ySquuPkIGcOOHrvZzxbRjzMx1 Mwqu3GQ= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 On 12/18/23 18:33, Stephen Smalley wrote: > On Mon, Dec 18, 2023 at 12:21 PM Stephen Smalley > wrote: >> >> On Tue, Dec 12, 2023 at 8:17 AM Maxime Coquelin >> wrote: >>> >>> This patch introduces a LSM hook for devices creation, >>> destruction (ioctl()) and opening (open()) operations, >>> checking the application is allowed to perform these >>> operations for the Virtio device type. >> >> Can you explain why the existing LSM hooks and SELinux implementation >> are not sufficient? We already control the ability to open device >> nodes via selinux_inode_permission() and selinux_file_open(), and can >> support fine-grained per-cmd ioctl checking via selinux_file_ioctl(). >> And it should already be possible to label these nodes distinctly >> through existing mechanisms (file_contexts if udev-created/labeled, >> genfs_contexts if kernel-created). What exactly can't you do today >> that this hook enables? > > (added Ondrej to the distribution; IMHO we should swap him into > MAINTAINERS in place of Eric Paris since Eric has long-since moved on > from SELinux and Ondrej serves in that capacity these days) > > Other items to consider: > - If vduse devices are created using anonymous inodes, then SELinux > grew a general facility for labeling and controlling the creation of > those via selinux_inode_init_security_anon(). > - You can encode information about the device into its SELinux type > that then allows you to distinguish things like net vs block based on > the device's SELinux security context rather than encoding that in the > permission bits. Got it, that seems indeed more appropriate than using persmission bits for the device type. > - If you truly need new LSM hooks (which you need to prove first), > then you should pass some usable information about the object in > question to allow SELinux to find a security context for it. Like an > inode associated with the device, for example. Ok. > Thanks for the insights, I'll try and see if I can follow your recommendations in a dedicated series. Maxime