Re: [PATCH v4 02/18] a.out: remove define-only CMAGIC, previously magic number

From: Geert Uytterhoeven
Date: Mon Sep 26 2022 - 04:16:31 EST


Hi Наб,

CC binfmt

Thanks for your patch, which is now commit 53c2bd679017277f
("a.out: remove define-only CMAGIC, previously magic number") in
driver-core/driver-core-next.

On Fri, Sep 16, 2022 at 12:40 AM наб <nabijaczleweli@xxxxxxxxxxxxxxxxxx> wrote:
> The last user was removed in 5.1 in
> commit 08300f4402ab ("a.out: remove core dumping support")
> but this is part of the UAPI headers, so this may want to either wait
> until a.out is removed entirely, or be removed from the magic number doc
> and silently remain in the header

Indeed. This is part of uapi, and might break some unknown
userspace, while the gain is limited. Do we really want to reduce
include/uapi/linux/a.out.h piecewise (e.g. N_BADMAG() seems to be
unused, too), instead of keeping it until a.out support is removed
completely?

Anyway, even at that point, it might be wise to keep the header file
around, as people have expressed the desire to run a.out binaries
through a userspace-compatibility wrapper.

> A cursory glance on DCS didn't show any user code actually using this
> value

What is DCS?

>
> Found with
> grep MAGIC Documentation/process/magic-number.rst | while read -r mag _;
> do git grep -wF "$mag" | grep -ve '^Documentation.*magic-number.rst:' \
> -qe ':#define '"$mag" || git grep -wF "$mag" | while IFS=: read -r f _;
> do sed -i '/\b'"$mag"'\b/d' "$f"; done ; done
>
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@xxxxxxxxxxxxxxxxxx>
> ---
> Documentation/process/magic-number.rst | 1 -
> Documentation/translations/it_IT/process/magic-number.rst | 1 -
> Documentation/translations/zh_CN/process/magic-number.rst | 1 -
> Documentation/translations/zh_TW/process/magic-number.rst | 1 -
> include/uapi/linux/a.out.h | 3 ---
> 5 files changed, 7 deletions(-)
>
> diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
> index eb2db3608a15..f48c6c6efaf7 100644
> --- a/Documentation/process/magic-number.rst
> +++ b/Documentation/process/magic-number.rst
> @@ -69,7 +69,6 @@ Changelog::
> Magic Name Number Structure File
> ===================== ================ ======================== ==========================================
> PG_MAGIC 'P' pg_{read,write}_hdr ``include/linux/pg.h``
> -CMAGIC 0x0111 user ``include/linux/a.out.h``
> HDLC_MAGIC 0x239e n_hdlc ``drivers/char/n_hdlc.c``
> APM_BIOS_MAGIC 0x4101 apm_user ``arch/x86/kernel/apm_32.c``
> FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h``
> diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
> index 86ef47906f37..27f60133fbe5 100644
> --- a/Documentation/translations/it_IT/process/magic-number.rst
> +++ b/Documentation/translations/it_IT/process/magic-number.rst
> @@ -75,7 +75,6 @@ Registro dei cambiamenti::
> Nome magico Numero Struttura File
> ===================== ================ ======================== ==========================================
> PG_MAGIC 'P' pg_{read,write}_hdr ``include/linux/pg.h``
> -CMAGIC 0x0111 user ``include/linux/a.out.h``
> HDLC_MAGIC 0x239e n_hdlc ``drivers/char/n_hdlc.c``
> APM_BIOS_MAGIC 0x4101 apm_user ``arch/x86/kernel/apm_32.c``
> FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h``
> diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
> index cbefdcbfbf53..520cc5cf4d63 100644
> --- a/Documentation/translations/zh_CN/process/magic-number.rst
> +++ b/Documentation/translations/zh_CN/process/magic-number.rst
> @@ -58,7 +58,6 @@ Linux 魔术数
> 魔术数名 数字 结构 文件
> ===================== ================ ======================== ==========================================
> PG_MAGIC 'P' pg_{read,write}_hdr ``include/linux/pg.h``
> -CMAGIC 0x0111 user ``include/linux/a.out.h``
> HDLC_MAGIC 0x239e n_hdlc ``drivers/char/n_hdlc.c``
> APM_BIOS_MAGIC 0x4101 apm_user ``arch/x86/kernel/apm_32.c``
> FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h``
> diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
> index 7fd6e494467b..7d6debd0117e 100644
> --- a/Documentation/translations/zh_TW/process/magic-number.rst
> +++ b/Documentation/translations/zh_TW/process/magic-number.rst
> @@ -61,7 +61,6 @@ Linux 魔術數
> 魔術數名 數字 結構 文件
> ===================== ================ ======================== ==========================================
> PG_MAGIC 'P' pg_{read,write}_hdr ``include/linux/pg.h``
> -CMAGIC 0x0111 user ``include/linux/a.out.h``
> HDLC_MAGIC 0x239e n_hdlc ``drivers/char/n_hdlc.c``
> APM_BIOS_MAGIC 0x4101 apm_user ``arch/x86/kernel/apm_32.c``
> FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h``
> diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
> index 5fafde3798e5..bb15da96df2a 100644
> --- a/include/uapi/linux/a.out.h
> +++ b/include/uapi/linux/a.out.h
> @@ -70,9 +70,6 @@ enum machine_type {
> The first page is unmapped to help trap NULL pointer references */
> #define QMAGIC 0314
>
> -/* Code indicating core file. */
> -#define CMAGIC 0421
> -
> #if !defined (N_BADMAG)
> #define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
> && N_MAGIC(x) != NMAGIC \

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds