Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp310184pxj; Thu, 20 May 2021 09:49:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/4CgGTg4ZgWYANJNdFgy+RsHhpLES22vesgywHjMeHZZAOH0izf+AU/pTjQWKMykdT3mR X-Received: by 2002:a17:906:b104:: with SMTP id u4mr5526064ejy.211.1621529383499; Thu, 20 May 2021 09:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621529383; cv=none; d=google.com; s=arc-20160816; b=Wrma98Fx8N5ckgUL6JUxXcuR3zRnVrNFw2cRbW6HWvTypYcXHLJm5YofHEK8sDi8jp 7ww2Zm/1aotYS3/Yg+kWnx54hJ+PTB0uVpww1IgbO0MTWzKVglNVGdJ6DvZpQEFuxX/C 67zsmI9KF6uEkLlBQWJGQJe71tXMrSX6bABziw9oWcabsadNbiyU43MXTy0NF1rXK4Zs t+oxzARFCY7u0o81ZPN677t1wPKxilw+r0rQktv7kqChbm+wN7DWCY9O89HOkShvmJWu GeNxDFQchAZ/tUwOUlY4U00MrRbUPJFnHNAelQbAZxZbALdjtnbjDyJEGnDoRm8Cj3TV 5QfA== 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=X1JKXHe1sq38vCsAhWvir188tZcnt3mADah/V1znEjI=; b=s2Et95CKHpO3FWQSFbqTx3vbyduB1aKl7DmIQvcNbYnvHZZNcwuEZ+N+NjA37qHSf9 JZ2xVVj7zLoW0QlLBblk1hu1qTencooLC/Zy1jEaGKJOb8+rmYXaqBZ9wxE05mU9PAiB qVRpxbBgWewGfeXPO3Niqvdng13pM2eiqN/H8DBJBydElQ2stZgKeW8Buyl8aDdMPJvl cnPDxe4fphadER10l82ob8seWmBax8auhiF8Kr2wZFu29wOqZFCXRORB7GzSnmJuqobk n6gOF6u6hgFjbVhvl3wHXGqrPgVeim/BRDq3GaUDVRsZSxrHZSGEdBdQHQJhV8+PfPva XgXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oop0ZLRh; 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 o6si511620edi.18.2021.05.20.09.49.19; Thu, 20 May 2021 09:49:43 -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=oop0ZLRh; 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 S234483AbhETJxE (ORCPT + 99 others); Thu, 20 May 2021 05:53:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:54308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233934AbhETJum (ORCPT ); Thu, 20 May 2021 05:50:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 60EED61584; Thu, 20 May 2021 09:35:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503329; bh=XV8Fr3CEUUJBnDnC3hM/ys1BvIbZDMIfM6Eq8qfQBRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oop0ZLRhg4cyr1HBNpuyPZyay3iImOzquidSCiFI4O0NGU3LvAkqqQNgZxRpAvMkt d+UTxX58MtIGmmmmU5RED0gouCoY4kYlCXepv4pMDjJBO68ZPKMCZBfUKTQ5Xrf/Hs 7UVNGzJQfyuc98ep8keEVHO0Dx9XJB4jBawJRNfk= 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.19 145/425] ipw2x00: potential buffer overflow in libipw_wx_set_encodeext() Date: Thu, 20 May 2021 11:18:34 +0200 Message-Id: <20210520092136.191746122@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 @@ -647,8 +647,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;