From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 0DDAD37CD42 for ; Sun, 9 Aug 2026 07:16:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786259807; cv=none; b=rSh48lAdKSA9sTgg9Y12y7U+E9AyPINw+O9hpj7GafUGLgxUJeJ/j3AJTKn27DCr4j+USptexfUvMdsJh4/1lA8ULjwmf6YpF16nnpY3qt5yY2B6AlbMiumVPSFify+5kgeBkHfErn2nLMSU2zb62H4yKKkoCA6CtNjz1ajL8O0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786259807; c=relaxed/simple; bh=Ng0dHs3X9wQVhe1ERH80lRumo9icxJFHkEBbVAZydvc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=biAsxrXgbJgiyfVObactVHCvJY1b0YHWV1jAA2XJf+SBcVueIca6hmKqLcZOcfC+RxZosthkjOmnniHWhGX+Rzgy5pqww7CFZm+bm1U5odHb0ElvFxox8sG2G3hkzGHIUJXDHMD7IcKZ0Lt6rzCJmpnJXTdBjCWhJt/UkrOmIRw= 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=YtyV5DbP; arc=none smtp.client-ip=209.85.216.50 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="YtyV5DbP" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-38d489b6b71so751232a91.0 for ; Sun, 09 Aug 2026 00:16:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786259805; x=1786864605; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=6/zrl6clmXEtZvk4idWU7qHREwz822KaQXUlYrmnYcY=; b=YtyV5DbP+kMs3JWcWLXVYMTmTfTcrPk7IQF3UlZR9+LWALGRYrNY8gSTinRW7ADjLV 0km/hs7l4zYzPFVx1M6ioua45woval+PN/zmF3c0zd3B8HZN/4p6+YHbzvmB+sf1RVP9 1ohBcwVVxWPm/ZeoDg1QY7xN3WAxWii4SpI+wQAXBYeYPDgZbNeOXEBO85RVeWv0z01t AEhIT0h07Y6R5dzyE+e80P/16lOEX/hf+ixq9yTgAYP+wbVtL/AHWZtCzSxx0Dj6tsU6 fFvWpzZNBsJTxhyffm47OWMJYf6OU7ZuMGopdg7jk4GdUoxfk34ECKWto9EwbZRDZQsz SoNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786259805; x=1786864605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=6/zrl6clmXEtZvk4idWU7qHREwz822KaQXUlYrmnYcY=; b=gwpIZCV2y9KCVPxYnRyWx599rR+PhWbB3A1qi7wxIIWYGI5e1VMNQLVig3kIIXbcQZ Ks/a1OXQPEUZO36GqtNlUUEizZpro4skOJp2dE2To2NOik5N9TuoAzdt1o61N3VHEM8p YfWl7t/ovFcaZ0SRePE9OXyZ/VWzmQ7C2uzZZOjXDzazoCkbOuv1mU0RJj0NJrVp8nUR KqCZOkMjHwRjf0RwNM4l9UVMGsTpxS0nxumU+rSnClmjmXIjpJcsW9/3xWQ8wyXFL6zV W/Tu/bPD03qpummFFF7vvefv/8YsVUGbez9szDdb//kuu7OKV5LT0eCqjLqVfJLxZWNr imTA== X-Forwarded-Encrypted: i=1; AHgh+RrSWV2vbVkEhp/nldWqr8U7eFi4Qehub0mBz6KAwqMXFgqF+eFo2G8AQa0QxSRDtpre8IekiWBLgtwrg38=@vger.kernel.org X-Gm-Message-State: AOJu0YyUP8cXZFXFlYbW4fMfD1wPj9qTm5c/22nDq1weRJcz2pIH9TEq k2w/evNqDf3Cb2GkISc7xxPuVYj5ZrvUMBUwx6MhRhKSj/LLCsXgKv1m X-Gm-Gg: AR+sD12C/wKyakAP9VmfIx5tBTWYvWiXMDwMieNAlIEKSe9rE+K2LC+2aVazd0XIO30 CL3a4T8QWDSKU8jFdmCalWAq69Lru5ClqkJyrTd6MNUgluI4j7vjdxogq0mqFFnHOysXofj7+7e MZJJkmGO2Q0UG3vR2wL4GqUl9yVMn0cda7LA5BmvuFC6FqWwuTMtK+56EMIXUL6TQbLvz6Y8mJZ KpDcssq80VZWEQrz7a0PAYxP69cN/Zv5k86yn3vMcCwA9JhNlNWoiRsK9WnZeLAvyryLUPIxhpA Qd/lM6rkG9v2S92CMCIPsFhethdZlfd3roxSUScZBvF0+NAxchJMKlSmbD3mUB6lzb9hnAMy8eZ JVEJCp+ye1DsKTcXkV7EC1uxAv8vqhejXpKBUtxa2nhJ0AlfUiBL32JiS1l5XSGkvE6vox4lsAS XU1043QRXub24d3BUTdQVUnJnzdvmPV8twJ7TS8BYL6H1UL3raFpyfCXpPbUf6 X-Received: by 2002:a17:90b:1e43:b0:392:b509:b1a5 with SMTP id 98e67ed59e1d1-392b509b300mr415412a91.14.1786259805247; Sun, 09 Aug 2026 00:16:45 -0700 (PDT) Received: from ubuntu.. ([219.241.133.184]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-390b343e662sm3296002a91.2.2026.08.09.00.16.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2026 00:16:44 -0700 (PDT) From: Rihyeon Kim To: kartikey406@gmail.com Cc: bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+7134530b25073b4ef373@syzkaller.appspotmail.com Subject: Re: [PATCH] PCI: sysfs: Reject unaligned resource I/O port accesses Date: Sun, 9 Aug 2026 16:16:39 +0900 Message-ID: <20260809071639.21204-1-rihyeon8648@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260809045946.15638-1-kartikey406@gmail.com> References: <20260809045946.15638-1-kartikey406@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Sun Aug 9, 2026 at 4:59 AM UTC, Deepanshu Kartikey wrote: > + if (!IS_ALIGNED(port, count)) > + return -EINVAL; You beat me to it :) I had the same change under test here, so rather than send a duplicate patch, here are the results. I had already run the same diff through a syzbot test. Quoting the result for reference, since it went to linux-kernel and not to linux-pci: > syzbot has tested the proposed patch and the reproducer did not trigger any issue: > > Reported-by: syzbot+7134530b25073b4ef373@syzkaller.appspotmail.com > Tested-by: syzbot+7134530b25073b4ef373@syzkaller.appspotmail.com > > Tested on: > > commit: ba5cc80f Merge branch 'for-next/core' into for-kernelci > git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git > console output: https://syzkaller.appspot.com/x/log.txt?x=15898149580000 > kernel config: https://syzkaller.appspot.com/x/.config?x=ccf4bea59f67007 > dashboard link: https://syzkaller.appspot.com/bug?extid=7134530b25073b4ef373 > userspace arch: arm64 > patch: https://syzkaller.appspot.com/x/patch.diff?x=1431e132580000 I also tested it locally, on v7.2-rc4 arm64 defconfig under qemu 9.2, with and without this hunk, over every offset and width on an I/O BAR. The unaligned 2- and 4-byte accesses go from oopsing to -EINVAL in both directions, and every aligned access is unchanged. Widths of 3, 5 and 8 return -EINVAL before and after, so the IS_ALIGNED() point the bot raised makes no difference in practice: with a non-power-of-two count the test is meaningless, and the switch rejects the width anyway. Tested-by: Rihyeon Kim I wonder if it is worth mentioning in the commit log that the two directions are not the same here. You already say pread64() hits it too, but pci_write_resource() calls security_locked_down() with LOCKDOWN_PCI_ACCESS while pci_read_resource() has no such check, so with lockdown at integrity or above the write is refused and the read still faults. Both need root either way, since the attribute is 0600, so maybe it is noise; feel free to ignore. I went through the same thing in the syzbot thread earlier today, if any of it is useful: https://lore.kernel.org/all/20260809012855.109608-1-rihyeon8648@gmail.com/ Thanks, Rihyeon Kim