Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp414072pxj; Thu, 20 May 2021 12:15:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxO7K1NVG3CeD9FBzqXgldYMjXMA8jdaD4J7RxPI4cD67gIUeNguNlfl9IfErQt0oHwNgm0 X-Received: by 2002:a50:a446:: with SMTP id v6mr6684512edb.254.1621538132727; Thu, 20 May 2021 12:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621538132; cv=none; d=google.com; s=arc-20160816; b=tMFIuQJzqwSy0iyLRTitWD5NeHo70qdSjOeRBT1utk1FYds4n2ZwmbUXGNiC+0xkgN /cBkRTGAOGJp25lZyfYC7HKlSNfXss6+bCUefve5uQ66C8uQZS6oS3bG69o0NMLHyJSb tOOJwDi9cdFgokZOAbyqy0edaZAEGYCHGElI7IJmep7Nvh51Q12Ky78UTtQ2nQ1jYz2R IcTd5pDMfy6TbWJVUxdXYqYwbqXHkkfPQP8e/TL8dqmRfx5dpFEmBETETwt/q8MER1HL b26Xq+QN9VGnlGGBjyFQ0w+/AU4xwDLXRFsH+Hx2jXcYhYpH811E0lVD5d4Ra6WY95BL y2wQ== 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=cR80gjHOdCkVKgLhaKS9SoBM3DW2dslmW15p1XIbyME=; b=MRrdt1pkbMbqY6nBgbM73IPtnSQg5q9OXuzuCJ1rIYaFfS3L8YATgZ6PnO4/bHAjBe n7WtnnZqbLwHp8716DGSfcHTUhTn6f7BaxOIZwqsk3hJJE68xE27S+rpZqyu/bZ5hSwX fiUrJBxFBsLVfyRhxQ9hZxYOGC9vISoUCW04Z6PjPqJ8ABrQyuXw7gXePkiBy4auF1nO yT4mMFJzJV/hCUapIqsPRSZsA3W9s7ncS6jrpzXMqYgs4mwoz5lyYwMrw+0UT9eYMjrT kBJgvNHVyZKHQySZjNIUKfykKLt34oLTK7N96A17nxNN2P69yKxQo1lh4bKDk6maK+4m 600g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BDHRGMhs; 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=pass (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 kv7si3168351ejc.678.2021.05.20.12.15.09; Thu, 20 May 2021 12:15:32 -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=@linuxfoundation.org header.s=korg header.b=BDHRGMhs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234343AbhETKjs (ORCPT + 99 others); Thu, 20 May 2021 06:39:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:53182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236864AbhETKYi (ORCPT ); Thu, 20 May 2021 06:24:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 310F161C19; Thu, 20 May 2021 09:49:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504175; bh=QR5aBRGdFE0mJmURdhJkExodKp4G8vkyAhLsjs0tbTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BDHRGMhsk4zA4vND6R1BFXtpHNQ9BRw9Dp/8287N1LzsRHDNgqRWJ/oLML/v7LbP0 tOZUtNfW/Y8jdygdK+UdWUgKrFmxDTRUEzCx1XEtO64ly4Lmn4wEdq2KHFz95BtB6q QNdDe8SALMaY31zn79cLqGH4rkUt48t4UIeO5w0o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Stanislav Yakovlev , Kalle Valo Subject: [PATCH 4.14 125/323] ipw2x00: potential buffer overflow in libipw_wx_set_encodeext() Date: Thu, 20 May 2021 11:20:17 +0200 Message-Id: <20210520092124.390078224@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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: Dan Carpenter commit 260a9ad9446723d4063ed802989758852809714d upstream. The "ext->key_len" is a u16 that comes from the user. If it's over SCM_KEY_LEN (32) that could lead to memory corruption. Fixes: e0d369d1d969 ("[PATCH] ieee82011: Added WE-18 support to default wireless extension handler") Cc: stable@vger.kernel.org Signed-off-by: Dan Carpenter Acked-by: Stanislav Yakovlev Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/YHaoA1i+8uT4ir4h@mwanda Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/intel/ipw2x00/libipw_wx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/net/wireless/intel/ipw2x00/libipw_wx.c +++ b/drivers/net/wireless/intel/ipw2x00/libipw_wx.c @@ -649,8 +649,10 @@ int libipw_wx_set_encodeext(struct libip } if (ext->alg != IW_ENCODE_ALG_NONE) { - memcpy(sec.keys[idx], ext->key, ext->key_len); - sec.key_sizes[idx] = ext->key_len; + int key_len = clamp_val(ext->key_len, 0, SCM_KEY_LEN); + + memcpy(sec.keys[idx], ext->key, key_len); + sec.key_sizes[idx] = key_len; sec.flags |= (1 << idx); if (ext->alg == IW_ENCODE_ALG_WEP) { sec.encode_alg[idx] = SEC_ALG_WEP;