Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp62518pxj; Thu, 20 May 2021 04:37:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0yOipsMlVxw6zPmu5nKDwrkvYkzvB7AuncvtJCAuhYga629jGTpMJ+FxgMoCGwh+DNyKP X-Received: by 2002:a17:906:a0a:: with SMTP id w10mr4212641ejf.416.1621510673967; Thu, 20 May 2021 04:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621510673; cv=none; d=google.com; s=arc-20160816; b=EWhk3MvljrDyoVkv9V84rLz3JP/7OgyH3MohWajiSQDdbBX1ehqvFp2c3Mg8A5calx zPPoKmXfaaLFavTxOiUVF+zoEAyVmRNW1m1QK5Ym2XMWpo4EmoOZ2gdhClObIzZuovO4 V3jv6IufxhZ20VRh5w5RjjRDgBtxZcW5xJlrc3j4SYeYFRq/rzOtfslYgLajq4g8OeV8 Xl5FPBDZh593nwiK1gixwdE7g/SDmovuUxMG/S6F3i5+DmiZnguqr2vPobDTw0sYiiFn 9QBkri7XxVGfffL7edI/3W1NnceH7dnOzoY90We7q+g/FthnLSCWJrFZvG2WoRsFOyFQ +Peg== 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=sjI5sc33tGHJQZ2Tt6zZSM1tu/Of+PcIwwVS8s2HKas=; b=GGOcYutl0pTLe1MNpvsAj77yCu5fH+KiusR5fPcWmgPrpVMIWv92bn/pXxhCIBOouK ycBziuwLFFmQmTW4ZOSFUfvibHlQiXd1aJzaHdlu0Q/c4BgOgS+VvTgP7qW8mWLG2794 sfljpPM2xp/ZDSRC/RZcsOI4Oh3SnVBghNxSRbSBS2+NFmIM1977UH1efdccdb2PIkds K/pLHyoBQyoWHamk95svdjy3PfdESkdyWSkh7VmoOuz1qc5Rn/rl6Zq7ZNK1HZ59hrzw NRiejXlKAI0BkakGYM8D+5/95x5d1qwa9L6bwKEaGr5gur4qIbG6IdboLd78HaoB9Fqw m3Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gRlIxOQo; 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 s25si2272783eju.101.2021.05.20.04.37.30; Thu, 20 May 2021 04:37:53 -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=gRlIxOQo; 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 S241897AbhETLeI (ORCPT + 99 others); Thu, 20 May 2021 07:34:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:55230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240021AbhETLNU (ORCPT ); Thu, 20 May 2021 07:13:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E28C361428; Thu, 20 May 2021 10:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505291; bh=CBe8NfCfielCR3DjqOZoEgmyEEGmR6WIYQD7l/nh8mI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gRlIxOQoHCbt+POcokPbJmheUKUDguKuddxIEkOA1szAWpbLefYpaRcvgYLBZnvax fL1a1bSqDbm5+kUgIzzMvpfg8GnOdWcOQOyzSIo4d+hZfqjfeUOoUDwfOVBFIVrgW6 n/PpynxS4zU/iUExDkiG+R4P7oLar7ZT/JGM7Iik= 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.4 067/190] ipw2x00: potential buffer overflow in libipw_wx_set_encodeext() Date: Thu, 20 May 2021 11:22:11 +0200 Message-Id: <20210520092104.391396925@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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/ipw2x00/libipw_wx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/net/wireless/ipw2x00/libipw_wx.c +++ b/drivers/net/wireless/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;