machine/param.h Leak of non-standard methods to Application Space

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Oct 18 05:08:40 UTC 2018


On 17/10/2018 17:04, Joel Sherrill wrote:
> Hi
>
> We are updating the port of a large third party framework and ran
> into an issue where what I would think are BSD kernel methods
> leak into application space. All but one of the methods is used
> by rtems-libbsd code.
>
> I think the following in <machine/param.h> needs to be protected by
> an _KERNEL ifdef.
>
> Does that sound OK?
>
> ============================
> /*
>  * Mach derived conversion macros
>  */
> #define round_page(x)           (((unsigned long)(x) + PAGE_MASK) & 
> ~PAGE_MASK)
> #define trunc_page(x)           ((unsigned long)(x) & ~PAGE_MASK)
>
> #define atop(x)                 ((unsigned long)(x) >> PAGE_SHIFT)
> #define ptoa(x)                 ((unsigned long)(x) << PAGE_SHIFT)
>
> #define pgtok(x)                ((unsigned long)(x) * (PAGE_SIZE / 1024))
> ============================

In FreeBSD they are always present:

https://github.com/freebsd/freebsd/blob/master/sys/riscv/include/param.h#L97

The <sys/param.h> is not a POSIX header file. Unfortunately it is 
included in <sys/_cpuset.h> and thus in <rtems.h>. I think we should fix.

Are these macros only used in kernel-space files in libbsd?

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list