Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3631297pxb; Mon, 24 Jan 2022 13:59:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJypafgh4cItNm561mTU09ZI10yxgynV4IKV9lCdnm1RH3LOKfqN+s3wpGc/ffesjFQB0ud+ X-Received: by 2002:a17:902:a502:b0:149:c5a5:5329 with SMTP id s2-20020a170902a50200b00149c5a55329mr16038099plq.164.1643061549544; Mon, 24 Jan 2022 13:59:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061549; cv=none; d=google.com; s=arc-20160816; b=OfOkb1zgONQbENcUtki5h5czL7/TZ6F/euQCEIfbh5GN4DzzpM9ywgo/M42Q1B4KtY PlOv/4YJt1GO5Bnx4EA5/tljx8/GZ7oNtI0zjEggHNqXoB4JOl8hWE3hX3ccchf6+zLh sj+3ALNcsy/14io3ljk6rtp89g/rSZBss+QKuTP8LTz+NBAopKaRd3xtsR0RdMsFqZG1 l2Tt/HL89kqBQ8YzWmyBLChsZZCO7lX0Ec754YC8Zf2AjyOQlPElFpt5WjwD3q6ZE5/Z ws0u6PpQVVdrigIJVfeSrG/2LYcBGdEY6nnE/LEZqEyre/jHBg7RnC+y0cqz1Eb91dB6 HHhA== 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=4vMNOwPDByJqtLBKPUBHBOPaosMxPPO9gj5Tla3kvH4=; b=NYMfWVTlo5fZr1wfBrEaq8jThsIiHm/kMEyESo9j6CauIHb76nNO4HM1LmQEAuD8Uu 4ruJAfa76Uhi4bRO/SKHnQNkPYPwQxHVnaiSKlBE+4yMYSoDYkPA47kj6xS3XXJUFDTN ETcxI+Feyh76cG0NE3zmB4f0cxAdu+eHxpM7f87nZTyctyJ3s1Z6LLtXKAPW+lqTlGbc p/4eNCmSAx/4OsVof1J3SeePF/MqWey4DCaqvRj/Bxh8qapxxDYCyJjxTg9tI/MQrZ5a ebgccO3PG5zh3CfYQS0KlXqnVf3nJFVZcTS6vHN38RA88oaatCIBv4nJ9sOIDFNFZsvD e8eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=W38MF4DR; 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 w10si439395pjk.113.2022.01.24.13.58.57; Mon, 24 Jan 2022 13:59:09 -0800 (PST) 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=W38MF4DR; 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 S1359341AbiAXVtM (ORCPT + 99 others); Mon, 24 Jan 2022 16:49:12 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:36738 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1448811AbiAXVNw (ORCPT ); Mon, 24 Jan 2022 16:13:52 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 62342614A8; Mon, 24 Jan 2022 21:13:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A40AC36AE2; Mon, 24 Jan 2022 21:13:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058828; bh=l6Ni9v689sSDYi8RGWJ0Fvwu5bh71a7KQRIO9ThqCxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W38MF4DRlAkuJ1I1UNwujiD9JLwIcbpPhuuLsFOY05J+M+O0j3hfCoX8rfuMOb+Go wtjKyP/wE/pKDAzlfTC+FLATmh2ykrlejUZVaZHyMcI/tJbW/mwYrmOvTnHyuMmwut 6nGKfHsc08vjiJ3gjD30S4TlVu3hnlNHISN8ADaA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.16 0416/1039] Bluetooth: L2CAP: uninitialized variables in l2cap_sock_setsockopt() Date: Mon, 24 Jan 2022 19:36:45 +0100 Message-Id: <20220124184139.296305819@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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 [ Upstream commit 2b70d4f9b20635ac328836e50d183632e1930f94 ] The "opt" variable is a u32, but on some paths only the top bytes were initialized and the others contained random stack data. Fixes: a7b75c5a8c41 ("net: pass a sockptr_t into ->setsockopt") Signed-off-by: Dan Carpenter Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/bluetooth/l2cap_sock.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 251017c69ab7f..d2c6785205992 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -903,6 +903,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, struct l2cap_conn *conn; int len, err = 0; u32 opt; + u16 mtu; + u8 mode; BT_DBG("sk %p", sk); @@ -1085,16 +1087,16 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, break; } - if (copy_from_sockptr(&opt, optval, sizeof(u16))) { + if (copy_from_sockptr(&mtu, optval, sizeof(u16))) { err = -EFAULT; break; } if (chan->mode == L2CAP_MODE_EXT_FLOWCTL && sk->sk_state == BT_CONNECTED) - err = l2cap_chan_reconfigure(chan, opt); + err = l2cap_chan_reconfigure(chan, mtu); else - chan->imtu = opt; + chan->imtu = mtu; break; @@ -1116,14 +1118,14 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, break; } - if (copy_from_sockptr(&opt, optval, sizeof(u8))) { + if (copy_from_sockptr(&mode, optval, sizeof(u8))) { err = -EFAULT; break; } - BT_DBG("opt %u", opt); + BT_DBG("mode %u", mode); - err = l2cap_set_mode(chan, opt); + err = l2cap_set_mode(chan, mode); if (err) break; -- 2.34.1