Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2387292lqp; Sun, 24 Mar 2024 17:10:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU8t2xIXiA4Sz6DiMFn6x5axLUcvB6fCPOVEaUg7sGwlDtRZxUiq645qOJy8XPDokt2V2G72xZsFMRFHTLpGlTMAgTyY0muVe0HDfwyPw== X-Google-Smtp-Source: AGHT+IEw1hAOGYRgMY6cFvqbSR+WFSf8Xloibqu/wHW7EJtZU7PD9LWaMRDztomnWgAOff0lGEs2 X-Received: by 2002:a05:6a00:1489:b0:6e7:3216:507b with SMTP id v9-20020a056a00148900b006e73216507bmr5817913pfu.13.1711325434968; Sun, 24 Mar 2024 17:10:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711325434; cv=pass; d=google.com; s=arc-20160816; b=mh3VkzDHCGCOXYdrjy2neUwHvyUj+DI4KkmYyfqeaLQndXTDdCdobr80lNkRmhtf5x XqZzoSgc6RI4J+8xz7RzSgXO4ePJLFdF4D3SxPSFSwqISyvzfVQTOPzmgObxZmwQSlbq LZC01ytEDTtATXzKxlixOwh/ZKOowVzvchru6fOoKvApg5ji6+I3mIdLZJesZDFUXt/n TAHfB+uUK4S/M0TJ6Vde8tVKai8SU5tIE1RE2F/jvI1KRCRcxXh3aVqXsObKRN7TLp4t pVZLluhzJS0gGZXhbQ1cfaXEpx8o4Q95A4BVFOWNKrcbaTFUPCEFISq20Ic1E8Q+Vmsm EqwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=d93Iq979C00Cm0nW9rrP/eD0YsyGTG7ZcwWQ/HG1W4g=; fh=bMNKZ7ybmBmtJ9ZN0DsIraF1RdLwlTOItTNQ9utm064=; b=pHc42j5EpZu0fHn71cYv+V6fkmeNLhN3Ow0R1hNJWDpVz2J6jC/2Mia9h4Ew2sQ3uq Z5dJLRzm1CtafR7eeQva9YxVzCzEmDuQpCsCtSojhdjm+b7hRKIP+hDiHRRiU8/D7HoK 8ZVl/0SNv6TyYRH2sMR4EVGHkcBxm6N59z+6Yhkp3tIsJ1pn631EPcFQe+KcILkW2Om5 CFKYakSTBsgVapgY1EJsAz4br/TJEV4Qi23YOnfqyN85a4rSo8VVN9UxLqD6qzwXJWhO +tPqVSnUXiPKz9nTLkmisEfwkf3r7suTOZGYsrFXGu5XmA9dhmcj/yQ7HHizfLx0pzKM 3sfg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tn8lX06L; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113314-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 6-20020a631746000000b005d8bb0cd282si6285741pgx.126.2024.03.24.17.10.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:10:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113314-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tn8lX06L; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113314-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5753F282486 for ; Mon, 25 Mar 2024 00:07:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07745193864; Sun, 24 Mar 2024 22:41:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tn8lX06L" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E056193175; Sun, 24 Mar 2024 22:41:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320115; cv=none; b=J6SaU3Ficlt0bAPLGy56eILXaT0mwKiKnJdpN21RXwpERAIkOVgwCHTmL2/PZgfeM/5ubRyZDDNqzv/navEzC1g2glJwgilCCxQd/UlE84GCsxF5+Yphh6NXfj7+4vapu0OUK8SaN1NsLRaWeEhaSl74NGC1HwDoMlIoQYhw96Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320115; c=relaxed/simple; bh=h8BdH7BljQ0FdEXcZo6/KF7jYRa7kna71QzsImwJywI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EPnTTTbjh56JtqXcmMBvezUJaDeG/KhU0PUZ50SU2sv5O6Olv7cvgF2W26ckv1jJi4eLImIGOgyTrCiAaCZEL6SJWJHFGVuUNpBJUiPrtCymYg7ooMD2NPEN6gR4zAR/obimcAYmgRFQkgWXOcTIeanUP2snGi8sDbSboS2qkbY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tn8lX06L; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D5DBC43399; Sun, 24 Mar 2024 22:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320114; bh=h8BdH7BljQ0FdEXcZo6/KF7jYRa7kna71QzsImwJywI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tn8lX06LMZ9bQyDbSSoabLn+JcFz3i7H3dzncMnnp4emIE4ugEdWFFAGunqgLnzPO LMfsemgNmJAvk1Vuc7x/V380BL933hBP4M4ucAULf0FKJy3We8+94a7bpQ2lp6gXpp 6VZ/QYn/eDgcyc3pxCSf3FnwXsh1vj6SJg8IcA4OtpgtXjySYmScM/74LiUt5fBBJn s/LeTXyQ17MmZQo6oi9wPlPJrfZhoYwhCHN5BHZ+vAwqpWlBmu66EqkPcN816d7EFO /8g744XuuHHKVnLVFwuP+etoXtiJ/exf1iSjSlhuNDawT6AJIB5NvN6HvmY6H+Ic2F ZyexER8cdMSTQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , Arnd Bergmann , Sasha Levin Subject: [PATCH 6.8 423/715] ALSA: seq: fix function cast warnings Date: Sun, 24 Mar 2024 18:30:02 -0400 Message-ID: <20240324223455.1342824-424-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Takashi Iwai [ Upstream commit d7bf73809849463f76de42aad62c850305dd6c5d ] clang-16 points out a control flow integrity (kcfi) issue when event callbacks get converted to incompatible types: sound/core/seq/seq_midi.c:135:30: error: cast from 'int (*)(struct snd_rawmidi_substream *, const char *, int)' to 'snd_seq_dump_func_t' (aka 'int (*)(void *, void *, int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict] 135 | snd_seq_dump_var_event(ev, (snd_seq_dump_func_t)dump_midi, substream); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/core/seq/seq_virmidi.c:83:31: error: cast from 'int (*)(struct snd_rawmidi_substream *, const unsigned char *, int)' to 'snd_seq_dump_func_t' (aka 'int (*)(void *, void *, int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict] 83 | snd_seq_dump_var_event(ev, (snd_seq_dump_func_t)snd_rawmidi_receive, vmidi->substream); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For addressing those errors, introduce wrapper functions that are used for callbacks and bridge to the actual function call with pointer cast. The code was originally added with the initial ALSA merge in linux-2.5.4. [ the patch description shamelessly copied from Arnd's original patch -- tiwai ] Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: Arnd Bergmann Link: https://lore.kernel.org/r/20240213101020.459183-1-arnd@kernel.org Link: https://lore.kernel.org/r/20240213135343.16411-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/core/seq/seq_midi.c | 8 +++++++- sound/core/seq/seq_virmidi.c | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c index 18320a248aa7d..78dcb0ea15582 100644 --- a/sound/core/seq/seq_midi.c +++ b/sound/core/seq/seq_midi.c @@ -113,6 +113,12 @@ static int dump_midi(struct snd_rawmidi_substream *substream, const char *buf, i return 0; } +/* callback for snd_seq_dump_var_event(), bridging to dump_midi() */ +static int __dump_midi(void *ptr, void *buf, int count) +{ + return dump_midi(ptr, buf, count); +} + static int event_process_midi(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop) { @@ -132,7 +138,7 @@ static int event_process_midi(struct snd_seq_event *ev, int direct, pr_debug("ALSA: seq_midi: invalid sysex event flags = 0x%x\n", ev->flags); return 0; } - snd_seq_dump_var_event(ev, (snd_seq_dump_func_t)dump_midi, substream); + snd_seq_dump_var_event(ev, __dump_midi, substream); snd_midi_event_reset_decode(msynth->parser); } else { if (msynth->parser == NULL) diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index 1b9260108e482..1678737f11be7 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -62,6 +62,13 @@ static void snd_virmidi_init_event(struct snd_virmidi *vmidi, /* * decode input event and put to read buffer of each opened file */ + +/* callback for snd_seq_dump_var_event(), bridging to snd_rawmidi_receive() */ +static int dump_to_rawmidi(void *ptr, void *buf, int count) +{ + return snd_rawmidi_receive(ptr, buf, count); +} + static int snd_virmidi_dev_receive_event(struct snd_virmidi_dev *rdev, struct snd_seq_event *ev, bool atomic) @@ -80,7 +87,7 @@ static int snd_virmidi_dev_receive_event(struct snd_virmidi_dev *rdev, if (ev->type == SNDRV_SEQ_EVENT_SYSEX) { if ((ev->flags & SNDRV_SEQ_EVENT_LENGTH_MASK) != SNDRV_SEQ_EVENT_LENGTH_VARIABLE) continue; - snd_seq_dump_var_event(ev, (snd_seq_dump_func_t)snd_rawmidi_receive, vmidi->substream); + snd_seq_dump_var_event(ev, dump_to_rawmidi, vmidi->substream); snd_midi_event_reset_decode(vmidi->parser); } else { len = snd_midi_event_decode(vmidi->parser, msg, sizeof(msg), ev); -- 2.43.0