Compare commits

...

6 Commits

Author SHA1 Message Date
openharmony_ci 2bef65046a
!1081 fix: 【挑单】codecheck问题清零
Merge pull request !1081 from zhushengle/cherry-pick-1669685670
2022-11-29 03:20:11 +00:00
zhushengle 205df75f15 fixed 8d980de from https://gitee.com/zhushengle/kernel_liteos_a/pulls/1078
fix: codecheck问题清零

1.shell初始化异常流程double free
2.los_disk_init中冗余初始化
3.OsKProcessPmUsage 中OsUProcessPmUsage异常退出时,存在使用未初始化的变量
4.HiLogHeadInit异常推出后,存在使用未初始化的变量
5.api_shell.c 中存在冗余初始化

fix #I63H5G

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: If17d8ed1e6f2276e20fbce24b32de169bfd22e54
2022-11-29 01:34:30 +00:00
openharmony_ci 85f1c9e0ca
!1067 【挑单】time相关系统调用内核栈信息泄露排查
Merge pull request !1067 from zhushengle/cherry-pick-1668158211
2022-11-14 03:24:57 +00:00
zhushengle c04ff6b10f fixed 0b05a46 from https://gitee.com/zhushengle/kernel_liteos_a/pulls/1061
task: time相关系统调用内核栈信息泄露排查

解决方案:
    在涉及从内核拷贝数据到用户态的场景时,先将内核的数据进行清零操作,再填充内核数据
Close #I60M1P

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ia61d4e39b9e190accea477ff5b361e41d0eed2af
2022-11-11 09:16:52 +00:00
openharmony_ci 1b61489512
!1048 Fix : 内核告警清理挑单到monthly 分支
Merge pull request !1048 from yinjiaming/cherry-pick-1666774395
2022-10-27 14:24:41 +00:00
yinjiaming 29c459e045 fixed 8d55bb1 from https://gitee.com/hgbveiu743/kernel_liteos_a/pulls/1046
fix: 内核告警清理
【背景】
内核告警清理

【修改方案】
删去了多余的空格,更改了魔数字

【影响】
对现有的产品编译不会有影响。

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Iba21be6cb23027dfb369576847d7d21e85f936b4
2022-10-26 08:53:15 +00:00
8 changed files with 36 additions and 48 deletions

View File

@ -49,7 +49,7 @@ ShellCB *OsGetShellCb()
return g_shellCB;
}
void ShellDeinit(ShellCB *shellCB)
static void ShellDeinit(ShellCB *shellCB)
{
(void)pthread_mutex_destroy(&shellCB->historyMutex);
(void)pthread_mutex_destroy(&shellCB->keyMutex);
@ -65,27 +65,23 @@ static int OsShellCreateTask(ShellCB *shellCB)
ret = sched_getparam(getpid(), &param);
if (ret != SH_OK) {
goto OUT;
return ret;
}
param.sched_priority = SHELL_PROCESS_PRIORITY_INIT;
ret = sched_setparam(getpid(), &param);
if (ret != SH_OK) {
goto OUT;
return ret;
}
ret = ShellTaskInit(shellCB);
if (ret != SH_OK) {
goto OUT;
return ret;
}
shellCB->shellEntryHandle = pthread_self();
return 0;
OUT:
ShellDeinit(shellCB);
return ret;
}
static int DoShellExec(char **argv)
@ -148,7 +144,7 @@ int main(int argc, char **argv)
shellCB = (ShellCB *)malloc(sizeof(ShellCB));
if (shellCB == NULL) {
goto ERR_OUT1;
return SH_NOK;
}
ret = memset_s(shellCB, sizeof(ShellCB), 0, sizeof(ShellCB));
if (ret != SH_OK) {
@ -176,7 +172,9 @@ int main(int argc, char **argv)
g_shellCB = shellCB;
ret = OsShellCreateTask(shellCB);
if (ret != SH_OK) {
goto ERR_OUT3;
ShellDeinit(shellCB);
g_shellCB = NULL;
return ret;
}
ShellEntry(shellCB);

View File

@ -1465,7 +1465,7 @@ INT32 los_disk_init(const CHAR *diskName, const struct block_operations *bops,
ret = VnodeLookup(diskName, &blkDriver, 0);
if (ret < 0) {
VnodeDrop();
ret = ENOENT;
PRINT_ERR("disk_init : %s, failed to find the vnode, ERRNO=%d\n", diskName, ret);
goto DISK_FIND_ERROR;
}
struct block_operations *bops2 = (struct block_operations *)((struct drv_data *)blkDriver->data)->ops;

View File

@ -146,7 +146,6 @@ UINT32 OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm)
LosVmSpace *space = NULL;
LOS_DL_LIST *spaceList = NULL;
UINT32 UProcessUsed = 0;
UINT32 pmTmp;
if (actualPm == NULL) {
return 0;
@ -167,8 +166,7 @@ UINT32 OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm)
if (space == LOS_GetKVmSpace()) {
continue;
}
(VOID)OsUProcessPmUsage(space, NULL, &pmTmp);
UProcessUsed += pmTmp;
UProcessUsed += OsUProcessPmUsage(space, NULL, NULL);
}
(VOID)LOS_MuxRelease(vmSpaceListMux);

View File

@ -233,14 +233,8 @@ static int HiLogWriteRingBuffer(unsigned char *buffer, size_t bufLen)
static void HiLogHeadInit(struct HiLogEntry *header, size_t len)
{
struct timespec now;
int ret;
ret = clock_gettime(CLOCK_REALTIME, &now);
if (ret != 0) {
PRINTK("In %s line %d,clock_gettime fail\n", __FUNCTION__, __LINE__);
return;
}
struct timespec now = {0};
(void)clock_gettime(CLOCK_REALTIME, &now);
header->len = len;
header->pid = LOS_GetCurrProcessID();

View File

@ -356,7 +356,7 @@ int print_netif(struct netif *netif, char *print_buf, unsigned int buf_len)
buf_len -= (unsigned int)ret;
}
ret = snprintf_s(tmp, buf_len, (buf_len - 1), " %s\n",
ret = snprintf_s(tmp, buf_len, (buf_len - 1), " %s\n",
(netif->flags & NETIF_FLAG_LINK_UP) ? "Link UP" : "Link Down");
if ((ret <= 0) || ((unsigned int)ret >= buf_len))
goto out;
@ -2175,8 +2175,6 @@ u32_t osShellPing6(int argc, const char **argv)
/* Setting the start time of the entire ping task for statistics */
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &first);
nsent = 0;
for (nsent = 0; nsent < ping6_params.pingcount; nsent++) {
/* capture the start tick to calculate rtt */
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &start);
@ -3170,7 +3168,6 @@ void netstat_internal(void *ctx)
}
/* For listen PCBs */
recvQlen = 0;
sendQlen = 0;
for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
@ -3670,7 +3667,7 @@ u32_t netdebug_sock(int argc, const char **argv)
int idx;
u32_t ret = LOS_NOK;
if (argc == 2) {
if (argc == 2) { /* 2: Number of command parameters */
if (!strcmp("-i", argv[1])) {
/* netdebug sock -i */
for (idx = 0; idx < (int)LWIP_CONFIG_NUM_SOCKETS; idx++) {
@ -3678,10 +3675,9 @@ u32_t netdebug_sock(int argc, const char **argv)
}
ret = LOS_OK;
}
} else if (argc == 3) {
} else if (argc == 3) { /* 3: Number of command parameters */
if (!strcmp("-d", argv[1])) {
/* netdebug sock -d <idx> */
idx = atoi(argv[2]);
idx = atoi(argv[2]); /* 2: netdebug sock -d <idx> */
if (idx >= 0) {
debug_socket_info(idx, 1, 1);
ret = LOS_OK;

View File

@ -109,7 +109,7 @@ int SysSetiTimer(int which, const struct itimerval *value, struct itimerval *ova
{
int ret;
struct itimerval svalue;
struct itimerval sovalue;
struct itimerval sovalue = { 0 };
if (value == NULL) {
errno = EINVAL;
@ -137,7 +137,7 @@ int SysSetiTimer(int which, const struct itimerval *value, struct itimerval *ova
int SysGetiTimer(int which, struct itimerval *value)
{
int ret;
struct itimerval svalue;
struct itimerval svalue = { 0 };
if (value == NULL) {
errno = EINVAL;
@ -189,7 +189,7 @@ int SysTimerCreate(clockid_t clockID, struct ksigevent *evp, timer_t *timerID)
int SysTimerGettime(timer_t timerID, struct itimerspec *value)
{
int ret;
struct itimerspec svalue;
struct itimerspec svalue = { 0 };
if (value == NULL) {
errno = EINVAL;
@ -213,7 +213,7 @@ int SysTimerSettime(timer_t timerID, int flags, const struct itimerspec *value,
{
int ret;
struct itimerspec svalue;
struct itimerspec soldValue;
struct itimerspec soldValue = { 0 };
if (value == NULL) {
errno = EINVAL;
@ -285,7 +285,7 @@ int SysClockSettime(clockid_t clockID, const struct timespec *tp)
int SysClockGettime(clockid_t clockID, struct timespec *tp)
{
int ret;
struct timespec stp;
struct timespec stp = { 0 };
if (tp == NULL) {
errno = EINVAL;
@ -308,7 +308,7 @@ int SysClockGettime(clockid_t clockID, struct timespec *tp)
int SysClockGetres(clockid_t clockID, struct timespec *tp)
{
int ret;
struct timespec stp;
struct timespec stp = { 0 };
if (tp == NULL) {
errno = EINVAL;
@ -356,7 +356,7 @@ int SysNanoSleep(const struct timespec *rqtp, struct timespec *rmtp)
{
int ret;
struct timespec srqtp;
struct timespec srmtp;
struct timespec srmtp = { 0 };
if (!rqtp || LOS_ArchCopyFromUser(&srqtp, rqtp, sizeof(struct timespec))) {
errno = EFAULT;
@ -384,7 +384,7 @@ int SysNanoSleep(const struct timespec *rqtp, struct timespec *rmtp)
clock_t SysTimes(struct tms *buf)
{
clock_t ret;
struct tms sbuf;
struct tms sbuf = { 0 };
if (buf == NULL) {
errno = EFAULT;
@ -436,7 +436,7 @@ int SysClockGettime64(clockid_t clockID, struct timespec64 *tp)
{
int ret;
struct timespec t;
struct timespec64 stp;
struct timespec64 stp = { 0 };
if (tp == NULL) {
errno = EINVAL;
@ -463,7 +463,7 @@ int SysClockGetres64(clockid_t clockID, struct timespec64 *tp)
{
int ret;
struct timespec t;
struct timespec64 stp;
struct timespec64 stp = { 0 };
if (tp == NULL) {
errno = EINVAL;
@ -525,7 +525,7 @@ int SysTimerGettime64(timer_t timerID, struct itimerspec64 *value)
{
int ret;
struct itimerspec val;
struct itimerspec64 svalue;
struct itimerspec64 svalue = { 0 };
if (value == NULL) {
errno = EINVAL;
@ -584,6 +584,7 @@ int SysTimerSettime64(timer_t timerID, int flags, const struct itimerspec64 *val
}
if (oldValue != NULL) {
(void)memset_s(&soldValue, sizeof(struct itimerspec64), 0, sizeof(struct itimerspec64));
soldValue.it_interval.tv_sec = oldVal.it_interval.tv_sec;
soldValue.it_interval.tv_nsec = oldVal.it_interval.tv_nsec;
soldValue.it_value.tv_sec = oldVal.it_value.tv_sec;

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -31,6 +31,7 @@
#include "it_test_shm.h"
#define SHMID_MAX 192
#define SHM_FLAG 0777
static int Testcase(VOID)
{
@ -44,24 +45,24 @@ static int Testcase(VOID)
ICUNIT_ASSERT_EQUAL(ret, SHMID_MAX, ret);
leftShmIds = SHMID_MAX - shmInfo.used_ids;
shmid[0] = shmget((key_t)0x1234, PAGE_SIZE, 0777 | IPC_CREAT);
shmid[0] = shmget((key_t)0x1234, PAGE_SIZE, SHM_FLAG | IPC_CREAT); // 0x1234: a key used to create shared memory
ICUNIT_ASSERT_NOT_EQUAL(shmid[0], -1, shmid[0]);
ret = shmctl(shmid[0], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
shmid[0] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
shmid[0] = shmget(IPC_PRIVATE, PAGE_SIZE, SHM_FLAG | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid[0], -1, shmid[0]);
ret = shmctl(shmid[0], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
for (i = 0; i < leftShmIds; i++) {
shmid[i] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
shmid[i] = shmget(IPC_PRIVATE, PAGE_SIZE, SHM_FLAG | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid[i], -1, shmid[i]);
}
shmid[leftShmIds] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
shmid[leftShmIds] = shmget(IPC_PRIVATE, PAGE_SIZE, SHM_FLAG | IPC_CREAT);
ICUNIT_ASSERT_EQUAL(shmid[leftShmIds], -1, shmid[leftShmIds]);
for (i = 0; i < leftShmIds; i++) {

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -41,7 +41,7 @@
#define CLOCK_RES_NSEC 1000
#define CLOCK_COARSE_RES_SEC 0
#define CLOCK_COARSE_RES_NSEC 1000000
#define CLOCK_GET_CPU_CLOCKID(pid) ((-pid - 1) * 8U + 2)
#define CLOCK_GET_CPU_CLOCKID(pid) ((-(pid) - 1) * 8U + 2)
void ClockTestSmoke(void);
void ClockTest001(void);