From patchwork Fri Sep 29 15:59:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 146664 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4147063vqu; Fri, 29 Sep 2023 09:11:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuFl5yLxKXWnlOOKHRzMSG6rfw0Qs4abAqvWarXI4N6DnNRZbJWdjtWmOktMMJHT+J5R1a X-Received: by 2002:a05:6a00:847:b0:692:7527:c2d0 with SMTP id q7-20020a056a00084700b006927527c2d0mr4973075pfk.32.1696003884359; Fri, 29 Sep 2023 09:11:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696003884; cv=none; d=google.com; s=arc-20160816; b=sTJeIxevtpqDcs7/frtM8gcL20jT3hoxwiyVvbgkl4NutcE+CA7aiqPI2Uh3pP2Mp/ Q71z5y3ah6YWLSJszh6qeI7+9G7WrUcg8qH3O2+5RpfbSAJSlYLmo5pG30XawJFbZToc Z7+n4BC4K9ffnz/T1+t0UZ32ggvVaUtWHr+xHmca7YhHJ5rLf+N99NPzAZAtmJT0taBj 33jR9XklmS2xcRx3U4uus9V522MCeWt12v1VcqkwJgTnRCbJvuTg9TXW9H2wIpG9JekR Ky9JQNnB5IipjsLI5kXFJyWz5hwjpTTakozSW4XU9ZCNVkiKDMsbeXeOnqZ8r9IPVRU/ Do9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=0ttJTwKN130+tmHo29VT2VrWZht6be55rIjfXfE96vA=; fh=mSzG5hg4bwmmmuflZ4+7bzKFkfPIridSyVHkXiuikO4=; b=j5XCRtqAtDgl7CJsWs3rxvzRHd5Gy4gF8MCR0Rx05xZEG594SVyPNfY/uJBdbhZvuc nFHus/2wp0wlZXBRsRddCXg1skYfeIQoR476HS0gOkPFgNq+hZQ+yW3zY5DXIhyguV8G jlRTeiQAJCQ0487c7WnEiHvJKRlfa74zGcrpcA33Z5NJOxj9az+215fUWVsknZhZ3sXx Nyv98lHqnnInNfDLUsrBBact+Cm/ZVBbg11ijtoXx/WY9UcIOyyTc6fIAIxbVxHaLdA9 iYb7iNeLGmynGO7Ll0feLq4u7U3gl5oHUQj04AtqA2dLQMzPnc7fajlIie3UGXR+TyL6 zwSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ji33FVLv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id eh11-20020a056a00808b00b0068ace3816d7si21199557pfb.387.2023.09.29.09.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 09:11:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ji33FVLv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3F84385FEDAA; Fri, 29 Sep 2023 08:59:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233665AbjI2P7c (ORCPT + 20 others); Fri, 29 Sep 2023 11:59:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233141AbjI2P7b (ORCPT ); Fri, 29 Sep 2023 11:59:31 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8BBE139 for ; Fri, 29 Sep 2023 08:59:29 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF5B3C433C8; Fri, 29 Sep 2023 15:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696003169; bh=MnZquLPkDBkjKHQwlCsmfD9plASD37pKQYphc5bm4a0=; h=Date:From:To:Cc:Subject:From; b=Ji33FVLvtjef5TpdrXCXT+tOfwK7X6QqaDW/sSTW4uncDJ0ZD9QBIZRmOUQKsgWmN QAMCATmVFijx8Ajh0KRMVLs4/Ie2iez01r2ZQyzhpaJR+MveEuei8hv1I1+AA1xmW3 4PH/aAAdF0p2YDAtLRE8dOPiriMcOvZcelN0alOaurtwQY6DGn94/ko5B/BINekQ74 IfRn7eWnesujGiT4JQEJYxfMUmcCRe8TLku3hCbeiZvI/IFBpvXE7FdC6PNebn/cwN eOpJTyQLqnuKMSDxcxYEvvGb6KYot/hn7gOtIDSNOP8ZDBbsQUVchp6GoohIeN39cX QDXFd3aOUztUg== Date: Fri, 29 Sep 2023 17:59:22 +0200 From: "Gustavo A. R. Silva" To: Jaroslav Kysela , Takashi Iwai , Jussi Kivilinna Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] ALSA: 6fire: Fix undefined behavior bug in struct comm_runtime Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 29 Sep 2023 08:59:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778388968862934196 X-GMAIL-MSGID: 1778388968862934196 `struct urb` is a flexible structure, which means that it contains a flexible-array member at the bottom. This could potentially lead to an overwrite of the objects following `receiver` in `struct comm_runtime`, among them some function pointers. Fix this by placing the declaration of object `receiver` at the end of `struct comm_runtime`. Fixes: ddb6b5a96437 ("ALSA: 6fire: fix DMA issues with URB transfer_buffer usage") Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook --- sound/usb/6fire/comm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/usb/6fire/comm.h b/sound/usb/6fire/comm.h index 2447d7ecf179..ee81572a4eec 100644 --- a/sound/usb/6fire/comm.h +++ b/sound/usb/6fire/comm.h @@ -19,7 +19,6 @@ enum /* settings for comm */ struct comm_runtime { struct sfire_chip *chip; - struct urb receiver; u8 *receiver_buffer; u8 serial; /* urb serial */ @@ -30,6 +29,7 @@ struct comm_runtime { int (*write8)(struct comm_runtime *rt, u8 request, u8 reg, u8 value); int (*write16)(struct comm_runtime *rt, u8 request, u8 reg, u8 vh, u8 vl); + struct urb receiver; }; int usb6fire_comm_init(struct sfire_chip *chip);