Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp242711rdb; Fri, 6 Oct 2023 02:00:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbA5cZpR2s0DIERXZ7fEQHcJCJG2UPybJfc+5EwyAHfYIlkkj+t4k5pfyspL3OMpq/QDej X-Received: by 2002:a05:6a00:22c9:b0:690:2ecd:a593 with SMTP id f9-20020a056a0022c900b006902ecda593mr8973877pfj.26.1696582805232; Fri, 06 Oct 2023 02:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696582805; cv=none; d=google.com; s=arc-20160816; b=P4rsmkhczGmFz45T0f2ZABFbgufdulzGBdI92YvNxVBT052SsSrQnaYOrFMzcDdB4e medcGum96eYjJgLNWUMb2yOW/G32sQtzM64tj5zsNhALFRwc3UXs21KscmYNWHFFf4OS qVsZXVs7GRGcO1xCJjGhYntwttQpcYm4zHNyMBFOon5J3mEcVquDjqAEYBm3M7lzZCMK yRqWxCA8hAPJxGjANqLwtgAYKzMgK1bvrzhL4b4XuB/11LHRuy6EC7uYfzrcDA4FZ6Q6 Hu1jhZ+jK45XLjjLzfaOpq1msQ4LeWOQUy3rau6jDFfk5BYq0IzAgfnrYvCpOlQLZG1k v6ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=srsNrgZL9zR7WLAyT/RuTZKhjlgD3sHz3MPU5cn2BWI=; fh=myyKjZzjprqLKGywR+mABZWHwR0F26SfX94yqsD6bUQ=; b=Nv2EU9T/clFr4FMZhXo17VzV3DK/lLCZPHqHQKWcTu1fV+WtKYT2qHgiEg1pKGsYZ4 T/9jf9lzbt1CmlMO6IZKX0Y77UvsGkteP7ZubHxhuylZxkIuHcyEcomt6aeKdiYHrPFl CbJBQemFQqc+BU7MACx3y5cKj5wJVU0MSj2BqlmLL60945eKC8gulSUBn9o1F77OTESr C0aYvXV6zmEovFyr1i0Zp2lENFnexbWbaIIfbWecKv3GnGWMRQHPmU8Psrt5zVCsAkTa GTYZ86GH4AeyOc9Og3K2zKh2x7CIUUt7PtOLmDPRF7E/nFPG2KGT7BueYwEcoqHnpLQP Nqmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=ZCsjFioV; dkim=neutral (no key) header.i=@suse.de header.b=jDkDMmAT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id u9-20020a056a00098900b00690b88a9c32si1114939pfg.82.2023.10.06.02.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 02:00:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=ZCsjFioV; dkim=neutral (no key) header.i=@suse.de header.b=jDkDMmAT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6254680309BC; Fri, 6 Oct 2023 02:00:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231321AbjJFI77 (ORCPT + 99 others); Fri, 6 Oct 2023 04:59:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231293AbjJFI76 (ORCPT ); Fri, 6 Oct 2023 04:59:58 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A469695; Fri, 6 Oct 2023 01:59:56 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 611CD1F896; Fri, 6 Oct 2023 08:59:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1696582795; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=srsNrgZL9zR7WLAyT/RuTZKhjlgD3sHz3MPU5cn2BWI=; b=ZCsjFioV7vYcwiEHo+5WQbDXQfwKOFUSQr8L6NlaRfg3WSyQyj1z8YAytwlDi4zp+II0PG 79QLmVOl5S2tBkOwoRWLBK1FIsQo4zOSkXYasWBJNCnEMUGougG+kPlFI2ak6S+3hUPIe7 k2yv1v/KP5cRYYdRh4+yM0XdBUC4QTc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1696582795; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=srsNrgZL9zR7WLAyT/RuTZKhjlgD3sHz3MPU5cn2BWI=; b=jDkDMmATGw1QHuu5h9nmfyzmoUhPndizF41NCJAiTgTTHXNKphOTcdSwlRub96x085JSWZ /k0EXK0fzmkumhCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 25A6E13A2E; Fri, 6 Oct 2023 08:59:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id todOCIvMH2UbKAAAMHmgww (envelope-from ); Fri, 06 Oct 2023 08:59:55 +0000 Date: Fri, 06 Oct 2023 10:59:54 +0200 Message-ID: <87pm1sw2gl.wl-tiwai@suse.de> From: Takashi Iwai To: "Gustavo A. R. Silva" Cc: Jaroslav Kysela , Takashi Iwai , Jussi Kivilinna , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] ALSA: 6fire: Fix undefined behavior bug in struct comm_runtime In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 (snail.vger.email [0.0.0.0]); Fri, 06 Oct 2023 02:00:04 -0700 (PDT) On Fri, 29 Sep 2023 17:59:22 +0200, Gustavo A. R. Silva wrote: > > `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 Sorry for the late reply, as I've been (still) off since the last week. Through a quick glance, I don't mind much to apply this, but I still wonder how this "fixes" anything. Does it silence compiler warnings or such? Certainly struct urb *may* have flex array, but in this case, it's clearly not used, so it's fixed-size. And, even if we shuffle the member to put to the last, it doesn't fix anything automagically alone. If a flex array were used, it still leads to memory corruption unless we implement the allocation properly. So I find the patch description is somehow misleading. thanks, Takashi > --- > 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); > -- > 2.34.1 >