lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Sun, 05 Aug 2012 10:16:56 +1000 From: Benjamin Herrenschmidt <benh@...nel.crashing.org> To: Joerg Roedel <joerg.roedel@....com> Cc: Anton Blanchard <anton@....ibm.com>, FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>, linux-kernel@...r.kernel.org Subject: Is iommu_num_pages() broken ? Hi folks ! I stumbled upon this today: static inline unsigned long iommu_num_pages(unsigned long addr, unsigned long len, unsigned long io_page_size) { unsigned long size = (addr & (io_page_size - 1)) + len; return DIV_ROUND_UP(size, io_page_size); } That doesn't look right to me... The powerpc iommu code at least uses that with an addr which may not be page aligned (ie, result of sg_virt() which include the offset). The above code will align the start before adding the len which is wrong and will result in potentially missing a page or am I missing something ? Shouldn't it be something like static inline unsigned long iommu_num_pages(unsigned long addr, unsigned long len, unsigned long io_page_size) { unsigned long start = addr & (io_page_size - 1); unsigned long end = addr + len; return DIV_ROUND_UP(end - start, io_page_size); } ? Cheers, Ben. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists