Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3029606pxb; Mon, 18 Apr 2022 13:56:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxADVqQi8KHMhbiP7ZD9Y6rODFlB/3woLczwGv2kJHbh/aYoRYg4LwVym6p/PDTWRSK/Zq X-Received: by 2002:a63:e706:0:b0:3a9:fb93:2011 with SMTP id b6-20020a63e706000000b003a9fb932011mr5749277pgi.259.1650315385590; Mon, 18 Apr 2022 13:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650315385; cv=none; d=google.com; s=arc-20160816; b=bxa2XRRKinw+m1r3EvjuJZ7yOeFnBxzVcn3/akeF+fuVAqhRr2Q+LzLr4xrjYqSZJs Yv8sNpUiHowPuIcqbPAvMHlvS1BnekfmFphPwcFsr5Rav6ZC3c0ab5zfU+dRSCji5Ag0 MKOlEkmGKbc3/bwQrBrm/8y482HkCnRW+/DKZQg3PYlhXb2wf06L59t45O2GIJUL0fuw bfrWV43MttUFsk4uPpFWYzHwvWihsEjcRWQ0Az7DE3nbeuBLNkZsTPX9qU3OBIs92JrK URkRfvtyv+gNvlGob3ndDRZXppIozOK4IN0qPQOtOiqYIZ2U2CaVEhZ6ZtpkJrIcJrwX 88UA== 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=6mDluKF2jALz0xql67ZnJzwqw2in2ta49xj6gytatVE=; b=nrZlVYoH7c75QwUJQB+fyxCv9oRQwEMRx5n60VALce2sAHyXOqtTWaARDE3kkfbgFg nYanmsB6OtJ7NuOCj6Jj7fLcEJctDZsOM5WUFR7DIaOlu3ZhEkwT0m5pf083lo6hZAZH bRxPwFDHCduHUEIAwLcSNByhyCpfeQldBOMrwTGs2YO/oK3RTSlpUsxwENxjhbqhcqJ2 e4Yq2aL9xwRvAZo8ylF3t9OPsT+r3tPoKbcT6RfqHNHYUUo72fOdiI7n2Hsjt1wGE8FB ewWanvNpuHMCdIKPu1Ntcn+VKozLqwy0h8d9x8RLBwee4aPbdGhFfFpqvb1D+UaNCjQI kDOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="sMbt2K/j"; 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 p17-20020a170902ead100b00153b2d16512si8833295pld.282.2022.04.18.13.56.08; Mon, 18 Apr 2022 13:56:25 -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="sMbt2K/j"; 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 S245351AbiDROHb (ORCPT + 99 others); Mon, 18 Apr 2022 10:07:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244445AbiDRNtw (ORCPT ); Mon, 18 Apr 2022 09:49:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A68A434A2; Mon, 18 Apr 2022 06:01:42 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 1BB8260B73; Mon, 18 Apr 2022 13:01:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25429C385AB; Mon, 18 Apr 2022 13:01:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286901; bh=v5N7atVabdYmknc+NlpOF9iBuklO7MWoN0onHb00TMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sMbt2K/j8lyekMJIgjK8bhZkqdaxeoHzzxRUV9LS0gVZL1kdZY0Q4LUrMA2VT/cIi ULcWQBfanc/5asmOunrr8bkAOg4agWtRMv/cbMf+GtIye3nT62Vnx+TkTX0vQ2CEeJ Fq0fWqDA+t0Mj0PJhfyTYCp7JwWRx9SYdNgTZrmY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Fabio M. De Francesco" , Takashi Iwai , syzbot+205eb15961852c2c5974@syzkaller.appspotmail.com Subject: [PATCH 4.14 281/284] ALSA: pcm: Test for "silence" field in struct "pcm_format_data" Date: Mon, 18 Apr 2022 14:14:22 +0200 Message-Id: <20220418121221.180353013@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@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,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: Fabio M. De Francesco commit 2f7a26abb8241a0208c68d22815aa247c5ddacab upstream. Syzbot reports "KASAN: null-ptr-deref Write in snd_pcm_format_set_silence".[1] It is due to missing validation of the "silence" field of struct "pcm_format_data" in "pcm_formats" array. Add a test for valid "pat" and, if it is not so, return -EINVAL. [1] https://lore.kernel.org/lkml/000000000000d188ef05dc2c7279@google.com/ Reported-and-tested-by: syzbot+205eb15961852c2c5974@syzkaller.appspotmail.com Signed-off-by: Fabio M. De Francesco Cc: Link: https://lore.kernel.org/r/20220409012655.9399-1-fmdefrancesco@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/pcm_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c @@ -406,7 +406,7 @@ int snd_pcm_format_set_silence(snd_pcm_f return 0; width = pcm_formats[(INT)format].phys; /* physical width */ pat = pcm_formats[(INT)format].silence; - if (! width) + if (!width || !pat) return -EINVAL; /* signed or 1 byte data */ if (pcm_formats[(INT)format].signd == 1 || width <= 8) {