Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp484992imn; Wed, 27 Jul 2022 11:30:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tftw9ajKAwJSpUii86CunVvGEFwCYZbP5zf39Lf2CXpZ/5A813l/FS8TQhGvgwPLUiUX9g X-Received: by 2002:a05:6a00:1812:b0:52a:c171:7cc5 with SMTP id y18-20020a056a00181200b0052ac1717cc5mr22778936pfa.81.1658946635529; Wed, 27 Jul 2022 11:30:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946635; cv=none; d=google.com; s=arc-20160816; b=FWg+7UtUcOwl3oHEMsyIgOABcIpd6UxCJ8kW+pKHvQQ4DDlrF4DO5r1/sjL9QDUKBP rRGO3d1BhB5E3McCy118IiD0RlaxDVmWvqjqyrXG2Du1kcG3nooZrYkmdVV6vWwO1Aao KJnM4ct4pwksFk6de4+YXYc9L9CqJbE5SuvR1S7v6b7VPA1cdhxJYrtmZUgmiDa5WDkX ehUTNmGh3ArPSmlkLQ1jefS19VQJhdVK04nQX83HKNXsn07naWpUu0jxPikTgjt+vtIZ nLyXGBAwWt9zm8vqY+Wt+czxlLAEfWrUI4s64drhMn4clGT+Sftpu4/tm8z0GImA8DIw 2KQw== 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=EiSQLKrAQjdj7Sj1O4pcSP9xSx+QMdhLkD2oHutFmjQ=; b=UgJTPkKDpgrgO3X0Ga/EjmMvuMzpztrfztV+sidse3It/CtCoH9YqwB7iYLSkYj6dt wQ5W0NVwvAEEKmnt4TCddQWe/7f/lH1+SllA+SdX5+ooiqPhWypkyy8FuboTz4k28po3 lfQfdQzTaAoniMXX8COj0LLwaG8TpmBydl9BSDp90tyXE/rx2BSlFbwWv7/kZf8WF5wc Q5+J8yiW/0mOhVZdFEt+jQs52CujUSPCPxBMYEn9cR4oV+97ODVy99XupJ86VlojGRi5 lVlIY9y6IE+0ce+zTvuW5o/IrC5Nrj9s587dO86G99wi5OV44vRbtUEOdafncjuaYnhb 2qaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uCM6svHf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id me2-20020a17090b17c200b001ef7fc77664si3057382pjb.158.2022.07.27.11.30.18; Wed, 27 Jul 2022 11:30:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uCM6svHf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S236247AbiG0R0A (ORCPT + 99 others); Wed, 27 Jul 2022 13:26:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242324AbiG0RYy (ORCPT ); Wed, 27 Jul 2022 13:24:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 420077D1DC; Wed, 27 Jul 2022 09:46:30 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id C28BCB821BE; Wed, 27 Jul 2022 16:46:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E63FC433C1; Wed, 27 Jul 2022 16:46:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940388; bh=8wseduYSB04klnmbB3qO5dWg7kVn28vt/87y7JL97D4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uCM6svHfXDhLOC4Pdi5YxlyIO09BwIK7ubU9Eu6O60yEOUsrvrE7w05hMzIZBd2J7 j4uyhHkA/sU8m3yyYSoWvfaCGgz2hzJX3y9eWUVl1Oihvcjow7ebMM+fBs23buw51r lkmxoOM5vJ6fg8NHkE58hYQ532UEIrKXQUg2ljfA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tedd Ho-Jeong An , Luiz Augusto von Dentz , Marcel Holtmann , Harshit Mogalapalli Subject: [PATCH 5.15 179/201] Bluetooth: SCO: Fix sco_send_frame returning skb->len Date: Wed, 27 Jul 2022 18:11:23 +0200 Message-Id: <20220727161035.212051689@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161026.977588183@linuxfoundation.org> References: <20220727161026.977588183@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luiz Augusto von Dentz commit 037ce005af6b8a3e40ee07c6e9266c8997e6a4d6 upstream. The skb in modified by hci_send_sco which pushes SCO headers thus changing skb->len causing sco_sock_sendmsg to fail. Fixes: 0771cbb3b97d ("Bluetooth: SCO: Replace use of memcpy_from_msg with bt_skb_sendmsg") Tested-by: Tedd Ho-Jeong An Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Marcel Holtmann Cc: Harshit Mogalapalli Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/sco.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -283,16 +283,17 @@ static int sco_connect(struct hci_dev *h static int sco_send_frame(struct sock *sk, struct sk_buff *skb) { struct sco_conn *conn = sco_pi(sk)->conn; + int len = skb->len; /* Check outgoing MTU */ - if (skb->len > conn->mtu) + if (len > conn->mtu) return -EINVAL; - BT_DBG("sk %p len %d", sk, skb->len); + BT_DBG("sk %p len %d", sk, len); hci_send_sco(conn->hcon, skb); - return skb->len; + return len; } static void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb) @@ -743,7 +744,8 @@ static int sco_sock_sendmsg(struct socke err = -ENOTCONN; release_sock(sk); - if (err) + + if (err < 0) kfree_skb(skb); return err; }