Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4672964rwl; Mon, 10 Apr 2023 15:08:15 -0700 (PDT) X-Google-Smtp-Source: AKy350a7I9MxcmxtxDQBYzYSK/EPamgovPfp6JB0vGb6pp/8OgjcNdI7wbgg8g+r+6M6YMgjlfjk X-Received: by 2002:a17:906:a28c:b0:94a:514c:f1c8 with SMTP id i12-20020a170906a28c00b0094a514cf1c8mr6958185ejz.32.1681164495657; Mon, 10 Apr 2023 15:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681164495; cv=none; d=google.com; s=arc-20160816; b=r2c4pYik5pPSu8W9PMW73TLAZGwbY750fI4iYPHRvZ7eyIoouGCNirA5Zk6GtExrlS J3GryRHdw/dBZ1jOUPpPPxRJvOl8+BnBUUAVUhlNUOjHw0dj8xhWyDBaW+viA8E/eB+t SpnEZNBXrYoLJ2EiCDhamrc6zNbJg9GbCf5Z0n8NrgCFrk4CZqHAlNL21Y47dBCyG+xm Gwe9DuBpBGB1zAhs6JfR3TdKCsbXp842ank7k1BmAE2g/MPihGg7bwsUnReNAWYW5ArG siBc6tHmn+dK9oGo25kM5B47yLbs92Gzvw7NpnazFkNJJlqUtGAhkqO7GCvcZiej84XQ xtyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=bED5ulcYb93j7wfobicz3Hdy0GnTvYMsiawFSUzL6rc=; b=yFp8N/Ukq3GBhYDcWsSNSCcmESUe/RI8gmKTlzd2exCtvNnYGyIDhDTPekPCp+QnKu 0HsckjFeaWOz0TCO92/P6uBXa/gHv8fc+ZXbNZBevMsco9MyTMBPDO6vNzBCwUilPlan aR3GudNXOtbD8j/XMPVqm8LA0zZKs70s6yQcrnwsdLXFgZTAcMLgNUEqn1mV9zYOzMuC s7sMZuJ+WtspLuXWP23q768jARW92MaeIV+p2O2JiOfBk1qVxHxHyy8mIzAVg+a/NIyD gfVKSUMD6xRlzKk8T611O3y+tDutLHW/w/e4BkmfWG/9dKUn5MXDGrnZk4Xc5AUK9BY9 bZ9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=XzRGT16d; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vj8-20020a170907d48800b0094e0fab7708si441384ejc.927.2023.04.10.15.07.50; Mon, 10 Apr 2023 15:08:15 -0700 (PDT) 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 header.s=google header.b=XzRGT16d; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbjDJWBN (ORCPT + 99 others); Mon, 10 Apr 2023 18:01:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbjDJWBL (ORCPT ); Mon, 10 Apr 2023 18:01:11 -0400 Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A03A19B9 for ; Mon, 10 Apr 2023 15:01:10 -0700 (PDT) Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-54c17fa9ae8so223416347b3.5 for ; Mon, 10 Apr 2023 15:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1681164069; x=1683756069; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bED5ulcYb93j7wfobicz3Hdy0GnTvYMsiawFSUzL6rc=; b=XzRGT16d9rRlYCQG9GGVljhDILPR2ri+sbEeL1QSJb5nhg6MEtND6YxMfqgjkyCIDO lTtnDv4+ALmYDsiqFWYUBeYXMCQj5dfKhHcb7k+UhMIgAUxYCSSoZEzGSaWq+EKe6XEA eNzw/z/QMnyF+ory62D7Rk1lOdX096anN2YCtvH7H+4rV4z1b22lPX2C1fG2GwYHdFKz mYU87suz8C+zZaftzWv5lZX9b+pcHdWbOBm1mwcHR5LPsne3m7ADaTbmNZSjw4gOJKIt kYs0kSJYSHhqyJ/rJcTfz8Uu/OrdmX4b6xny3YfUKkTtk4bmtaFr8+00MKTY5T75NRPX pkRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681164069; x=1683756069; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bED5ulcYb93j7wfobicz3Hdy0GnTvYMsiawFSUzL6rc=; b=A9NTRjQ35BswKYFU6nnhYFkE81bxu0Kksu/Jvj7lBaaG9VoPVicfPlJyVa290uYKOE +b8Um58y3N7/qGEd/2KWa/I9zEzkXBDHLeiSgbbZCUMWr08+wxdFv+DQhs6zC2vSDcOa Rjmz8Ya0AhJj04xJ6mIdx1kwQEvK37OQJEOJd7VQ46qXRkWodwtMJ8tq347p8pqMafzV si68OdLKowboQYUjqxKm6prCNgC0Az2/fJKDzCPhwFJiSl8e9XiJhJvUfxo4XTDkibP9 7RxDXDbKEZQduQ4W2xtT39P+8YzvhNGYRZmxQNd7KxV+bZFXv5x4vmZtqdTPtmmXtL73 /zPQ== X-Gm-Message-State: AAQBX9cl7Mjxfo293tsiiJMJxA9MeTCcwyFUyqackHteIWhr53D0S2s6 p+PO43IgfQ+8rnVUggxio+nUWkyTeuBrAd+fWvLMpK5LTl/DJ+wvmA== X-Received: by 2002:a81:a744:0:b0:54f:69a4:151e with SMTP id e65-20020a81a744000000b0054f69a4151emr326196ywh.8.1681164069123; Mon, 10 Apr 2023 15:01:09 -0700 (PDT) MIME-Version: 1.0 References: <93ef5db7-fb4d-bf3f-9456-3fb6e7d5ca29@oracle.com> In-Reply-To: From: Paul Moore Date: Mon, 10 Apr 2023 18:00:58 -0400 Message-ID: Subject: Re: Semantics of blktrace with lockdown (integrity) enabled kernel. To: Junxiao Bi Cc: Konrad Rzeszutek Wilk , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, jmorris@namei.org, serge@hallyn.com, nathanl@linux.ibm.com, joe.jin@oracle.com, Eric , Boris Ostrovsky , axboe@kernel.dk Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Mon, Apr 10, 2023 at 5:52=E2=80=AFPM Junxiao Bi = wrote: > On 4/10/23 2:44 PM, Paul Moore wrote: > > On Mon, Apr 10, 2023 at 5:28=E2=80=AFPM Junxiao Bi wrote: > >> On 4/10/23 1:22 PM, Paul Moore wrote: > >>> On Mon, Apr 10, 2023 at 3:20=E2=80=AFPM Junxiao Bi wrote: > >>>> On 4/6/23 2:43 PM, Paul Moore wrote: > >>>>> On Thu, Apr 6, 2023 at 3:33=E2=80=AFPM Konrad Rzeszutek Wilk > >>>>> wrote: > >>>>>> On Thu, Apr 06, 2023 at 02:39:57PM -0400, Paul Moore wrote: > >>>>> ... > >>>>> > >>>>>>> Before we go any further, can you please verify that your issue i= s > >>>>>>> reproducible on a supported, upstream tree (preferably Linus')? > >>>>>> Yes. Very much so. > >>>>> Okay, in that case I suspect the issue is due to the somewhat limit= ed > >>>>> granularity in the lockdown LSM. While there are a number of > >>>>> different lockdown "levels", the reality is that the admin has to > >>>>> choose from either NONE, INTEGRITY, or CONFIDENTIALITY. Without > >>>>> digging to deep into the code path that you would be hitting, we ca= n > >>>>> see that TRACEFS is blocked by the CONFIDENTIALITY (and therefore > >>>>> INTEGRITY too) setting and DEBUGFS is blocked by the INTEGRITY > >>>>> setting. With DEBUGFS blocked by INTEGRITY, the only lockdown opti= on > >>>>> that would allow DEBUGFS is NONE. > >>>>> > >>>>> Without knowing too much about blktrace beyond the manpage, it look= s > >>>>> like it has the ability to trace/snoop on the block device operatio= ns > >>>>> so I don't think this is something we would want to allow in a > >>>>> "locked" system. > >>>> blktrace depends on tracepoint in block layer to trace io events of > >>>> block devices, > >>>> > >>>> through the test with mainline, those tracepoints were not blocked b= y > >>>> lockdown. > >>>> > >>>> If snoop block devices operations is a security concern in lock down= , these > >>>> > >>>> tracepoints should be disabled? > >>> Possibly, however, as I said earlier I'm not very familiar with > >>> blktrace and the associated tracepoints. If it is possible to snoop > >>> on kernel/user data using blktrace then it probably should be > >>> protected by a lockdown control point. > >>> > >>> Is this something you could verify and potentially submit a patch to = resolve? > >> blktrace can not snoop kernel/user data. The information it got from > >> kernel is kind of "io metadata", basically include which process from > >> which cpu, at what time, triggered what kind of IO events(issue, queue= , > >> complete etc.), to which disk, from which sector offset and how long. > >> blktrace has no way to know what's inside that io. I am kind of think > >> this is safe for lockdown mode. > > Well, you could always submit a patch* and we would review it like any > > other; that's usually a much better approach. > > > > * Yes, there was a patch submitted, but it was against a distro kernel > > that diverged significantly from the upstream kernel in the relevant > > areas. > > Sure, i will submit a new one. > > Before that, may i ask this question? It may affect the approach of the > patch. > > Lockdown blocked files with mmap operation even that files are > read-only, may i know what's the security concern there? > > static int debugfs_locked_down(struct inode *inode, > struct file *filp, > const struct file_operations *real_fops) > { > if ((inode->i_mode & 07777 & ~0444) =3D=3D 0 && > !(filp->f_mode & FMODE_WRITE) && > !real_fops->unlocked_ioctl && > !real_fops->compat_ioctl && > !real_fops->mmap) > return 0; > > if (security_locked_down(LOCKDOWN_DEBUGFS)) > return -EPERM; > > return 0; > } I think the comment block at the top of that function describes it well: /* * Only permit access to world-readable files when the kernel is locked dow= n. * We also need to exclude any file that has ways to write or alter it as r= oot * can bypass the permissions check. */ -- paul-moore.com