Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2866379pxb; Mon, 18 Apr 2022 09:53:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnvcuIv8pLYAoY2I5+3PO6gZFWh3bkRRcAGmRZi6Ek8jkkYEC6iOvXL7Vx1fueLHNj5VAu X-Received: by 2002:a17:906:e18:b0:6e8:69c2:528c with SMTP id l24-20020a1709060e1800b006e869c2528cmr9730623eji.439.1650300793307; Mon, 18 Apr 2022 09:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650300793; cv=none; d=google.com; s=arc-20160816; b=nHbPoG2XzGDIkaiYWUVqEOapTg/BjEA/mi2eZqcmTrGwNhCbwyg1f6IxSGGm3R6VfQ tPMWcU02OGAIV21EQIlTv5QW0nEBYdE5n+Kf/JRMXxTjFbEkZEcnAS//q8988yADj+qs phkAJYoOp5Bwd1xVl9MD1GmPYaBq3T2VtG6T3PfqQ7j2uYOBpVyjt9gWy1yoraNrSU8i v3fYeAw37KLWTq3iTc6/MJRUZfSjHKC/aq4AR3SKkpxyzeY+qq383qMnzxJNV02kOjjt n7mcoNRRbDYHILADdZ7l+d/VN4TJooRgC75hawiSyzdtm+2EFdxWszqWnnUTu3HAG1yp z5Ng== 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=wWIJ9fm27W5Jh2Ynt1LJu9kR41bUgLSCV+exEV35WpE=; b=j5vzgw9PgMvw7EswO3dQ2ftYu5U9jQHjH2sEpzMHo5WQsKFrcUK69D6nTsQLWGR+od hugFulXApn2wTNI+TYDH/PpJIEx2MfJ0bTumF92GHHcw+NE0qJIQOZhOLzFT29WY7Ah+ VnHApygmmO4AVvS/aboVpGIjtp6nT/aZmCHybV8/tMI32nvbPUIZqUiQWOEBLhdxPLEi d8ENmEJOTo2jEZ2X0lgdZooaENiYnN8XmLNP6bi5ZQpN9NVaybdCDK5Qav4YZGyqTSi5 V9qH4lNJj+D2zF0b+9i05jLwnAHzH8sR/YsW9zMFvqFnVNNF2LbHdO22n0CrT9VUCDg2 Ihpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cHlioOTv; 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 au22-20020a170907093600b006e8c1be7b7asi6760322ejc.274.2022.04.18.09.52.49; Mon, 18 Apr 2022 09:53: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=cHlioOTv; 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 S239344AbiDRMkW (ORCPT + 99 others); Mon, 18 Apr 2022 08:40:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239520AbiDRMdK (ORCPT ); Mon, 18 Apr 2022 08:33:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76C25382; Mon, 18 Apr 2022 05:24:49 -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 8562360E97; Mon, 18 Apr 2022 12:24:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94529C385A1; Mon, 18 Apr 2022 12:24:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284689; bh=c/3SbLS1EA2AxoaIQFhF0FgLVJKgO8/XqZhIPUJY6TY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cHlioOTvwwoJH9yW1b5G9ancuwnt/fQj3yJAt0MYhhyXLRGOSkhZV4SWw4tkQbLVW wJAUkLSRY421eUCuC84qj68JHb0RTmv/MjP9sTyCShVUIBMnKQrtG2hlp1OYO2jC6N n49YwxSABMkKwlE4gU9rMFyqITfMJaKY47HyAYgU= 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 5.17 196/219] ALSA: pcm: Test for "silence" field in struct "pcm_format_data" Date: Mon, 18 Apr 2022 14:12:45 +0200 Message-Id: <20220418121212.360645780@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@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 @@ -433,7 +433,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) {