Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4341079pxu; Mon, 12 Oct 2020 16:50:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeWrNECV/PlhDAsBz0uI4FAXV5Dhma+2MBrxcWl5I+zqt+lD8ZeXCDhm63JBRt7fJDAohH X-Received: by 2002:a50:e40b:: with SMTP id d11mr17055901edm.198.1602546658211; Mon, 12 Oct 2020 16:50:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602546658; cv=none; d=google.com; s=arc-20160816; b=endSdGTSrdjEEVzNhi0leNXU4EoVt61xll7wnlkBu0WnjCpfMts1+BsSK9AUHf73xV h3WUKdRX7DjXCh+LcUKDeb/FjKRiVxxtrgBPG/EAcq7Cozj+xtseccu4vUXeyQvpwVKi ycY3+bq3Y0lT4zqd6sCTEcVwwnb69JxWonfgWavxb3BtLo3U6Ca+spBpapoYA3MqulWg Dwoyr2vEmNvxHeo4RYvlnVN9S7sXs8GOqtBEoAagm85cTz3i8L1nz+3fU3GwvPGOwN6F ppAazsyN+FN/PJFTGpqyg/GDw6ouW/L4eNzeE6Y7v/P0hLW/GLuCiTQvEAhAySCPWpXP h/8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EHK6QqQHdhQFsTAERqFlSjQfLovenSzHw96YfIqOxPU=; b=WFkWnm7qy8mLMiL5R/yL6cw0ygVO2D3ZrN5lQ3Pd90LzNYGCQZ3pOEl0CvvXUFxosg jNsegJHf5n98eD5qECvS8YmOOaRKZn3ms7Tst7TIgXC2jDDXY6CbNwn8xy/hAMMTWvNO PUq8+5yNv68JJwrks6yuZywQwi10+46VJRsDtVThNi9roPEwXUHlV/J1MQfw/7L1V/v9 9dv6+MjvHoN+Tyaa3fhM1FVTEc8cjwmU8w7AZ7mB+LPaOUbH45I2WWWfzrZ28wtROl3n wobxLiLl1w2h/0P9q4gBr0dG9Y61SpmKzdVE6+k9RKuSzRQdRDEsk42pEVmmDxIzNL44 uC2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g8x7WZOG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id li15si13263192ejb.166.2020.10.12.16.50.22; Mon, 12 Oct 2020 16:50:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g8x7WZOG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389482AbgJLNoZ (ORCPT + 99 others); Mon, 12 Oct 2020 09:44:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:47038 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731561AbgJLNmy (ORCPT ); Mon, 12 Oct 2020 09:42:54 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2A4D2076E; Mon, 12 Oct 2020 13:42:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510171; bh=qdiCA891/AKho+tqEgtW7e7Hq0oe8jkjymgonMTJrmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g8x7WZOG3jg3CN6Q3DYX+Cag0H40uthBr2TU02QsgLSLo4xgYuTfdZE0waSYlLTxx jFro0hdLT3jtkn6lydBUN0Qw8aSaQ4N7zB/EHO5i+eaLLV4rhvOTpjtqZFUElIBKA2 NvERAxLq00mCziwJk+59nxTTIbQWcH2RruJ28ql4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Dionne , David Howells , Sasha Levin Subject: [PATCH 5.4 70/85] rxrpc: Fix rxkad token xdr encoding Date: Mon, 12 Oct 2020 15:27:33 +0200 Message-Id: <20201012132636.208494904@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132632.846779148@linuxfoundation.org> References: <20201012132632.846779148@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Dionne [ Upstream commit 56305118e05b2db8d0395bba640ac9a3aee92624 ] The session key should be encoded with just the 8 data bytes and no length; ENCODE_DATA precedes it with a 4 byte length, which confuses some existing tools that try to parse this format. Add an ENCODE_BYTES macro that does not include a length, and use it for the key. Also adjust the expected length. Note that commit 774521f353e1d ("rxrpc: Fix an assertion in rxrpc_read()") had fixed a BUG by changing the length rather than fixing the encoding. The original length was correct. Fixes: 99455153d067 ("RxRPC: Parse security index 5 keys (Kerberos 5)") Signed-off-by: Marc Dionne Signed-off-by: David Howells Signed-off-by: Sasha Levin --- net/rxrpc/key.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c index 0c98313dd7a8c..d77e89766406a 100644 --- a/net/rxrpc/key.c +++ b/net/rxrpc/key.c @@ -1073,7 +1073,7 @@ static long rxrpc_read(const struct key *key, switch (token->security_index) { case RXRPC_SECURITY_RXKAD: - toksize += 9 * 4; /* viceid, kvno, key*2 + len, begin, + toksize += 8 * 4; /* viceid, kvno, key*2, begin, * end, primary, tktlen */ toksize += RND(token->kad->ticket_len); break; @@ -1139,6 +1139,14 @@ static long rxrpc_read(const struct key *key, memcpy((u8 *)xdr + _l, &zero, 4 - (_l & 3)); \ xdr += (_l + 3) >> 2; \ } while(0) +#define ENCODE_BYTES(l, s) \ + do { \ + u32 _l = (l); \ + memcpy(xdr, (s), _l); \ + if (_l & 3) \ + memcpy((u8 *)xdr + _l, &zero, 4 - (_l & 3)); \ + xdr += (_l + 3) >> 2; \ + } while(0) #define ENCODE64(x) \ do { \ __be64 y = cpu_to_be64(x); \ @@ -1166,7 +1174,7 @@ static long rxrpc_read(const struct key *key, case RXRPC_SECURITY_RXKAD: ENCODE(token->kad->vice_id); ENCODE(token->kad->kvno); - ENCODE_DATA(8, token->kad->session_key); + ENCODE_BYTES(8, token->kad->session_key); ENCODE(token->kad->start); ENCODE(token->kad->expiry); ENCODE(token->kad->primary_flag); -- 2.25.1