Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp743426ybl; Sat, 18 Jan 2020 09:56:35 -0800 (PST) X-Google-Smtp-Source: APXvYqwePi/zFzKJZrZUwPsuSUPzpyynSFkNQpEko9cFVJ9ucIKZoTMjI+OnsNtVUfGUM8IiPSQk X-Received: by 2002:a05:6830:1385:: with SMTP id d5mr10814076otq.61.1579370195353; Sat, 18 Jan 2020 09:56:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579370195; cv=none; d=google.com; s=arc-20160816; b=Ia9zf9T/aQMtCAz/2a6d581Oy5JPglqa+ZfHb3FbvB0vBPFM6jOrsuXRAfLNYR+LzP KYxPth7hJMEZ0/ILPerMQKVeEVJxG54k2Zxn7wOb8q5rneAJDxq1j6itypa5VpwmBQzk z0qcP9j9siLFZcFtj0rhxjK3St+LMDaXgb88CHg7BYRBULYnLmM/sggmvzXAAvn/Qi4c K+kbX4LUCkCG9pTnBLiRFKp4H+bDv52NAeXcEslAaDZMyRbFaK45q8LbkR2Ybr5cNTE+ F36LlJPrnKe8AOdjUGVPKTb7BL71TGznRS//5+H1z8oAv+4dz3+jVfZ4Op/TLJIS27n3 pa3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:dkim-signature; bh=pEs/hAf9fHDJfCs0wurYxBmVxR8fXaAeAsbgbfRzxlU=; b=UZNDvcrP3C0MTcaWyGDik5P4op8fothDl+gLMafYTX7udVudvTU601nlWtMMAkDfmQ x1f/KgVS/fyfHfpf3eiTb5XxFJjz/su+4P+wh+Y0EswGjBPRfKUfT0D0aQ8PlhIaLSTV OFqUBd6GTA0glfbmAhKK8wlOA7rB1NM6yTv1FYjj8XQ9Jn4i/9oMo6YcBgpqK4k3x/Ov LLhdqMv2Yb0zy6z1MhusR9q8t+az5WTdS2Xgh+oJwNG7Jy1Y1utC5cjoJHBlYFC9pKBk TEO3AXQ8AUaFpXSs0v86O5UKKV9G4WZ65oGCg6axgAGl8ccaMz3GWu6RZwsp2h40BBP+ MJiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=NNLdCDc2; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=NNLdCDc2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f21si17066898otp.56.2020.01.18.09.56.23; Sat, 18 Jan 2020 09:56:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=NNLdCDc2; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=NNLdCDc2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726674AbgARRza (ORCPT + 99 others); Sat, 18 Jan 2020 12:55:30 -0500 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:50724 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgARRz3 (ORCPT ); Sat, 18 Jan 2020 12:55:29 -0500 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 56C7A8EE2AB; Sat, 18 Jan 2020 09:55:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1579370129; bh=V4bj38Jmyfpffwm4ybT9rv/2Gr5czbyWSE4U0HdmjRM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=NNLdCDc2T/cCtpJyDzPAnpQ/xfjAxsLl7ksZ2EHRjNTkRm7CO2IKVxTzG+KKB8n92 lVViakNoqglFjc6Ozor7I+Ut98rYhpD5k/PrT+qc+Co3uWA/1JorGmktedxanZ11Py 1ZibMadZd0C26Xad+qfyOLipDUnYlMkxGzWHgS98= Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YHxP8T0xBaqT; Sat, 18 Jan 2020 09:55:29 -0800 (PST) Received: from jarvis.lan (unknown [50.35.76.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id B3D9F8EE17D; Sat, 18 Jan 2020 09:55:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1579370129; bh=V4bj38Jmyfpffwm4ybT9rv/2Gr5czbyWSE4U0HdmjRM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=NNLdCDc2T/cCtpJyDzPAnpQ/xfjAxsLl7ksZ2EHRjNTkRm7CO2IKVxTzG+KKB8n92 lVViakNoqglFjc6Ozor7I+Ut98rYhpD5k/PrT+qc+Co3uWA/1JorGmktedxanZ11Py 1ZibMadZd0C26Xad+qfyOLipDUnYlMkxGzWHgS98= Message-ID: <1579370126.3421.19.camel@HansenPartnership.com> Subject: Re: [RFC PATCH 2/2] dm-crypt: Use any key type which is registered From: James Bottomley To: Franck LENORMAND , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, keyrings@vger.kernel.org Cc: horia.geanta@nxp.com, silvano.dininno@nxp.com, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, dhowells@redhat.com, jmorris@namei.org, serge@hallyn.com Date: Sat, 18 Jan 2020 09:55:26 -0800 In-Reply-To: <1551456599-10603-3-git-send-email-franck.lenormand@nxp.com> References: <1551456599-10603-1-git-send-email-franck.lenormand@nxp.com> <1551456599-10603-3-git-send-email-franck.lenormand@nxp.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2019-03-01 at 17:09 +0100, Franck LENORMAND wrote: > @@ -2025,16 +2027,15 @@ static int crypt_set_keyring_key(struct > crypt_config *cc, const char *key_string > if (!key_desc || key_desc == key_string || !strlen(key_desc > + 1)) > return -EINVAL; > > - if (strncmp(key_string, "logon:", key_desc - key_string + 1) > && > - strncmp(key_string, "user:", key_desc - key_string + 1)) > - return -EINVAL; > + type = get_key_type(key_string, key_desc - key_string); > + if (!type) > + return -ENOENT; You can't do this. This check ensures that the key responds correctly to user_key_payload_locked() lower down. To do that, the payload has to be in a specific form. You ensured that yours are, but dm-crypt will now accept any key type, load the user payload blindly and create all sorts of mayhem in the kernel because of the structural differences in payload types. James