* [PATCH] audit: use time_after to compare time
@ 2022-08-29 16:26 wuchi
2022-08-29 23:48 ` Paul Moore
0 siblings, 1 reply; 2+ messages in thread
From: wuchi @ 2022-08-29 16:26 UTC (permalink / raw)
To: paul, eparis, rgb; +Cc: linux-audit, linux-kernel
Using time_{*} macro to compare time is better
Signed-off-by: wuchi <wuchi.zero@gmail.com>
---
kernel/audit.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/kernel/audit.c b/kernel/audit.c
index a75978ae38ad..9bc0b0301198 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -321,7 +321,6 @@ static inline int audit_rate_check(void)
static DEFINE_SPINLOCK(lock);
unsigned long flags;
unsigned long now;
- unsigned long elapsed;
int retval = 0;
if (!audit_rate_limit) return 1;
@@ -330,9 +329,8 @@ static inline int audit_rate_check(void)
if (++messages < audit_rate_limit) {
retval = 1;
} else {
- now = jiffies;
- elapsed = now - last_check;
- if (elapsed > HZ) {
+ now = jiffies;
+ if (time_after(now, last_check + HZ)) {
last_check = now;
messages = 0;
retval = 1;
@@ -366,7 +364,7 @@ void audit_log_lost(const char *message)
if (!print) {
spin_lock_irqsave(&lock, flags);
now = jiffies;
- if (now - last_msg > HZ) {
+ if (time_after(now, last_msg + HZ)) {
print = 1;
last_msg = now;
}
--
2.20.1
--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] audit: use time_after to compare time
2022-08-29 16:26 [PATCH] audit: use time_after to compare time wuchi
@ 2022-08-29 23:48 ` Paul Moore
0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2022-08-29 23:48 UTC (permalink / raw)
To: wuchi; +Cc: rgb, linux-audit, linux-kernel, eparis
On Mon, Aug 29, 2022 at 12:26 PM wuchi <wuchi.zero@gmail.com> wrote:
>
> Using time_{*} macro to compare time is better
>
> Signed-off-by: wuchi <wuchi.zero@gmail.com>
> ---
> kernel/audit.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
Merged into audit/next, thanks!
--
paul-moore.com
--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-29 23:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-29 16:26 [PATCH] audit: use time_after to compare time wuchi
2022-08-29 23:48 ` Paul Moore
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).