Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.174 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795942594; b=X4jnt3HyxaXYfGV5MTOxDbRDjKcFEJ/4EBTeJ1lfcGti82Qsmlc82ns8JIDJ3Q33cybU 7nEwxwc8VRHEq6xC0sLB4/CtyjIZvMrd7bevH/jtOFEF2F397rKOG8VcQ4nOg5oXzpIr3 +DtSOMaWMO/U0InHcOcLfqR7xVzUanTz86iuPrgwbgVEaGctjSMVNQ6I3zT6PDteSDu9u Rw/xLSg8WkCY2YZN5gAEUV3xgijDbg6VIMIC8Dc3XkIxT0hH8BCH3WhEK+RCJyWdvbegb w73dzEnzOpvBOsqdqXp4zFJtOBBgBtsSBlqjhhCGgWATLD0qHeMYNCgoQ0jtDdc1BFA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795942594; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=1nXLB3hpFCwugvXZuqXQHCnaCcxjuLJzUskoPcyoK0Y=; b=XNLrDCt5k0sg7cm9eSLcuCsZBUyIdL+YvIdlrbmeddZ6wPIlydwUeRBasQIY2WlZi0Ad XB+FuWIa+5OhtTMzRf1cLYmkkvERvxahbScE3OvZGbLwZ9cOCARcN5nYFuXHCJUqVOFUF frXVfkiy5x5W9nvEs3jCxksIS3d6FJk/sYKRsHYsh9d25xx14NMZCKqeJHqJZprBsKqWp t25WtAEivRNXBIACnmCNCUJl6siiQA+pPt210WXYHlH33nTF1koEFitanTEhAdLUBZ0nS GriN4jvuMBtIutgdlzOgLvk6Oja/TqhSCWbbP7ruu0lbzK9VfcWhZkALV6ieEAIk1lA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="E/u26ASc"; arc=none smtp.remote-ip=209.85.214.174 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ACC4606A689 for ; Sun, 29 Nov 2026 08:56:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7ACC4606A689 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.a=rsa-sha256 header.s=20260707 header.b=E/u26ASc Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2efddf749e5so38707315ad.1 for ; Sun, 29 Nov 2026 00:56:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795942594; x=1796547394; 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=1nXLB3hpFCwugvXZuqXQHCnaCcxjuLJzUskoPcyoK0Y=; b=E/u26AScc/jPlEDbI+XipZjU5TllpUyhrOU49lNasAfa/sfF4qwt6v0Q/E+hSaC6yK wNtyMVDYUAKoxRu4QZ25s0TX2b+nxkIyPthzGX6W2UgnB2BfNI0fic6p0+xLuISI3o90 qtVCQF9D8m5FEgEXW53SpyvtLF/N2i+ned7mX3+FKT9DEA8HHJ2AkBH+2a7LaoKdz6Gw ZiU2kayGw2NGDf+nsNn63Y2n/IGLHBC7iLlmDfACG0u2Ahy1j1Hl591XqUrGVT1ikJOC 8c9LS3GwZz9iZNz5Cq+D4+3ADu5znD/mdGPhRIdA+9gjVT2MtAgQKIQpVj2G2L5DPLGf bCyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795942594; x=1796547394; 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=1nXLB3hpFCwugvXZuqXQHCnaCcxjuLJzUskoPcyoK0Y=; b=idhFKvtzm64ouROuZlgbfNjAB369cqYviTN2Wo9wNAmXOVh4eO2/0wHxV8FGnDosAu Nv4gMJHFXvSz8wR5k4zGih6bjkrkch+z99idX7Y275hbUSLdsaB2RXW1jgplFo6XyTEU wPFCS1z5MaylmiexF6du7Lysa2Wppo3RI1uDq8HFH0DDBcSpRZtOJ6y4QAW1X+JuwRxD /C5tPU6GNx48/XqRIhJkXOM3yC8KqS2LuGHNqHzCWZA19VjkgCk+VwFE/jhDHYvytYDQ umoks0DVyMQRWvEvg7TaUZ0tKKGvJKcdlD/cZdWZhPRxJUBkHJv4E4r+ZG//f9Q/8DQo wX7w== X-Gm-Message-State: APuU4Z+zBUA+ba8w93FGTocrJHrdBKqQaSsVqLNEdNEe1SYLAwbR1Bit U6fUL67kdQVwxT2PJ2GE8B3cNjoYylY9pNy9tl3AfqH+98WQQLuuZRIH X-Gm-Gg: AZFdTZdLJtvGpT0Y8UGGh84LRKoBDBwtMh3xLFoxHrfo8j+OWuBaGqCHeuPglWzbtAZ qBoXaQKEkmg9qNclp4TW5UKe/PvxsEw6LjIiNpWLTl4+XG35Ir2qch1FE1TXKtGq5MEcGSS3+Es U3eRQwkd7W7CZd0vmKNghliV9kAeMF2irpTpEBb8BF6ik/WhxsvVxZnZTFSNZf/SpU0KPT3ToFr +ScrB3V42h55e+dfivQG1cOss8l6A1i3w4/DtENYSJECNX70je/MfNWCWqtGXqEMOrSi0bXtb6A /vmMG4B9ET05s6fZyZzjKwL4zX6BV8VwqmhpRry8S3IIQ7mNF2pkwSBI5jMRxbBhbXHfMIZ8OnS hbl8qF16favwfvZ6AMLl36vx5LJU1q4R+ytX5krHNWgMgNGJhYhTwe6B2EvxCVWNA2RR0lmbDvH rCEBY5zqs4T4ax5wdnJUrJty74dI+/90On4WxDX88hAj1xGndMwmCBAfKSYB94mhoUzkTZnePaK 3GvRkdr8+HeA5yxF4PkPNKEktHXwbfTUN5zP+d1BgfKb1VqEc03vBWFqOtp5xDWa3lDghfGcbP4 uInBhF2lQlBvtgAG20q84cZKMjpTV0Kb3sNZlDwJDvT3Ya8+z8x7bV038lGykxuPFCrv9QRsm4F vRf9DcIDSDHCSsc7mqElN5bk6ANIIUTBWl0VlHH9oc++TC394X/TshBgjoJtjecAygDawGBxtq8 7IPJyXZbihE9uSjA1zhZdnPFGptw== X-Received: by 2002:a17:903:b8e:b0:2dd:86a3:232d with SMTP id d9443c01a7336-2f031e22ce0mr202763775ad.8.1795942593655; Sun, 29 Nov 2026 00:56:33 -0800 (PST) Received: from localhost.localdomain ([2601:1c2:4100:453:29cf:2f71:51d4:4a57]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03f0c2091sm144767735ad.20.2026.11.29.00.56.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 29 Nov 2026 00:56:33 -0800 (PST) From: Jack Wallner To: Kees Cook Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Frank Li , Arnd Bergmann , Greg Kroah-Hartman , linux-pci@vger.kernel.org Subject: [PATCH 3/8] misc: pci_endpoint_test: Use ALIGN() on DMA addresses Date: Sun, 29 Nov 2026 00:56:05 -0800 Message-ID: <20261129085612.22266-4-jackwallner@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261129085612.22266-1-jackwallner@gmail.com> References: <20261129085612.22266-1-jackwallner@gmail.com> X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit PTR_ALIGN() is meant for pointers. The copy, write and read tests pass it a dma_addr_t in four places. That compiles because PTR_ALIGN() casts its argument to unsigned long and back. A later patch in this series makes PTR_ALIGN() do pointer arithmetic on its argument so that the compiler can keep track of the object size. With that change these four lines get -Wint-to-pointer-cast and -Wpointer-to-int-cast warnings on 32-bit kernels with a 64-bit dma_addr_t (x86 with PAE, for example). Use ALIGN(), which works in the type of its argument. There is no change on 64-bit kernels. On a 32-bit kernel with a 64-bit dma_addr_t the old form would drop the upper 32 bits of the address. I have not seen that happen and did not try to trigger it: this is a cleanup and a prerequisite for the PTR_ALIGN() change, not a fix for a reported problem. Compile tested only, including i386 allmodconfig, which has a 64-bit dma_addr_t. The change and this changelog were written by an AI coding assistant (Claude, run in Claude Code) at my direction. See the cover letter for how it was used and tested. Signed-off-by: Jack Wallner --- drivers/misc/pci_endpoint_test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index dd49ca7f4..17d53375e 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -750,7 +750,7 @@ static int pci_endpoint_test_copy(struct pci_endpoint_test *test, } if (alignment && !IS_ALIGNED(orig_src_phys_addr, alignment)) { - src_phys_addr = PTR_ALIGN(orig_src_phys_addr, alignment); + src_phys_addr = ALIGN(orig_src_phys_addr, alignment); offset = src_phys_addr - orig_src_phys_addr; src_addr = orig_src_addr + offset; } else { @@ -782,7 +782,7 @@ static int pci_endpoint_test_copy(struct pci_endpoint_test *test, } if (alignment && !IS_ALIGNED(orig_dst_phys_addr, alignment)) { - dst_phys_addr = PTR_ALIGN(orig_dst_phys_addr, alignment); + dst_phys_addr = ALIGN(orig_dst_phys_addr, alignment); offset = dst_phys_addr - orig_dst_phys_addr; dst_addr = orig_dst_addr + offset; } else { @@ -884,7 +884,7 @@ static int pci_endpoint_test_write(struct pci_endpoint_test *test, } if (alignment && !IS_ALIGNED(orig_phys_addr, alignment)) { - phys_addr = PTR_ALIGN(orig_phys_addr, alignment); + phys_addr = ALIGN(orig_phys_addr, alignment); offset = phys_addr - orig_phys_addr; addr = orig_addr + offset; } else { @@ -979,7 +979,7 @@ static int pci_endpoint_test_read(struct pci_endpoint_test *test, } if (alignment && !IS_ALIGNED(orig_phys_addr, alignment)) { - phys_addr = PTR_ALIGN(orig_phys_addr, alignment); + phys_addr = ALIGN(orig_phys_addr, alignment); offset = phys_addr - orig_phys_addr; addr = orig_addr + offset; } else { -- 2.43.0