From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1464D2494F0 for ; Sun, 14 Jun 2026 15:16:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781450198; cv=none; b=LpTSeNaSaSHuwcpUnrMzDtY105YXvy6L9ozkvAAmJdHobtfx9dwxhcs09DnNSR+G6sVwSg7A2zcZpIVa5GnMUAfzp+DFM4/OHwcNGVjZos+fqLa2zjD1KGamFmDG00UX1WK6xMHpb0K2vAMoJIfAC40aTzIpF6fJg23Kh9ni8v4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781450198; c=relaxed/simple; bh=Tq/NlSsth9vI+z9s+xS4rbGf4t0qLVGa0rTsVnZFj7A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=aLs9pn9IGcxiOP3V4u++H8By4ZJyXibSnroabjQH/a5YWHLvBvwPuV1L9vRQtzidIG+gb2JJWgyEli7HofRG5HvlRNe2dITAeecCej2FgWPJnSt9hvl4kyO+O1p5Bo5woXGHugj+PrvXhCRSCJrT41xgXt06hR+LNL6W0Rq6Oc4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JcczSB2L; arc=none smtp.client-ip=209.85.160.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JcczSB2L" Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-51761d27612so31403761cf.3 for ; Sun, 14 Jun 2026 08:16:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781450195; x=1782054995; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nYFGdByGc/O9rZdW56KvG/nv6eJEgoe9jBWivYkD0UY=; b=JcczSB2L0zR00Xv/YCbpPIL1ChkvR12QZ4pa/l3kwf4dCNlnJCd2kBo8vURkVFAbDE Kdyd4KvpbieF6I4/0E1cqhyWJhEUY8PXnHpTmUsonV1G6hoelmfFu17KDr+Ubwtupj4O +Q52wEmhKBlyMbbTKpKuJ/djGuUkpv2H7Y8LisZnzSFF4e5UI3B4w566LJAOdba4Gj7n VCPM38I4+174fgSFQ5we+ASNIHaJ18VC7+tm5wufh+h/AY1M3g7CvyXuQA/YDATbDof0 Hf1rZ+nxke33kS+L829+JxNk44DUhRz8WTqqL259rg9fA1URqoDP+ryYEbde7wzN5yQ4 0bqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781450195; x=1782054995; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nYFGdByGc/O9rZdW56KvG/nv6eJEgoe9jBWivYkD0UY=; b=JsBPuUGxjAnwNq54gOJ6/5nu+1aTK9QhnpoT3uCuVQnfUgbc7WRhtZgCZSz+u6f8IF qpRWcLqmipcREUm9IG3eZWsxq7r/IVTr8V/G2tuXoCHYq92hu386MNIQ323IGYchcz4i Bp3kBFN5rNSixdjMtVH6nj6l7aSRF5qrUllQqz5z8PoTX8wmj/s50p8T043hUtemriNa yvGGPWWhCC6KMbYwvz1AT27Yrt4A3OMdezEH7QhGiZdzNBbopLK12I0DZwd0GsysNtzr NLl/sTHoTQv9ESifmb9Iprcq3ZKbln57ho74T3t1v4Kx5aHdsUqrN7tlZv2oSzXx16oI srLA== X-Forwarded-Encrypted: i=1; AFNElJ/6faWzcpHHCvPINOdEJGhIFQtRUBlvyeC1FvOYF0TVKeKSP59MhiskHxf5EdLgD/qNkuBus2KlEu4b77I=@vger.kernel.org X-Gm-Message-State: AOJu0YwtHxg3/E9ypB9e4Sshxa+Z21MpFMDQmuuyZbRN7UDah++BhV94 e9XCFPLT3vcSU6cUpiopdvh5VKsXLcQupIJATuXH5b7y/K/4AtGI2GJD X-Gm-Gg: Acq92OHduIbjRfXJoNL0RG9+1IA1FX+N2WIOQ3EQA7ipxGqgFr/CoFk+ekIBXg5mYFa y7tN8T+NIysHIbrbCCTzSeQ5ieWd715bKTcLAjBOIaDVmgKXhh5GtZLDUFbTLpy+Q15T8Otw75R /PH5GU8I6is1NbTd/5PqmF3d+jSiQHcNIgOmPaEpJz86xp9oehmRjnPHtT/oCr7qBFxY1QdrjHR xTrFeRoSdb0JSVWcuejiaRcVGZU8du4alcZ6PLtxXQ2GOrJuzwlUvEyD8HIIeXGSpRZKU93ikdZ sgxNMghZH249FT4xwQoIGmWv1bkCJKKXRaXeiHNFT3/hXBkem+L9V1M2YMWHLoI7KirYUSC1HqH iS8Brshyj2rAZ+yAo+x5HHAoh2KCe2xm7kaCS4ErR3xY5DXjUrioiNePK7mU1LsDxlSqexH0ur6 COomLgZMr+uUBQRhsLeuQDjBi/whYOACm33Ye1VShcR2ByjN/TQL8n06VZn2946tvI5OoRIMXPS WVrkcKq8UBylomQ918nSHjKsfMmQtB1yjeYYM5Q/nI= X-Received: by 2002:a05:622a:4a88:b0:517:9d3f:8f3 with SMTP id d75a77b69052e-517fe4de95dmr175063101cf.5.1781450194740; Sun, 14 Jun 2026 08:16:34 -0700 (PDT) Received: from server0.tail6e7dd.ts.net (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-9161a0541d3sm774999085a.39.2026.06.14.08.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2026 08:16:33 -0700 (PDT) From: Michael Bommarito To: Takashi Sakamoto Cc: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] firewire: core: propagate cycle-timer read failure in legacy ioctl Date: Sun, 14 Jun 2026 11:15:43 -0400 Message-ID: <20260614151543.2976015-1-michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit The legacy FW_CDEV_IOC_GET_CYCLE_TIMER handler ioctl_get_cycle_timer() reads into a local struct fw_cdev_get_cycle_timer2 via ioctl_get_cycle_timer2() and then copies tv_sec, tv_nsec and cycle_timer into the user-visible output, but it ignores the helper's return value. Since commit bacf921c42bb ("firewire: core: use guard macro to disable local IRQ") the helper returns early on fw_card_read_cycle_time() failure (for example -ENODEV after the dummy card driver is swapped in during controller removal) without writing those fields, so the wrapper copies out the uninitialized local: 12 of the 16 user-visible bytes are uninitialized kernel stack. The non-legacy ioctl already returns the error on this path. Propagate the helper return value so no output is copied on failure. Reproduced under KMSAN; the legacy wrapper no longer returns uninitialized cycle-timer bytes after this change. Fixes: bacf921c42bb ("firewire: core: use guard macro to disable local IRQ") Cc: stable@vger.kernel.org # v6.12+ Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Michael Bommarito --- Reproduction (v7.1-rc4, x86_64 QEMU, CONFIG_KMSAN=y, stack auto-init off): With fw_card_read_cycle_time() forced to fail, the stock legacy handler returns 0 and KMSAN reports the uninitialized local being stored to the output: BUG: KMSAN: uninit-value in ioctl_get_cycle_timer Local variable ct2 created at: ioctl_get_cycle_timer The leaked output is local_time (8 bytes, bytes 0-7, computed from the uninitialized tv_sec/tv_nsec) and cycle_timer (4 bytes, bytes 8-11, copied verbatim). After this change the handler returns -ENODEV and the KMSAN reports are gone; a success-path control stays clean. drivers/firewire/core-cdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index f791db4c8dfff..1d80e30cb681e 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -1283,9 +1283,12 @@ static int ioctl_get_cycle_timer(struct client *client, union ioctl_arg *arg) { struct fw_cdev_get_cycle_timer *a = &arg->get_cycle_timer; struct fw_cdev_get_cycle_timer2 ct2; + int ret; ct2.clk_id = CLOCK_REALTIME; - ioctl_get_cycle_timer2(client, (union ioctl_arg *)&ct2); + ret = ioctl_get_cycle_timer2(client, (union ioctl_arg *)&ct2); + if (ret < 0) + return ret; a->local_time = ct2.tv_sec * USEC_PER_SEC + ct2.tv_nsec / NSEC_PER_USEC; a->cycle_timer = ct2.cycle_timer; base-commit: e24a98d6884a6e4203a77a94f070a59fcab95208 -- 2.53.0