All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] rasdaemon: misc fixes
@ 2022-07-20 14:39 arozansk
  2022-07-20 14:39 ` [PATCH 1/3] rasdaemon: ras-report: fix possible but unlikely file descriptor leak arozansk
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: arozansk @ 2022-07-20 14:39 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-edac

These patches are for 3 issues found with covscan. None of them are likely to
happen during regular use, but worth fixing anyway.

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>

-- 
Aristeu


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

* [PATCH 1/3] rasdaemon: ras-report: fix possible but unlikely file descriptor leak
  2022-07-20 14:39 [PATCH 0/3] rasdaemon: misc fixes arozansk
@ 2022-07-20 14:39 ` arozansk
  2022-07-20 14:39 ` [PATCH 2/3] rasdaemon: mce-amd-smca: properly limit bank types arozansk
  2022-07-20 14:40 ` [PATCH 3/3] rasdaemon: ras-memory-failure-handler: handle localtime() failure correctly arozansk
  2 siblings, 0 replies; 7+ messages in thread
From: arozansk @ 2022-07-20 14:39 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-edac, Aristeu Rozanski

Found with covscan.

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>

diff --git a/ras-report.c b/ras-report.c
index ea3a9b6..0088745 100644
--- a/ras-report.c
+++ b/ras-report.c
@@ -768,7 +768,7 @@ int ras_report_mf_event(struct ras_events *ras, struct ras_mf_event *ev)
 	done = 1;
 
 mf_fail:
-	if (sockfd > 0)
+	if (sockfd >= 0)
 		close(sockfd);
 
 	if (done)


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

* [PATCH 2/3] rasdaemon: mce-amd-smca: properly limit bank types
  2022-07-20 14:39 [PATCH 0/3] rasdaemon: misc fixes arozansk
  2022-07-20 14:39 ` [PATCH 1/3] rasdaemon: ras-report: fix possible but unlikely file descriptor leak arozansk
@ 2022-07-20 14:39 ` arozansk
  2022-07-20 14:40 ` [PATCH 3/3] rasdaemon: ras-memory-failure-handler: handle localtime() failure correctly arozansk
  2 siblings, 0 replies; 7+ messages in thread
From: arozansk @ 2022-07-20 14:39 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-edac, Aristeu Rozanski

Found with covscan.

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>

diff --git a/mce-amd-smca.c b/mce-amd-smca.c
index f3379fc..27ca8aa 100644
--- a/mce-amd-smca.c
+++ b/mce-amd-smca.c
@@ -584,7 +584,7 @@ static void decode_smca_error(struct mce_event *e)
 		return;
 	}
 
-	if (bank_type >= MAX_NR_BANKS) {
+	if (bank_type >= N_SMCA_BANK_TYPES) {
 		strcpy(e->mcastatus_msg, "Don't know how to decode this bank");
 		return;
 	}


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

* [PATCH 3/3] rasdaemon: ras-memory-failure-handler: handle localtime() failure correctly
  2022-07-20 14:39 [PATCH 0/3] rasdaemon: misc fixes arozansk
  2022-07-20 14:39 ` [PATCH 1/3] rasdaemon: ras-report: fix possible but unlikely file descriptor leak arozansk
  2022-07-20 14:39 ` [PATCH 2/3] rasdaemon: mce-amd-smca: properly limit bank types arozansk
@ 2022-07-20 14:40 ` arozansk
  2022-07-20 15:33   ` Elliott, Robert (Servers)
  2 siblings, 1 reply; 7+ messages in thread
From: arozansk @ 2022-07-20 14:40 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-edac, Aristeu Rozanski

We could just have an empty string but keeping the format could prevent
issues if someone is actually parsing this.
Found with covscan.

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>

diff --git a/ras-memory-failure-handler.c b/ras-memory-failure-handler.c
index 9941e68..9574141 100644
--- a/ras-memory-failure-handler.c
+++ b/ras-memory-failure-handler.c
@@ -148,6 +148,8 @@ int ras_memory_failure_event_handler(struct trace_seq *s,
 	if (tm)
 		strftime(ev.timestamp, sizeof(ev.timestamp),
 			 "%Y-%m-%d %H:%M:%S %z", tm);
+	else
+		strncpy(ev.timestamp, "0000-00-00 00:00:00 GMT", sizeof(ev.timestamp));
 	trace_seq_printf(s, "%s ", ev.timestamp);
 
 	if (pevent_get_field_val(s,  event, "pfn", record, &val, 1) < 0)


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

* RE: [PATCH 3/3] rasdaemon: ras-memory-failure-handler: handle localtime() failure correctly
  2022-07-20 14:40 ` [PATCH 3/3] rasdaemon: ras-memory-failure-handler: handle localtime() failure correctly arozansk
@ 2022-07-20 15:33   ` Elliott, Robert (Servers)
  2022-07-20 15:39     ` 'arozansk@redhat.com'
  2022-07-20 15:40     ` [PATCH 3/3 v2] " arozansk
  0 siblings, 2 replies; 7+ messages in thread
From: Elliott, Robert (Servers) @ 2022-07-20 15:33 UTC (permalink / raw)
  To: 'arozansk@redhat.com', Mauro Carvalho Chehab; +Cc: linux-edac



> -----Original Message-----
> From: arozansk@redhat.com <arozansk@redhat.com>
> Sent: Wednesday, July 20, 2022 9:40 AM
...
> Subject: [PATCH 3/3] rasdaemon: ras-memory-failure-handler: handle
> localtime() failure correctly
> 
> We could just have an empty string but keeping the format could prevent
> issues if someone is actually parsing this.
> Found with covscan.
> 
...
> diff --git a/ras-memory-failure-handler.c b/ras-memory-failure-handler.c
...
> @@ -148,6 +148,8 @@ int ras_memory_failure_event_handler(struct trace_seq
> *s,
>  	if (tm)
>  		strftime(ev.timestamp, sizeof(ev.timestamp),
>  			 "%Y-%m-%d %H:%M:%S %z", tm);
> +	else
> +		strncpy(ev.timestamp, "0000-00-00 00:00:00 GMT", sizeof(ev.timestamp));


Per man strftime:
       %z     The +hhmm or -hhmm numeric timezone (that is, the hour and minute offset from UTC). (SU)
       %Z     The timezone name or abbreviation.

GMT does not match the lowercase %z format of +hhmm or -hhmm

Returning the UNIX epoch might be safer, too:
    1970-01-01 00:00:00 +0000


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

* Re: [PATCH 3/3] rasdaemon: ras-memory-failure-handler: handle localtime() failure correctly
  2022-07-20 15:33   ` Elliott, Robert (Servers)
@ 2022-07-20 15:39     ` 'arozansk@redhat.com'
  2022-07-20 15:40     ` [PATCH 3/3 v2] " arozansk
  1 sibling, 0 replies; 7+ messages in thread
From: 'arozansk@redhat.com' @ 2022-07-20 15:39 UTC (permalink / raw)
  To: Elliott, Robert (Servers); +Cc: Mauro Carvalho Chehab, linux-edac

On Wed, Jul 20, 2022 at 03:33:49PM +0000, Elliott, Robert (Servers) wrote:
> > -----Original Message-----
> > From: arozansk@redhat.com <arozansk@redhat.com>
> > Sent: Wednesday, July 20, 2022 9:40 AM
> ...
> > Subject: [PATCH 3/3] rasdaemon: ras-memory-failure-handler: handle
> > localtime() failure correctly
> > 
> > We could just have an empty string but keeping the format could prevent
> > issues if someone is actually parsing this.
> > Found with covscan.
> > 
> ...
> > diff --git a/ras-memory-failure-handler.c b/ras-memory-failure-handler.c
> ...
> > @@ -148,6 +148,8 @@ int ras_memory_failure_event_handler(struct trace_seq
> > *s,
> >  	if (tm)
> >  		strftime(ev.timestamp, sizeof(ev.timestamp),
> >  			 "%Y-%m-%d %H:%M:%S %z", tm);
> > +	else
> > +		strncpy(ev.timestamp, "0000-00-00 00:00:00 GMT", sizeof(ev.timestamp));
> 
> 
> Per man strftime:
>        %z     The +hhmm or -hhmm numeric timezone (that is, the hour and minute offset from UTC). (SU)
>        %Z     The timezone name or abbreviation.
> 
> GMT does not match the lowercase %z format of +hhmm or -hhmm

Good catch, thanks

> Returning the UNIX epoch might be safer, too:
>     1970-01-01 00:00:00 +0000

Agreed, v2 will follow

-- 
Aristeu


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

* [PATCH 3/3 v2] rasdaemon: ras-memory-failure-handler: handle localtime() failure correctly
  2022-07-20 15:33   ` Elliott, Robert (Servers)
  2022-07-20 15:39     ` 'arozansk@redhat.com'
@ 2022-07-20 15:40     ` arozansk
  1 sibling, 0 replies; 7+ messages in thread
From: arozansk @ 2022-07-20 15:40 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-edac, Elliott, Robert (Servers)

We could just have an empty string but keeping the format could prevent
issues if someone is actually parsing this.
Found with covscan.

v2: fixed the timestamp as pointed by Robert Elliott

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>

diff --git a/ras-memory-failure-handler.c b/ras-memory-failure-handler.c
index 9941e68..9574141 100644
--- a/ras-memory-failure-handler.c
+++ b/ras-memory-failure-handler.c
@@ -148,6 +148,8 @@ int ras_memory_failure_event_handler(struct trace_seq *s,
 	if (tm)
 		strftime(ev.timestamp, sizeof(ev.timestamp),
 			 "%Y-%m-%d %H:%M:%S %z", tm);
+	else
+		strncpy(ev.timestamp, "1970-01-01 00:00:00 +0000", sizeof(ev.timestamp));
 	trace_seq_printf(s, "%s ", ev.timestamp);
 
 	if (pevent_get_field_val(s,  event, "pfn", record, &val, 1) < 0)


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

end of thread, other threads:[~2022-07-20 15:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20 14:39 [PATCH 0/3] rasdaemon: misc fixes arozansk
2022-07-20 14:39 ` [PATCH 1/3] rasdaemon: ras-report: fix possible but unlikely file descriptor leak arozansk
2022-07-20 14:39 ` [PATCH 2/3] rasdaemon: mce-amd-smca: properly limit bank types arozansk
2022-07-20 14:40 ` [PATCH 3/3] rasdaemon: ras-memory-failure-handler: handle localtime() failure correctly arozansk
2022-07-20 15:33   ` Elliott, Robert (Servers)
2022-07-20 15:39     ` 'arozansk@redhat.com'
2022-07-20 15:40     ` [PATCH 3/3 v2] " arozansk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.