From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 454B4170A26 for ; Thu, 12 Jun 2025 20:38:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749760687; cv=none; b=qNLeMTe+1uT7OarIe3WsfwRVC+EO2rC1vnzVhifm4jxveE6im6jUWewKx4bKEbheAPz1WX9kx5h9SV+4cxoXZNf5wCfQQpsnkbvxop295xt1IXukZwsovVtih6GaKp55LJBovtKlfCngAV9LcSqbHmQToIdUBQoodJBdwYtPpf0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749760687; c=relaxed/simple; bh=SAU5o2DQ0CfgLin1S8tnE5huEGqu4f6AQhBXhQIQYLU=; h=From:In-Reply-To:References:To:Cc:Subject:MIME-Version: Content-Type:Date:Message-ID; b=a5hs3Ix8Q9UBFluPABZSVr5Kqz1eOTJxloLX4ZONHUVlmldnPb3taLfrmCn+6lytltCZnXOhYDdgbc28UMorXMOMY2l3Z603LAnqTlAn8hpjU6DXTPr2aWvsWSwNhRhLJgHSF0Jr+uUD+dj0e28XlVSAqAS7rPmrSbGZJe/oBvI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=jRybjXxv; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jRybjXxv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749760685; 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=Gj8SQGLLh0rljui6jnNkQMA92RjfoZpiblWpalJC6vA=; b=jRybjXxvPIdp4blIUWtIBTRMkTDklPh5+rmD5urSG4m9/yEcKk2QM6gZm7hKZq8bC+ivQh 2k7+nM0KxTTwnc5670X/4yessIN5T0ODhUl7t9QSWBat9hOEbGdlVE+/59HrcTOi/ibhtB dPdOjgUWiCtYKph8O7CfzFM2cSo97zE= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-yC1TTY1fOoaf_k-updd0AA-1; Thu, 12 Jun 2025 16:36:35 -0400 X-MC-Unique: yC1TTY1fOoaf_k-updd0AA-1 X-Mimecast-MFC-AGG-ID: yC1TTY1fOoaf_k-updd0AA_1749760593 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E95CE180AB15; Thu, 12 Jun 2025 20:36:29 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.18]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 84881195E340; Thu, 12 Jun 2025 20:36:19 +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 In-Reply-To: <2dc7318d6c74b27a49b4c64b513f3da13d980473.camel@HansenPartnership.com> References: <2dc7318d6c74b27a49b4c64b513f3da13d980473.camel@HansenPartnership.com> <462886.1749731810@warthog.procyon.org.uk> To: James Bottomley Cc: dhowells@redhat.com, keyrings@vger.kernel.org, Jarkko Sakkinen , Steve French , Chuck Lever , Mimi Zohar , Paulo Alcantara , Herbert Xu , Jeffrey Altman , hch@infradead.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-crypto@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC] Keyrings: How to make them more useful Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <473710.1749760578.1@warthog.procyon.org.uk> Date: Thu, 12 Jun 2025 21:36:18 +0100 Message-ID: <473711.1749760578@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 James Bottomley wrote: > One of the problems I keep tripping over is different special casing > for user keyrings (which are real struct key structures) and system > keyrings which are special values of the pointer in struct key *. It's meant to be like that. The trusted system keyrings are static within system_keyring.c and not so easily accessible by kernel modules for direct modification, bypassing the security checks. Obviously this is merely a bit of obscurity and enforcement isn't possible against kernel code that is determined to modify those keyrings or otherwise interfere in the verification process. > For examples of what this special handling does, just look at things > like bpf_trace.c:bpf_lookup_{user|system}_key > > Since the serial allocation code has a hard coded not less than 3 > (which looks for all the world like it was designed to mean the two > system keyring id's were never used as user serial numbers) That's just a coincidence. The <3 thing predates the advent of those system keyring magic pointers. > I think we could simply allow the two system keyring ids to be passed into > lookup_user_key() (which now might be a bit misnamed) and special case not > freeing it in put_key(). If you want to make lookup_user_key() provide access to specific keyrings like this, just use the next negative numbers - it's not like we're likely to run out soon. But I'd rather not let lookup_user_key() return pointers to these keyrings... David