Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3719365pxv; Mon, 26 Jul 2021 10:10:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhTJ/OIvgcBvVI9T2R55315E/noTfnZLbxtcX0pJcr19okzX/nWRwbLwjDQBxD8EjqKfPp X-Received: by 2002:aa7:d998:: with SMTP id u24mr13722941eds.64.1627319440850; Mon, 26 Jul 2021 10:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627319440; cv=none; d=google.com; s=arc-20160816; b=jyISOvQXae1jZcWvaY6AUzq+9BFtgoJRey99DJaLY/CGai9VWFHgmm7h7wcn1kN8HL 5C1pwSsJCKQsGdusJSGPRORe5DCYGu2yTmC3tcNw0VxpE6TVEYQAuLxKgCQDbkr1V6YO nJQw/CBn59x+L+PwsamtMk9o6RzTZLOXjwMG2dIgULDyVlrUmnLnJPhBa5Yh4IQLDuCC Jfp/vRyCEwLb/zMliVJUh25lLCy+VgVhA8DmfjQuifWW6ETVw17ffimxH2325jortPh0 KH6Q2BEM06lunHweqybUEW+g5X473CBvo/yoiJWEkTn3U7rNvgo7C+hX892q1ROFiFVW t3xg== 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 :message-id:date:subject:cc:to:from; bh=IOy5IjugBTUbPIxGdIjO57faVpRAWXl9rs4XgFJVoSM=; b=fLu2axj/pe+IzNe7f0Y/gTq1rYShueb6X3jHynaAH93wwLPWLbOx0W/DpDGu+Bd/8b Ggr7RQhBde9Oa6pSZRbYiag/uSlhyi64DOF4M9Z5kpx2dPRi9pJIL26fM5ItMfaXUSd2 fyxeWwk5+mxF4C+s2kfEKHpMqi9lrplMmvmEzUNGPcHVeNGkYvBWyhPxSmaEBM1WAm2k uygQ/IQsfa4nx0nU1Suw3mDGIKPDdNgP2+2tgu9TT792bldKljmBUlxnZySatsqU9dZK tENw0yNAaG42HC1abn3yfdv0IKrHkZcdTDbTMoB/1OspRz7Umcr8SoMn0pNAUIWZZi9H E51g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q5si447062edh.492.2021.07.26.10.10.17; Mon, 26 Jul 2021 10:10:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241003AbhGZQXR (ORCPT + 99 others); Mon, 26 Jul 2021 12:23:17 -0400 Received: from h4.fbrelay.privateemail.com ([131.153.2.45]:51368 "EHLO h4.fbrelay.privateemail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240198AbhGZQVJ (ORCPT ); Mon, 26 Jul 2021 12:21:09 -0400 Received: from MTA-07-3.privateemail.com (mta-07-1.privateemail.com [198.54.122.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by h3.fbrelay.privateemail.com (Postfix) with ESMTPS id A69DE80AA7; Mon, 26 Jul 2021 13:01:36 -0400 (EDT) Received: from mta-07.privateemail.com (localhost [127.0.0.1]) by mta-07.privateemail.com (Postfix) with ESMTP id EC71618000A9; Mon, 26 Jul 2021 13:01:34 -0400 (EDT) Received: from localhost.localdomain (unknown [10.20.151.236]) by mta-07.privateemail.com (Postfix) with ESMTPA id 3DC9218000A7; Mon, 26 Jul 2021 13:01:33 -0400 (EDT) From: Jordy Zomer To: netdev@vger.kernel.org Cc: Greg Kroah-Hartman , Jordy Zomer , Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] crypto: ccm - avoid negative wrapping of integers Date: Mon, 26 Jul 2021 19:01:20 +0200 Message-Id: <20210726170120.410705-1-jordy@pwning.systems> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Set csize to unsigned int to avoid it from wrapping as a negative number (since format input sends an unsigned integer to this function). This would also result in undefined behavior in the left shift when msg len is checked, potentially resulting in a buffer overflow in the memcpy call. Signed-off-by: Jordy Zomer --- To address was corrected, and ccm was added to the topic to indicate that this is just for ccm. crypto/ccm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/ccm.c b/crypto/ccm.c index 6b815ece51c6..e14201edf9db 100644 --- a/crypto/ccm.c +++ b/crypto/ccm.c @@ -66,7 +66,7 @@ static inline struct crypto_ccm_req_priv_ctx *crypto_ccm_reqctx( return (void *)PTR_ALIGN((u8 *)aead_request_ctx(req), align + 1); } -static int set_msg_len(u8 *block, unsigned int msglen, int csize) +static int set_msg_len(u8 *block, unsigned int msglen, unsigned int csize) { __be32 data; -- 2.27.0