mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pps: clients: ldisc: Fix uninitialized info.echo in pps_tty_open()
@ 2026-11-30 22:54 Ian Rogers
  2026-12-01  8:30 ` Rodolfo Giometti
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2026-11-30 22:54 UTC (permalink / raw)
  To: Rodolfo Giometti, Greg Kroah-Hartman
  Cc: Jiri Slaby, Nathan Chancellor, linux-serial, llvm, linux-kernel,
	Ian Rogers

pps_tty_open() declares struct pps_source_info info on the stack without
an initializer and never initializes info.echo before calling
pps_register_source(&info, ...). pps_register_source() copies the entire
struct via pps->info = *info, leaving pps->info.echo with uninitialized
stack contents that are read by echo_show() when /sys/class/pps/ppsX/echo
is read.

Initialize info using a designated initializer so info.echo and any
remaining fields are zero-initialized, found with Clang's
require_explicit_initialization attribute.

Fixes: a0880df0ccde ("pps: serial clients support")
Signed-off-by: Ian Rogers <irogers@google.com>
---
Note: Found using Clang's require_explicit_initialization attribute;
an AI coding assistant helped audit call sites, verify Fixes commits,
and draft the changelog.

 drivers/pps/clients/pps-ldisc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/pps/clients/pps-ldisc.c b/drivers/pps/clients/pps-ldisc.c
index fa5660f3c4b7..dc24b2a32236 100644
--- a/drivers/pps/clients/pps-ldisc.c
+++ b/drivers/pps/clients/pps-ldisc.c
@@ -40,19 +40,19 @@ static int (*alias_n_tty_open)(struct tty_struct *tty);
 
 static int pps_tty_open(struct tty_struct *tty)
 {
-	struct pps_source_info info;
+	struct pps_source_info info = {
+		.owner = THIS_MODULE,
+		.mode = PPS_CAPTUREBOTH |
+			PPS_OFFSETASSERT | PPS_OFFSETCLEAR |
+			PPS_CANWAIT | PPS_TSFMT_TSPEC,
+	};
 	struct tty_driver *drv = tty->driver;
 	int index = tty->index + drv->name_base;
 	struct pps_device *pps;
 	int ret;
 
-	info.owner = THIS_MODULE;
-	info.dev = NULL;
 	snprintf(info.name, PPS_MAX_NAME_LEN, "%s%d", drv->driver_name, index);
 	snprintf(info.path, PPS_MAX_NAME_LEN, "/dev/%s%d", drv->name, index);
-	info.mode = PPS_CAPTUREBOTH | \
-			PPS_OFFSETASSERT | PPS_OFFSETCLEAR | \
-			PPS_CANWAIT | PPS_TSFMT_TSPEC;
 
 	pps = pps_register_source(&info, PPS_CAPTUREBOTH | \
 				PPS_OFFSETASSERT | PPS_OFFSETCLEAR);

base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] pps: clients: ldisc: Fix uninitialized info.echo in pps_tty_open()
  2026-11-30 22:54 [PATCH] pps: clients: ldisc: Fix uninitialized info.echo in pps_tty_open() Ian Rogers
@ 2026-12-01  8:30 ` Rodolfo Giometti
  0 siblings, 0 replies; 2+ messages in thread
From: Rodolfo Giometti @ 2026-12-01  8:30 UTC (permalink / raw)
  To: Ian Rogers, Greg Kroah-Hartman, Andrew Morton
  Cc: Jiri Slaby, Nathan Chancellor, linux-serial, llvm, linux-kernel

On 30/11/2026 23:54, Ian Rogers wrote:
> pps_tty_open() declares struct pps_source_info info on the stack without
> an initializer and never initializes info.echo before calling
> pps_register_source(&info, ...). pps_register_source() copies the entire
> struct via pps->info = *info, leaving pps->info.echo with uninitialized
> stack contents that are read by echo_show() when /sys/class/pps/ppsX/echo
> is read.
> 
> Initialize info using a designated initializer so info.echo and any
> remaining fields are zero-initialized, found with Clang's
> require_explicit_initialization attribute.
> 
> Fixes: a0880df0ccde ("pps: serial clients support")
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> Note: Found using Clang's require_explicit_initialization attribute;
> an AI coding assistant helped audit call sites, verify Fixes commits,
> and draft the changelog.
> 
>  drivers/pps/clients/pps-ldisc.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pps/clients/pps-ldisc.c b/drivers/pps/clients/pps-ldisc.c
> index fa5660f3c4b7..dc24b2a32236 100644
> --- a/drivers/pps/clients/pps-ldisc.c
> +++ b/drivers/pps/clients/pps-ldisc.c
> @@ -40,19 +40,19 @@ static int (*alias_n_tty_open)(struct tty_struct *tty);
>  
>  static int pps_tty_open(struct tty_struct *tty)
>  {
> -	struct pps_source_info info;
> +	struct pps_source_info info = {
> +		.owner = THIS_MODULE,
> +		.mode = PPS_CAPTUREBOTH |
> +			PPS_OFFSETASSERT | PPS_OFFSETCLEAR |
> +			PPS_CANWAIT | PPS_TSFMT_TSPEC,
> +	};
>  	struct tty_driver *drv = tty->driver;
>  	int index = tty->index + drv->name_base;
>  	struct pps_device *pps;
>  	int ret;
>  
> -	info.owner = THIS_MODULE;
> -	info.dev = NULL;
>  	snprintf(info.name, PPS_MAX_NAME_LEN, "%s%d", drv->driver_name, index);
>  	snprintf(info.path, PPS_MAX_NAME_LEN, "/dev/%s%d", drv->name, index);
> -	info.mode = PPS_CAPTUREBOTH | \
> -			PPS_OFFSETASSERT | PPS_OFFSETCLEAR | \
> -			PPS_CANWAIT | PPS_TSFMT_TSPEC;
>  
>  	pps = pps_register_source(&info, PPS_CAPTUREBOTH | \
>  				PPS_OFFSETASSERT | PPS_OFFSETCLEAR);
> 
> base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244

Acked-by: Rodolfo Giometti <giometti@enneenne.com>

-- 
GNU/Linux Solutions                  e-mail: giometti@enneenne.com
Linux Device Driver                          giometti@linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-01  8:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 22:54 [PATCH] pps: clients: ldisc: Fix uninitialized info.echo in pps_tty_open() Ian Rogers
2026-12-01  8:30 ` Rodolfo Giometti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®