Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp196938lqh; Thu, 30 May 2024 20:26:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVEYGvISGsON+6CIy82bKLHjL/xTYXU3OXTFed7z/vpJrsDK+Av7H9yZm8ga40J/Xprm+cveT5gy/AHbhjzUQY+P01ju4oc/lt90p/Qsw== X-Google-Smtp-Source: AGHT+IGqFUmBcKNkr5RZOX0zXrhf1Fs6Ivszgfji9gJbrUgxIlIHkZL0ZbOCSTxinIfWF1nIOXd7 X-Received: by 2002:a05:622a:4c9:b0:43a:cfc1:7f28 with SMTP id d75a77b69052e-43ff524a349mr7343341cf.16.1717125961001; Thu, 30 May 2024 20:26:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717125960; cv=pass; d=google.com; s=arc-20160816; b=yk5c9egE1Bn4TTZF72vtTwuT659rTDyEopm8xweVRhyFDFbVBlecwXDfmx7VrdbnVn U4whvHxkUjz/5OsyFJJn4kgbBZ0gzWMqSHlzaq2TONc9UPTOhHkGFqhzNBIRW/myUnTu PfMWOzFwcL8JnfWXAEkrwAgM8Fq+pNP7aSL2+NbONmmpdV2qcQQxXcMzjzaTPL88K0wS ZIZ/kW/ipSmjqYKzPWkFCEbW2giSM1dhvqY/1qeXCQr5PjVIJDmtKOH/gHv7ATTGVpQh YDyj+u+DYux6o/U+Ag4o71lrG+YnApRswBKAcnv8Kau/Wr/OqxjWSJ0sP4uaTFSx12D+ l8sA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=gZAVuRodAHbWTiC8IuA+RQLzAXhqPeUU7RFRhElhywc=; fh=JbD2A596CURoVn2J3I5HMHRuFCabXJvBdtsbHsnop7s=; b=XYM3gsOT9yMWENuMUMNRLWQ6nVI1R0qbSe7WPTYakP1fmgYEPOOKfqrfT4ItBlJDAi q9FjZTxVymhKUcu3dpKu69GYZVGtuireeA2xQZ+bmzN9dKJ4V6CGpilXIDSxSag2Oy4l 5wWE6qqK2GDIroy9UWgb3ki7jqpxpm7g9HQCMoOVglVT04CXzaYJJBxAilba1DiQ4VfD mGOdgfkcbHA4XFHS8EKbtl25zVMbX0p9MGjkSR3O1xKcKwMDHJRo6TqZBK9iMMJ/j8u6 dLbk1T53cbWeH0d6N1R71rwCGAY0HrTTH2HMXcew7d3PRAE+OP7nroPqdyK4/SIk4Sbk l4AQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=pL0Oefgz; arc=pass (i=1 spf=pass spfdomain=yandex.ru dkim=pass dkdomain=yandex.ru dmarc=pass fromdomain=yandex.ru); spf=pass (google.com: domain of linux-wireless+bounces-8335-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8335-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43ff257eff4si10783751cf.423.2024.05.30.20.26.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 20:26:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-8335-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=pL0Oefgz; arc=pass (i=1 spf=pass spfdomain=yandex.ru dkim=pass dkdomain=yandex.ru dmarc=pass fromdomain=yandex.ru); spf=pass (google.com: domain of linux-wireless+bounces-8335-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8335-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9EE731C21AB3 for ; Fri, 31 May 2024 03:26:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C52538DEC; Fri, 31 May 2024 03:25:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="pL0Oefgz" X-Original-To: linux-wireless@vger.kernel.org Received: from forward205b.mail.yandex.net (forward205b.mail.yandex.net [178.154.239.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B4E733993 for ; Fri, 31 May 2024 03:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.154.239.152 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717125956; cv=none; b=F8bxP9XDTIkJTMFCJUyHdSyDg3BZI43G+P83+ZyZ3SignfF6+HKYlukvJVsvDUaZwon0dJKZJO99BfkccJj1DppGSkGMQvRbvIbjw5t9Le2TW6ITTJhY351x19JQ9+MEFIN5W//nDN1/8CGKT+OAsUvbn9OqUcQPOh7EeRyT2IU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717125956; c=relaxed/simple; bh=bQgNdifRlXG+6YvlhtUeAOK6Mywvi8QoaccOz2Xdopg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=umNaMOfrqRevqajtIqbbxd8rIss+7wcwhFVQA29PpZLX6cjYzFSGuDtBJxaq63rwhoZgOvBRKOzKWpWM8DvFTzcEi2Kh9utMLvpGHMh/aVhgS4D422aNmpVT5F12EiNtTDdRNLnwaIE4DcQhkD23j1uESb9O2GIWyTpjoXWkG1A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru; spf=pass smtp.mailfrom=yandex.ru; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b=pL0Oefgz; arc=none smtp.client-ip=178.154.239.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex.ru Received: from forward100c.mail.yandex.net (forward100c.mail.yandex.net [IPv6:2a02:6b8:c03:500:1:45:d181:d100]) by forward205b.mail.yandex.net (Yandex) with ESMTPS id CF57366377 for ; Fri, 31 May 2024 06:22:08 +0300 (MSK) Received: from mail-nwsmtp-smtp-production-main-36.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-36.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:980:0:640:9d32:0]) by forward100c.mail.yandex.net (Yandex) with ESMTPS id A47C160AA2; Fri, 31 May 2024 06:22:00 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-36.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id vLJ0NiFOm8c0-8ZypTVeE; Fri, 31 May 2024 06:21:59 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1717125719; bh=gZAVuRodAHbWTiC8IuA+RQLzAXhqPeUU7RFRhElhywc=; h=Message-ID:Date:Cc:Subject:To:From; b=pL0Oefgzyu002ZMTTqbLWX/ugntvWx09Oi0ADp1OXajbn/W6EjPmaS9DwCnY6VofO r4kERjeIKMY8IihIIlsYuLT44SWULewoussIRzduvYaqkY1BX2DoINwIodFrcgvIJp /WEAgsXMWcQ465qsFkOz2riupB1I4/0GZx5gYmuE= Authentication-Results: mail-nwsmtp-smtp-production-main-36.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Johannes Berg Cc: linux-wireless@vger.kernel.org, lvc-project@linuxtesting.org, Dmitry Antipov , syzbot+253cd2d2491df77c93ac@syzkaller.appspotmail.com Subject: [PATCH] wifi: wireless: add extra SIOCSIWSCAN data check Date: Fri, 31 May 2024 06:20:10 +0300 Message-ID: <20240531032010.451295-1-dmantipov@yandex.ru> X-Mailer: git-send-email 2.45.1 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In 'cfg80211_wext_siwscan()', add extra check whether number of channels passed via 'ioctl(sock, SIOCSIWSCAN, ...)' doesn't exceed IW_MAX_FREQUENCIES and reject invalid request with -EINVAL otherwise. Reported-by: syzbot+253cd2d2491df77c93ac@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=253cd2d2491df77c93ac Signed-off-by: Dmitry Antipov --- net/wireless/scan.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 127853877a0a..6d4d3447aecc 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -3400,10 +3400,14 @@ int cfg80211_wext_siwscan(struct net_device *dev, wiphy = &rdev->wiphy; /* Determine number of channels, needed to allocate creq */ - if (wreq && wreq->num_channels) + if (wreq && wreq->num_channels) { + /* Passed from userspace so should be checked */ + if (unlikely(wreq->num_channels > IW_MAX_FREQUENCIES)) + return -EINVAL; n_channels = wreq->num_channels; - else + } else { n_channels = ieee80211_get_num_supported_channels(wiphy); + } creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) + n_channels * sizeof(void *), -- 2.45.1