Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3407469rwa; Tue, 23 Aug 2022 04:23:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR5hyYFcMU5Yuo+6yG12dI7mPKX67if639bufZi9Y11dV9BfEuSwPA9jFDHrFiSvx+FVBcdx X-Received: by 2002:a17:907:75e8:b0:730:ccd3:2683 with SMTP id jz8-20020a17090775e800b00730ccd32683mr15975190ejc.329.1661253793201; Tue, 23 Aug 2022 04:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253793; cv=none; d=google.com; s=arc-20160816; b=cD/jWav2KSX7H7DSlhcEK1j0vza7ZBvMGj6+69xUbGRPAD47kbqbPq/tKeNQ/WZS2U 5tAymFGp/AUOOuZorWGD/yQmVxEv6i7+NcwTZQETO2tKHOVun6QblYmDzB9pcU5AOIWe rTkOV75ae/fGPNC9b1kWpj3DVpUdzJY4DkBIXv0IRLRC+y91cyG1tywlJwf7IN/z+Wk8 DY4XZJIQwOx8kKFYDA1NI9qZ1eTxN4dMcjZkawXMz+gWWT1yBvs0cujtrqKKYWVnZydi M7jfNUJedQX7C8CWi+Z8FTQZh24VhbWPC4XVx1YsBJCy53+25BxSxxcpOeistJrqDoj7 KQBw== 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=F69kKeLz6h6/Zy/rDxUDj797rsJKhAVkSjwWc2x85ys=; b=fzRRkOrHzsOtLyXveRExUmoFO6bUQMmQd2vPEOi9AZBYQl0tiKNgiidJv7GSkQ9Pjj DYbmhW+9Mv60KBPx+f0nQKzVR7iZVKK5mTP+KHuZf1GcsElXIIY+upkbXPS4CyVIPt06 Fs1d42e1YDzzyEO4jZGbZaWOKegsDAfmBTH/DLrB5e3aKqAERymer62WtHtJS6pQyoAZ UhLdf+CLnbnb/ix4xy3w09gueN0w0kLOm0K/l3NByMrUTS707UCzIdVzFXz/TGUgr7Ki jRW8eSFcXoR+11MdJ0Bw845UxdRyj9J26rXA1W1EWawxsX7QL5wuKE5Jp9a6pDFCU7BM m54A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DnvO1XDR; 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 hd7-20020a170907968700b0073d21e8125dsi10470572ejc.850.2022.08.23.04.22.47; Tue, 23 Aug 2022 04:23:13 -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=DnvO1XDR; 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 S1350073AbiHWJZS (ORCPT + 99 others); Tue, 23 Aug 2022 05:25:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349781AbiHWJY2 (ORCPT ); Tue, 23 Aug 2022 05:24:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C474490805; Tue, 23 Aug 2022 01:35:54 -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 4123BB81C4F; Tue, 23 Aug 2022 08:18:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC131C433C1; Tue, 23 Aug 2022 08:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661242716; bh=+Z2c0OxS9hfS3VZxv8oMBN/X8wfE6XIeSWU42oMqx5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DnvO1XDR/pMEl79/YFpUmiXmcx0Sm36gvoNb8rbDnB4OnWCc/V2eJtCUZ69EfkfiQ Is5mHwKMCowINxnCmWHoZreVJcRWVTS9iL4ie+2ViT+gj7KZ05LL/fSHNh+n/H9FKV vhcy2kR4s1gCghVzhl3ZLjHCRP/6OER8hZ9Pls00= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Mark Brown Subject: [PATCH 5.19 178/365] ASoC: SOF: Intel: hda: Fix potential buffer overflow by snprintf() Date: Tue, 23 Aug 2022 10:01:19 +0200 Message-Id: <20220823080125.671237572@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 94c1ceb043c1a002de9649bb630c8e8347645982 upstream. snprintf() returns the would-be-filled size when the string overflows the given buffer size, hence using this value may result in the buffer overflow (although it's unrealistic). This patch replaces with a safer version, scnprintf() for papering over such a potential issue. Fixes: 29c8e4398f02 ("ASoC: SOF: Intel: hda: add extended rom status dump to error log") Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20220801165420.25978-4-tiwai@suse.de Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/sof/intel/hda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -467,7 +467,7 @@ static void hda_dsp_dump_ext_rom_status( chip = get_chip_info(sdev->pdata); for (i = 0; i < HDA_EXT_ROM_STATUS_SIZE; i++) { value = snd_sof_dsp_read(sdev, HDA_DSP_BAR, chip->rom_status_reg + i * 0x4); - len += snprintf(msg + len, sizeof(msg) - len, " 0x%x", value); + len += scnprintf(msg + len, sizeof(msg) - len, " 0x%x", value); } dev_printk(level, sdev->dev, "extended rom status: %s", msg);