Compare commits

...

3 commits

Author SHA1 Message Date
hujun5
3822355088
Merge 58e38a91c3 into aa0aecbd80 2025-01-12 01:36:06 +08:00
wangmingrong1
aa0aecbd80 mempool: addbacktrace should be before kasan_unpoison
If thread 1 is executing kasan_unpoison but a scheduling occurs and the block is trampled upon, the displayed backtracking may still be from the previously allocated backtracking

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-12 01:29:14 +08:00
hujun5
58e38a91c3 clock_adjtime: use small lock to protect g_adjtime_ppb g_adjtime_wdog
reason:
We would like to replace the critical section with a small lock.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-12-11 18:43:34 +08:00
2 changed files with 13 additions and 6 deletions

View file

@ -397,16 +397,17 @@ retry:
pool->nalloc++;
spin_unlock_irqrestore(&pool->lock, flags);
blk = kasan_unpoison(blk, pool->blocksize);
#ifdef CONFIG_MM_FILL_ALLOCATIONS
memset(blk, MM_ALLOC_MAGIC, pool->blocksize);
#endif
#if CONFIG_MM_BACKTRACE >= 0
mempool_add_backtrace(pool, (FAR struct mempool_backtrace_s *)
((FAR char *)blk + pool->blocksize));
#endif
blk = kasan_unpoison(blk, pool->blocksize);
#ifdef CONFIG_MM_FILL_ALLOCATIONS
memset(blk, MM_ALLOC_MAGIC, pool->blocksize);
#endif
return blk;
}

View file

@ -49,6 +49,7 @@
static struct wdog_s g_adjtime_wdog;
static long g_adjtime_ppb;
static spinlock_t g_adjtime_lock = SP_UNLOCKED;
/****************************************************************************
* Private Functions
@ -58,8 +59,12 @@ static long g_adjtime_ppb;
static void adjtime_wdog_callback(wdparm_t arg)
{
irqstate_t flags;
UNUSED(arg);
flags = spin_lock_irqsave(&g_adjtime_lock);
#ifdef CONFIG_ARCH_HAVE_ADJTIME
up_adjtime(0);
#endif
@ -69,6 +74,7 @@ static void adjtime_wdog_callback(wdparm_t arg)
#endif
g_adjtime_ppb = 0;
spin_unlock_irqrestore(&g_adjtime_lock, flags);
}
/* Query remaining adjustment in microseconds */
@ -108,7 +114,7 @@ static int adjtime_start(long long adjust_usec)
ppb = -ppb_limit;
}
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_adjtime_lock);
/* Set new adjustment */
@ -134,7 +140,7 @@ static int adjtime_start(long long adjust_usec)
wd_cancel(&g_adjtime_wdog);
}
leave_critical_section(flags);
spin_unlock_irqrestore(&g_adjtime_lock, flags);
return ret;
}