Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3540568pxb; Wed, 14 Apr 2021 07:50:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSl7lHPAmaNJ25C0K9IfBIyi3IDPscPqJ72oQgYZSVjGUg8nyBsBfqqzbMa7Aotra8yo5+ X-Received: by 2002:a17:906:130a:: with SMTP id w10mr22779585ejb.71.1618411817956; Wed, 14 Apr 2021 07:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618411817; cv=none; d=google.com; s=arc-20160816; b=bE94DlfZ8USPgrr7ZMLDzZt6Vam+oGuNJbjqw01NMFFHEaMEFJPs6QtzesKJQhxsCZ 51y7n6YAAvW5hZjBBUK9TvZbEQIf9MHL4ruFobrM9sUMwJof41c5q56B2aamdcluBnpr EQSFk+Bfs9w+OsEPmCAe7ebEwfIaywgFRUHxlTGa2ps2DFkGah11bHxqylk6QF0EC9Mk BF8/sueZXUsErSwVMvyZx1xpkiSqUhTlrMLcfmLCQshr1wGil4LZRQInspk6gp5/3zCy iYkSDCXANllBQRjyygew6laUKS+cgNEz5hV/F8paEbiwWsV6QObUQrYm+K/bDwYaLhfi e5rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=G1fYSfuXOphxN5Fqq4MLcXUEV47D2LMEy9TBOwWoUWs=; b=YL6Ntmlm4jFtfbFE/7TpEIm6pxHsYJXiicst7MeUAVkMmtAa2S89I/9gh7SHKkPiUr gTafSSk2lSSsjfHX77G8+OiyQo24hB3zzFYVReCw14c20cXXURGuT9LTEBvGC4S8yn3f nx3j4sCcjxYUj/P+5k0/jojo/8ZJs2ZOaO8nuB1a/dGIEUcUapaRonrBtJqWVeWSZZ5N Fk5euE/ZQUcQft/OJnR4Z7uCunuOBwLZzpdEo8gJkjjWZX/ZQCRkMmyrHbE8udUWYgyA baDv3VxD6kF2PlFS84yA4vHSAtwu3aL2SaShVS3A+ilO9UfiH9hbTk9NCG0lmOAlUQ6M DpIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=DQ1FBhK6; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si12654574edu.606.2021.04.14.07.49.54; Wed, 14 Apr 2021 07:50:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@oracle.com header.s=corp-2020-01-29 header.b=DQ1FBhK6; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350064AbhDNIag (ORCPT + 99 others); Wed, 14 Apr 2021 04:30:36 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:54598 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348357AbhDNIad (ORCPT ); Wed, 14 Apr 2021 04:30:33 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13E8TJSg028328; Wed, 14 Apr 2021 08:30:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2020-01-29; bh=G1fYSfuXOphxN5Fqq4MLcXUEV47D2LMEy9TBOwWoUWs=; b=DQ1FBhK6c0FG7yG+fiVSJJx3UvNBWAUmfSnZIKI10i3viOzdQzniVbLzYYzYP3+dmATo 728xi1nzgMcTu68HXgb2NqjDjFRS3dTrX6By35K5kZeq0qW7jjluULCDcU8/Zl8IDEqN mhbWrByZTZzAVnX7KESc79AX7f7hAKdYYY3W1WtT3aTAJBUO6tUiLxCukqmb+bgO5hBR McnnSVIuSWK0mgJrFEypcTi6w8wmoTKqdTkxcTBLZlPROEndSBRhn9ttHm1YxfE9Gpop 3SUgEvZNGQ8rFieeWMz58+cPPVMCJkd6Hi2Bp7tXkea2loCgDfS2VDowlMIWM+ooTx5s HQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 37u4nnhhca-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Apr 2021 08:30:05 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13E8KOD5080821; Wed, 14 Apr 2021 08:30:03 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 37unxy2e37-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Apr 2021 08:30:03 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 13E8U1Nx029437; Wed, 14 Apr 2021 08:30:01 GMT Received: from mwanda (/10.175.166.128) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 14 Apr 2021 01:30:01 -0700 Date: Wed, 14 Apr 2021 11:29:55 +0300 From: Dan Carpenter To: Stanislav Yakovlev Cc: Kalle Valo , James Ketrenos , Jeff Garzik , linux-wireless@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH v2] ipw2x00: potential buffer overflow in libipw_wx_set_encodeext() Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Proofpoint-IMR: 1 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9953 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104140058 X-Proofpoint-ORIG-GUID: BEsJqhmg-tg6YZjzmZFU3zGiwmifh5Tr X-Proofpoint-GUID: BEsJqhmg-tg6YZjzmZFU3zGiwmifh5Tr X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9953 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104140059 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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") Signed-off-by: Dan Carpenter --- v2: use clamp_val() instead of min_t() drivers/net/wireless/intel/ipw2x00/libipw_wx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intel/ipw2x00/libipw_wx.c b/drivers/net/wireless/intel/ipw2x00/libipw_wx.c index a0cf78c418ac..903de34028ef 100644 --- a/drivers/net/wireless/intel/ipw2x00/libipw_wx.c +++ b/drivers/net/wireless/intel/ipw2x00/libipw_wx.c @@ -633,8 +633,10 @@ int libipw_wx_set_encodeext(struct libipw_device *ieee, } 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; -- 2.30.2