Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3292394rwa; Tue, 23 Aug 2022 02:07:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR6p3HppV1UWuhyrViredF9Gr+qlxTgRWAYVIyZ3+iohtPPJnJtIKVEpmix3rigYIuuUkuU0 X-Received: by 2002:a17:907:2cc8:b0:73d:6abc:16a3 with SMTP id hg8-20020a1709072cc800b0073d6abc16a3mr9137963ejc.652.1661245667184; Tue, 23 Aug 2022 02:07:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661245667; cv=none; d=google.com; s=arc-20160816; b=r9JnT8pP89f+DxgWUoDXTYF5C8xfAP+NGEOtil8Yuol/s9m64KboBndGxHnwypC5IT w0eIpgIyQtCwHJ6dHFg3GAjY/Vg9jOQkWnIOZ6EOpZ3MCQFueVvkxiGwoU2HAQlv5ccK bc2RRcvCxgAc1VJXHpZH6hDqC+ZrWKHxjse6jjb7CSVp1L/LwHAPnPZjvU6adKn7DUcN UuaekCw2jjW5O/i26v49n7gObulZKhLjZxFdXjRwrh3XfoKTB5eZ0vvL3yhqJE+RKZSO p2sJeOqtUgDPne/1xozHiyGwIiHyR4yEQov0u3sx0YM80nhZJLzLyTPQA4yf5yX4MAJp ZwPg== 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=O9GbIVnGmxAa38NCUuAZ/HFbjLqYK/JBsBJf5D2Rxwo=; b=0kiYjT3/G5c0F71R+XlD9OutAY5NSmNUlkd+dbCmJMHPMdn6+X5+86EeTT4LTxXZYH u5IuDXLYuMF2oGuVAnM0mrVNeqZdNK1jqgbpoxP2IS6hxvCOHFA/oU6eI7nqqufiPUu0 PmuiSiVjB2aaUb6Qa91UDTUFF9LOOgd6u8f0fL/JJreKpjFwpPVZb9210hOXRZnx/mS/ Yu6/FCCRhQ0xqrYXeL3pnZHt8rUQyrC3yGR+oSoXKdEF2hnWazSMQn3LzBS56/D/TiPk FghNoaKfamWhftmgec9I+T3kjyyPpn69XfdzSOLoiIml1uvLiBSRblcQbE6HD5brALzj KsUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OZ6WmJ9m; 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 sd34-20020a1709076e2200b0073d63d9946asi7664430ejc.109.2022.08.23.02.07.20; Tue, 23 Aug 2022 02:07:47 -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=OZ6WmJ9m; 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 S1345867AbiHWIkP (ORCPT + 99 others); Tue, 23 Aug 2022 04:40:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344741AbiHWIjn (ORCPT ); Tue, 23 Aug 2022 04:39:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3999B1401D; Tue, 23 Aug 2022 01:18:31 -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 3E830B81C4B; Tue, 23 Aug 2022 08:18:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9717AC433D6; Tue, 23 Aug 2022 08:18:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661242710; bh=Ifo1c328SdBt/vUETtDn0Qt+M/Wj0wNycavFs6K4Gsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZ6WmJ9mb5UBfWG52VubvB8BUJa1mWYplOre6htbpzUj5LomEnexdazW5q9pBrpgx svuDw3H9E32aahlcRroL/0SSOIUlW3QQYyi0AuLG4wh2hFbgyQPvbcxMc0tFisqJfl 20AF0MN1c70USZE+ZCKR4VhA9PcoFyasv7V5GVQs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Cezary Rojewski , Mark Brown Subject: [PATCH 5.19 176/365] ASoC: Intel: avs: Fix potential buffer overflow by snprintf() Date: Tue, 23 Aug 2022 10:01:17 +0200 Message-Id: <20220823080125.576859163@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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,T_SCC_BODY_TEXT_LINE 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: Takashi Iwai commit ca3b7b9dc9bc1fa552f4697b7cccfa0258a44d00 upstream. snprintf() returns the would-be-filled size when the string overflows the given buffer size, hence using this value may result in a buffer overflow (although it's unrealistic). This patch replaces it with a safer version, scnprintf() for papering over such a potential issue. Fixes: f1b3b320bd65 ("ASoC: Intel: avs: Generic soc component driver") Signed-off-by: Takashi Iwai Acked-by: Cezary Rojewski Link: https://lore.kernel.org/r/20220801165420.25978-2-tiwai@suse.de Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/intel/avs/pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -636,8 +636,8 @@ static ssize_t topology_name_read(struct char buf[64]; size_t len; - len = snprintf(buf, sizeof(buf), "%s/%s\n", component->driver->topology_name_prefix, - mach->tplg_filename); + len = scnprintf(buf, sizeof(buf), "%s/%s\n", component->driver->topology_name_prefix, + mach->tplg_filename); return simple_read_from_buffer(user_buf, count, ppos, buf, len); }