Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp544566pxj; Thu, 20 May 2021 15:50:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrqzFBjfUz08lrcgPo69lGmMd9HLTl4XshITETsxHWi+Xgn5UxQz/tID/V+lKNI+AtiLK1 X-Received: by 2002:a6b:3119:: with SMTP id j25mr7084718ioa.64.1621551029573; Thu, 20 May 2021 15:50:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621551029; cv=none; d=google.com; s=arc-20160816; b=oNw78aAxiLBP9ZiEmS9NF4+Ik8tFuxdSlSfyvskkl27cF30nyz+PGvOeJOZ6FzJzzV eg7yzre/gCfj5pYVM72XVG73Y3dRAONGLMpBn+wBYFhJ1ovPmzeI6Z29VvVQyeAq03rV 9Zvv33QsN/mOALyWvJR9gl9Ztw6YIVEEAy93JairDuS/wL6r/IS96/2Pg+lPVf/QKdPi Oiqt1e7yjfpVnW8lr6mFi0QIO9qgES4nY4zSt4xf1hyIzEZ0uzmfSY5Rw5vfQXFtWZny jPbx4uozhRKRuM84A2/5HVvq/kxn0a/XwhtbltjgRk946ifoyt93OVJtZglR/gh38l9Z E5Hw== 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=nkmJQuuH1LBtsxQeReEPrGR2sK69Q9v/si2PBf32OAoIJuJrR0s+++V/If5wHa04BQ UBSN1bB+XFNOIZyOiXPDiuZeX1pb8ei/72QAImWNViK0VKtTA68MJnOYhB3jnGjJR5mJ EnUgIdNVksX2HaX3k/f/csWPcbp6Mmmat8VX5/gD8WmaRsDxY6OM8bNoJNWDuJffxx1j fGG2SmeCW+rK2iGrtPvvJwLoy7rQuHd/J6K1+jqYDLzf60VuRsr01Du2s9HAil9Q7e3k ZpTxveYJhQ7aeygWBTbZz4z3/MnxmznP2qCu8+JgzoXXAbxL/QxXCkaKb8xr3UG5KGws gCCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UH2y62zs; 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 d5si3357830ioq.28.2021.05.20.15.50.16; Thu, 20 May 2021 15:50:29 -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=UH2y62zs; 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 S239174AbhETLLR (ORCPT + 99 others); Thu, 20 May 2021 07:11:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:50584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239030AbhETKus (ORCPT ); Thu, 20 May 2021 06:50:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0781961CD3; Thu, 20 May 2021 09:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504791; bh=QR5aBRGdFE0mJmURdhJkExodKp4G8vkyAhLsjs0tbTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UH2y62zslBepn+fSkXt5NETjTO90IgIVpWV6H51gA7tjucVFkM3KHpM+7yxd3+xp/ Etd4ItvbCINQXTmTmqiPYTOHwhFY/cWyrGqmf3CLv3zGsby2lHvkJkdPlbvp7y4fhd j+zVX0DN7RPGeGWKe/4hn+umb4y4B53GTAzqqHn4= 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.9 083/240] ipw2x00: potential buffer overflow in libipw_wx_set_encodeext() Date: Thu, 20 May 2021 11:21:15 +0200 Message-Id: <20210520092111.476594360@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092108.587553970@linuxfoundation.org> References: <20210520092108.587553970@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;