* [PATCH] setfont: Initialize data pointer when resetting font
@ 2025-12-05 18:18 Yutao Zhang
2025-12-07 17:13 ` Alexey Gladkov
0 siblings, 1 reply; 2+ messages in thread
From: Yutao Zhang @ 2025-12-05 18:18 UTC (permalink / raw)
To: kbd; +Cc: Tommy-Zhang3759
From: Tommy-Zhang3759 <tommyzhang4707@outlook.com>
When resetting the font to default, the `data` field in the
`console_font_op` structure must be explicitly set to NULL.
Previously, this field was left uninitialized. The kernel treats a
non-NULL `data` pointer as a pointer to a font name string. This caused
the ioctl to fail with -EFAULT (Bad address) because it attempted to
read from a garbage address.
Signed-off-by: Yutao Zhang <tommyzhang4707@outlook.com>
---
src/libkfont/kdfontop.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/libkfont/kdfontop.c b/src/libkfont/kdfontop.c
index 8f132ff..4f1f0d2 100644
--- a/src/libkfont/kdfontop.c
+++ b/src/libkfont/kdfontop.c
@@ -46,6 +46,7 @@ kfont_restore_font(struct kfont_context *ctx, int fd)
return -1;
cfo.op = KD_FONT_OP_SET_DEFAULT;
+ cfo.data = NULL;
if (ioctl(fd, KDFONTOP, &cfo)) {
KFONT_ERR(ctx, "ioctl(KD_FONT_OP_SET_DEFAULT): %m");
--
2.52.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] setfont: Initialize data pointer when resetting font
2025-12-05 18:18 [PATCH] setfont: Initialize data pointer when resetting font Yutao Zhang
@ 2025-12-07 17:13 ` Alexey Gladkov
0 siblings, 0 replies; 2+ messages in thread
From: Alexey Gladkov @ 2025-12-07 17:13 UTC (permalink / raw)
To: Yutao Zhang; +Cc: kbd
On Sat, Dec 06, 2025 at 05:18:43AM +1100, Yutao Zhang wrote:
> From: Tommy-Zhang3759 <tommyzhang4707@outlook.com>
>
> When resetting the font to default, the `data` field in the
> `console_font_op` structure must be explicitly set to NULL.
>
> Previously, this field was left uninitialized. The kernel treats a
> non-NULL `data` pointer as a pointer to a font name string. This caused
> the ioctl to fail with -EFAULT (Bad address) because it attempted to
> read from a garbage address.
>
> Signed-off-by: Yutao Zhang <tommyzhang4707@outlook.com>
Applied. Thanks!
> ---
> src/libkfont/kdfontop.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/src/libkfont/kdfontop.c b/src/libkfont/kdfontop.c
> index 8f132ff..4f1f0d2 100644
> --- a/src/libkfont/kdfontop.c
> +++ b/src/libkfont/kdfontop.c
> @@ -46,6 +46,7 @@ kfont_restore_font(struct kfont_context *ctx, int fd)
> return -1;
>
> cfo.op = KD_FONT_OP_SET_DEFAULT;
> + cfo.data = NULL;
>
> if (ioctl(fd, KDFONTOP, &cfo)) {
> KFONT_ERR(ctx, "ioctl(KD_FONT_OP_SET_DEFAULT): %m");
> --
> 2.52.0
>
>
--
Rgrds, legion
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-07 17:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-05 18:18 [PATCH] setfont: Initialize data pointer when resetting font Yutao Zhang
2025-12-07 17:13 ` Alexey Gladkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox