Message ID | 2851036.1679417029@warthog.procyon.org.uk |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1889389wrt; Tue, 21 Mar 2023 09:52:32 -0700 (PDT) X-Google-Smtp-Source: AK7set9OJjFX8k/cQXsyDIx046icCUTL09JRGVZnAbzOvblfIt+ysYNVc0NYaKnOTAg3+wZOXOIL X-Received: by 2002:a05:6a20:3aa7:b0:d9:9bc2:8904 with SMTP id d39-20020a056a203aa700b000d99bc28904mr2986948pzh.56.1679417551817; Tue, 21 Mar 2023 09:52:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679417551; cv=none; d=google.com; s=arc-20160816; b=y/h8QPNj1DZyAqSoq2BhhQg/HmGULKcYce6FKtyFDGwiqeiyvhahwiCx4aROfYoOfz lCAqWK4/z1aOW0mg8Pb4jn3+FpowBrm8d8UMTPGDHTZKWLtTBCNgMbqdL0VijVl9iic8 LlDo8npnKG2j9/WDHmYR5bwmd1SiXSGJ9zBHWnj/IzbGVvhjY3PbnpTHNraXj+Bo2cxY 3Zf3sQGRIIB1ldhdX5HAtQ36rzpgOvhOduQ18k9us3Xn/JHRI9RtsfVohsIilevhEZMI AHJ0E/sdKMJb+hcdx8+Z5cvgzlnqG4iKDC4aGAjakbkjPp15SHkWD3mKT5pPShNKqw7r 6zUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:from:organization :dkim-signature; bh=ni73P6iOwq/z06Tc9mCMwHkprsEWFzyatJbBnmGE7Q8=; b=qWWSFQpVSHLbHwXvZtOdT5n+36lPmlk1iGwSGT6m/SyviUz8LMg4CVviWUF0IOpyHO 9S3qh66UXByIGxayHEt97qzGyyEV4EN97aW3rDQGxUxPDDLiXzdz/Wd813wHDh/jhLEq hOi0WkCJXgvCqY5N+v0vUwAguKeiTiDuly4uX7v+89mqfoIDBKWy8koMG/H4jOCgHvpg pIW8CU3OkRDC0/2HmpixWlxJqYcx+DHzT3ryMeC4wUnsPWxGcaOmFxbOP5epDrN0t7RH f03x5RsOBoLKLIWf2tDSSXSuKqyQ+5Sg0ydZO09v0TWTnoeMO5KYAMGYprSHe/0jmbTH Vvcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eSiCHkXy; 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=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h9-20020a631209000000b0050bfa82c24asi13350511pgl.647.2023.03.21.09.52.18; Tue, 21 Mar 2023 09:52:31 -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=@redhat.com header.s=mimecast20190719 header.b=eSiCHkXy; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230218AbjCUQpG (ORCPT <rfc822;ezelljr.billy@gmail.com> + 99 others); Tue, 21 Mar 2023 12:45:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbjCUQo7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 21 Mar 2023 12:44:59 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C991D52915 for <linux-kernel@vger.kernel.org>; Tue, 21 Mar 2023 09:43:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679417036; 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; bh=ni73P6iOwq/z06Tc9mCMwHkprsEWFzyatJbBnmGE7Q8=; b=eSiCHkXywRbPi/zBf0KpWiWawDXlLIAqeLbT+YgAMObRPvKRNP6mpDUiv+Hj+/srK1M31P RBZx+OG3cxdK4DTAAzPzhqdRBgwT/vXzD34euHutOwMWwyj7GYQIfY9lLkrPsSYN/wyDoF KkAef+wOASy4GFo1ptChgUCwgSvpW0g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-462-qaZqdp-zNrahOBtwB2l9Lg-1; Tue, 21 Mar 2023 12:43:52 -0400 X-MC-Unique: qaZqdp-zNrahOBtwB2l9Lg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F6FC101A54F; Tue, 21 Mar 2023 16:43:52 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 637B3492C13; Tue, 21 Mar 2023 16:43:50 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells <dhowells@redhat.com> To: torvalds@linux-foundation.org cc: dhowells@redhat.com, Jarkko Sakkinen <jarkko@kernel.org>, Bharath SM <bharathsm@microsoft.com>, Shyam Prasad N <nspmangalore@gmail.com>, Steve French <smfrench@gmail.com>, Robbie Harwood <rharwood@redhat.com>, Eric Biederman <ebiederm@xmission.com>, Herbert Xu <herbert@gondor.apana.org.au>, keyrings@vger.kernel.org, linux-cifs@vger.kernel.org, linux-crypto@vger.kernel.org, kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [GIT PULL] keys: Miscellaneous fixes/changes MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2851035.1679417029.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Tue, 21 Mar 2023 16:43:49 +0000 Message-ID: <2851036.1679417029@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760996938598591421?= X-GMAIL-MSGID: =?utf-8?q?1760996938598591421?= |
Series |
[GIT,PULL] keys: Miscellaneous fixes/changes
|
|
Pull-request
git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git tags/keys-fixes-20230321Message
David Howells
March 21, 2023, 4:43 p.m. UTC
Hi Linus, Could you pull these fixes/changes for keyrings? (1) Fix request_key() so that it doesn't cache a looked up key on the current thread if that thread is a kernel thread. The cache is cleared during notify_resume - but that doesn't happen in kernel threads. This is causing cifs DNS keys to be un-invalidateable. (2) Fix a wrapper check in verify_pefile() to not round up the length. (3) Change asymmetric_keys code to log errors to make it easier for users to work out why failures occurred. Thanks, David --- The following changes since commit fc89d7fb499b0162e081f434d45e8d1b47e82ece: Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost (2023-03-13 10:43:09 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git tags/keys-fixes-20230321 for you to fetch changes up to 3584c1dbfffdabf8e3dc1dd25748bb38dd01cd43: asymmetric_keys: log on fatal failures in PE/pkcs7 (2023-03-21 16:23:56 +0000) ---------------------------------------------------------------- keyrings fixes ---------------------------------------------------------------- David Howells (1): keys: Do not cache key in task struct if key is requested from kernel thread Robbie Harwood (2): verify_pefile: relax wrapper length check asymmetric_keys: log on fatal failures in PE/pkcs7 crypto/asymmetric_keys/pkcs7_verify.c | 10 +++++----- crypto/asymmetric_keys/verify_pefile.c | 32 ++++++++++++++++++-------------- security/keys/request_key.c | 9 ++++++--- 3 files changed, 29 insertions(+), 22 deletions(-)
Comments
On Tue, Mar 21, 2023 at 9:43 AM David Howells <dhowells@redhat.com> wrote: > > (1) Fix request_key() so that it doesn't cache a looked up key on the > current thread if that thread is a kernel thread. The cache is > cleared during notify_resume - but that doesn't happen in kernel > threads. This is causing cifs DNS keys to be un-invalidateable. I've pulled this, but I'd like people to look a bit more at this. The issue with TIF_NOTIFY_RESUME is that it is only done on return to user space. And these days, PF_KTHREAD isn't the only case that never returns to user space. PF_IO_WORKER has the exact same behaviour. Now, to counteract this, as of this merge window (and marked for stable) IO threads do a fake "return to user mode" handling in io_run_task_work(), and so I think we're all good, but I'd like people to at least think about this. Linus
The pull request you sent on Tue, 21 Mar 2023 16:43:49 +0000:
> git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git tags/keys-fixes-20230321
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/2faac9a98f010cf5b342fa89ac489c4586364e6e
Thank you!
On 3/21/23 12:48?PM, Linus Torvalds wrote: > On Tue, Mar 21, 2023 at 9:43?AM David Howells <dhowells@redhat.com> wrote: >> >> (1) Fix request_key() so that it doesn't cache a looked up key on the >> current thread if that thread is a kernel thread. The cache is >> cleared during notify_resume - but that doesn't happen in kernel >> threads. This is causing cifs DNS keys to be un-invalidateable. > > I've pulled this, but I'd like people to look a bit more at this. > > The issue with TIF_NOTIFY_RESUME is that it is only done on return to > user space. > > And these days, PF_KTHREAD isn't the only case that never returns to > user space. PF_IO_WORKER has the exact same behaviour. > > Now, to counteract this, as of this merge window (and marked for > stable) IO threads do a fake "return to user mode" handling in > io_run_task_work(), and so I think we're all good, but I'd like people > to at least think about this. I haven't seen the patch yet as it hasn't been pushed, but can imagine what it looks like. It may make sense to add some debug check for PF_KTHREAD having TIF_NOTIFY_RESUME set, or task_work pending for that matter, as that is generally not workable without doing something to handle it explicitly. For PF_IO_WORKER, with the commit you mentioned, those threads should deal with TIF_NOTIFY_RESUME just fine. Until something else gets added that is also run from exit_to_user_mode...
On Tue, Mar 21, 2023 at 12:16 PM Jens Axboe <axboe@kernel.dk> wrote: > > I haven't seen the patch yet as it hasn't been pushed, Well, it went out a couple of minutes before your email, so it's out now. > It may make sense to add some debug check for > PF_KTHREAD having TIF_NOTIFY_RESUME set, or task_work pending for that > matter, as that is generally not workable without doing something to > handle it explicitly. Yeah, I guess we could have some generic check for that. I'm not sure where it would be. Scheduler? Linus
On 3/21/23 1:21?PM, Linus Torvalds wrote: > On Tue, Mar 21, 2023 at 12:16?PM Jens Axboe <axboe@kernel.dk> wrote: >> >> I haven't seen the patch yet as it hasn't been pushed, > > Well, it went out a couple of minutes before your email, so it's out now. Yep I see it now, looks as expected. >> It may make sense to add some debug check for >> PF_KTHREAD having TIF_NOTIFY_RESUME set, or task_work pending for that >> matter, as that is generally not workable without doing something to >> handle it explicitly. > > Yeah, I guess we could have some generic check for that. I'm not sure > where it would be. Scheduler? Off the top of my head, two options, both in kernel/sched/core.c: 1) Add it to schedule_debug() 2) Add it to sched_submit_work(), adding PF_KTHREAD to the flags checked for PF_IO_WORKER | PF_WQ_WORKER to avoid adding any extra fast-path overhead. Alternatively, I guess it could go in kthread_exit() as well. But for workloads with a persistent kthread that doesn't really go away, that won't catch it.