Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8220613ybn; Tue, 1 Oct 2019 05:10:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzngu+/rvFKVbRUQphj97VxI6LodAbPGFskIuTuiXztA5R9my87BmI6pxPpYMQnM9ZwTX+4 X-Received: by 2002:a17:906:2ec8:: with SMTP id s8mr24591481eji.275.1569931852590; Tue, 01 Oct 2019 05:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569931852; cv=none; d=google.com; s=arc-20160816; b=Swz35Rej5PIj97ZNcnTw4JJn8dkJqx6oldj8gLOxiGyiDP9VM/cDxSoSCk6G2fa5le SLoq1OE/9yZqzMempoEqmjj75/fOhkliNTwklfy3QpQaoV4e8am7m9X7Hq2HxziIQ4NH 5nSCCYeDqloQSj4s8p0N8gCZ8yyvacowA6XyTgEer3g1pZzKZx0F46tXKtI31SzMzd9R zkTz7rpUEcnNsQW76UJ0vnRswLgaKIWzwG47jlxlrX7cOJWL6axp4Wh8wokjhoQ0IcKY tQy/8Yn3icaFsIPZHDVNXgHWiwICIzSwiHFZiuvIBilp3YeNCrUsHWJkjrh/veUaPsre /Fog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=vDFY4l7ObdzMDLTWvSUTkZyMTjDs2NyWYY8Kts57jhs=; b=ogXcITpX6VEyzqObyet2znwUukYMxIpy4C6CCGokffdPLSRvdrOIOR98u+a424uTYV XosqxAvVmoOrI25YkPj2eIWZ8vN1+icHuIofSC6qf1w8ITNhPmpUzJWWr7uUMNvVqSpO H9O7vjiJNtby0q3hnnJj7D3r98pK+CCKjRfKmbyWlv1APBdvQ+jEtR8LcAV5OsOtR/7s S1j6ZRridRRpDRXn9Xz5jYizk7YDSsIfBtcCc7x427tsjic7AAi6o2XyoPL6T5PM/EXR uYJpjVe494xPyWT83dlYYXaa+44FrgSQt1HABzHfKVvIHF9MZKKwF0LXmtLzSJGad+NX ZsOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id um16si8657912ejb.12.2019.10.01.05.10.27; Tue, 01 Oct 2019 05:10:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387476AbfJAMIl (ORCPT + 99 others); Tue, 1 Oct 2019 08:08:41 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33088 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725821AbfJAMIl (ORCPT ); Tue, 1 Oct 2019 08:08:41 -0400 Received: by mail-wr1-f65.google.com with SMTP id b9so15220403wrs.0; Tue, 01 Oct 2019 05:08:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vDFY4l7ObdzMDLTWvSUTkZyMTjDs2NyWYY8Kts57jhs=; b=LQWkubhsu5JfOHnNRgZxHIVVqCwzlzmLuZ9RHk9QImzDX+0MV/CkXvsOatJ8tZrmXe piAW/kJ612Zz75+s/zPNZ3jGgdtNmrHKAM1JfokLdSUAtFQAhU32AoKvMfarbTjWdPzT SQEMxn+a2+nL4iNSRZbq09+EhJfByQ6UrXxaZnqSMks+OEgjXFSfc6OBquesTes2NQ07 XXtnlwoC9mcSE7WTBZ0Wc4mCa8Tl7iMcFslMY65KqGDhNWT055fwAULryP9LZae5dd3I mat6PHk4RoNhs1du92YxKWZnnunloWSOpEJ2+V26Jqr0NWc1ao+HMTW1Z+Evw7XFEXCd kCuQ== X-Gm-Message-State: APjAAAXRGfOqKC1GUjsfAFk1rBo27bvu7FrqiRlgpNcgHKyCXKXKHzSU HbztSGXtCP1h6vE50Pxg9cdagF++ X-Received: by 2002:a5d:540c:: with SMTP id g12mr17579546wrv.207.1569931718832; Tue, 01 Oct 2019 05:08:38 -0700 (PDT) Received: from green.intra.ispras.ru (bran.ispras.ru. [83.149.199.196]) by smtp.googlemail.com with ESMTPSA id f18sm2600683wmh.43.2019.10.01.05.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 05:08:38 -0700 (PDT) From: Denis Efremov To: linux-wireless@vger.kernel.org Cc: Denis Efremov , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, wil6210@qti.qualcomm.com, Maya Erez , Kalle Valo , "David S. Miller" , stable@vger.kernel.org Subject: [PATCH] wil6210: check len before memcpy() calls Date: Tue, 1 Oct 2019 15:08:23 +0300 Message-Id: <20191001120823.29853-1-efremov@linux.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org memcpy() in wmi_set_ie() and wmi_update_ft_ies() is called with src == NULL and len == 0. This is an undefined behavior. Fix it by checking "ie_len > 0" before the memcpy() calls. As suggested by GCC documentation: "The pointers passed to memmove (and similar functions in ) must be non-null even when nbytes==0, so GCC can use that information to remove the check after the memmove call." [1] [1] https://gcc.gnu.org/gcc-4.9/porting_to.html Cc: Maya Erez Cc: Kalle Valo Cc: "David S. Miller" Cc: stable@vger.kernel.org Signed-off-by: Denis Efremov --- drivers/net/wireless/ath/wil6210/wmi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/wil6210/wmi.c b/drivers/net/wireless/ath/wil6210/wmi.c index 153b84447e40..41389c1eb252 100644 --- a/drivers/net/wireless/ath/wil6210/wmi.c +++ b/drivers/net/wireless/ath/wil6210/wmi.c @@ -2505,7 +2505,8 @@ int wmi_set_ie(struct wil6210_vif *vif, u8 type, u16 ie_len, const void *ie) cmd->mgmt_frm_type = type; /* BUG: FW API define ieLen as u8. Will fix FW */ cmd->ie_len = cpu_to_le16(ie_len); - memcpy(cmd->ie_info, ie, ie_len); + if (ie_len) + memcpy(cmd->ie_info, ie, ie_len); rc = wmi_send(wil, WMI_SET_APPIE_CMDID, vif->mid, cmd, len); kfree(cmd); out: @@ -2541,7 +2542,8 @@ int wmi_update_ft_ies(struct wil6210_vif *vif, u16 ie_len, const void *ie) } cmd->ie_len = cpu_to_le16(ie_len); - memcpy(cmd->ie_info, ie, ie_len); + if (ie_len) + memcpy(cmd->ie_info, ie, ie_len); rc = wmi_send(wil, WMI_UPDATE_FT_IES_CMDID, vif->mid, cmd, len); kfree(cmd); -- 2.21.0