Sign in
Sign up
Explore
Enterprise
Education
Search
Help
Terms of use
About Us
Explore
Enterprise
Education
Gitee Premium
Gitee AI
AI teammates
Sign in
Sign up
Fetch the repository succeeded.
description of repo status
Open Source
>
Other
>
Operation System
&&
Donate
Please sign in before you donate.
Cancel
Sign in
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
Watch
Unwatch
Watching
Releases Only
Ignoring
458
Star
1.7K
Fork
1.9K
GVP
openEuler
/
kernel
Closed
Code
Issues
1271
Pull Requests
991
Wiki
Insights
Pipelines
Service
Quality Analysis
Jenkins for Gitee
Tencent CloudBase
Tencent Cloud Serverless
悬镜安全
Aliyun SAE
Codeblitz
SBOM
DevLens
Don’t show this again
Update failed. Please try again later!
Remove this flag
Content Risk Flag
This task is identified by
as the content contains sensitive information such as code security bugs, privacy leaks, etc., so it is only accessible to contributors of this repository.
【openEuler-1.0-LTS】【cifs】2024年1月 4.19 LTS补丁回合
Done
#I8ZPJF
Task
Wang Zhaolong
Opened this issue
2024-01-29 17:35
### 补丁信息 ~~~ commit 832c20fc4cc82c497566db35996ea488661fc764 Author: Paulo Alcantara <pc@manguebit.com> Date: Mon Dec 11 10:26:42 2023 -0300 smb: client: fix NULL deref in asn1_ber_decoder() [ Upstream commit 90d025c2e953c11974e76637977c473200593a46 ] If server replied SMB2_NEGOTIATE with a zero SecurityBufferOffset, smb2_get_data_area() sets @len to non-zero but return NULL, so decode_negTokeninit() ends up being called with a NULL @security_blob: ~~~ #### 流程分析 ~~~ smb2_negotiate SMB2_negotiate smb2_get_data_area_len decode_negTokenInit ~~~ smb2_get_data_area_len()中对len和offs检查不充分,导致len != 0 并且 return NULL ~~~c char * smb2_get_data_area_len(int *off, int *len, struct smb2_sync_hdr *shdr) { *off = 0; *len = 0; /* error responses do not have data area */ if (shdr->Status && shdr->Status != STATUS_MORE_PROCESSING_REQUIRED && (((struct smb2_err_rsp *)shdr)->StructureSize) == SMB2_ERROR_STRUCTURE_SIZE2) return NULL; /* * Following commands have data areas so we have to get the location * of the data buffer offset and data buffer length for the particular * command. */ switch (shdr->Command) { case SMB2_NEGOTIATE: *off = le16_to_cpu( ((struct smb2_negotiate_rsp *)shdr)->SecurityBufferOffset); // offs 为 0 *len = le16_to_cpu( ((struct smb2_negotiate_rsp *)shdr)->SecurityBufferLength); // len 不为 0 break; ...... /* // ========== offs == 0 会导致下面的检查全部通过,并且len != 0 ============== * Invalid length or offset probably means data area is invalid, but * we have little choice but to ignore the data area in this case. */ if (*off > 4096) { cifs_dbg(VFS, "offset %d too large, data area ignored\n", *off); *len = 0; *off = 0; } else if (*off < 0) { cifs_dbg(VFS, "negative offset %d to data invalid ignore data area\n", *off); *off = 0; *len = 0; } else if (*len < 0) { cifs_dbg(VFS, "negative data length %d invalid, data area ignored\n", *len); *len = 0; } else if (*len > 128 * 1024) { cifs_dbg(VFS, "data area larger than 128K: %d\n", *len); *len = 0; } /* return pointer to beginning of data area, ie offset from SMB start */ if ((*off != 0) && (*len != 0)) // offs == 0 return (char *)shdr + *off; else return NULL; // 返回NULL,并且len不为0 } ~~~ 随后进入decode_negTokenInit()所在分支 ~~~c int SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) ....... security_blob = smb2_get_data_area_len(&blob_offset, &blob_length, (struct smb2_sync_hdr *)rsp); ...... if (blob_length) { rc = decode_negTokenInit(security_blob, blob_length, server); // security_blob 为 NULL if (rc == 1) rc = 0; else if (rc == 0) rc = -EIO; } ~~~ 对空指针进行操作 ~~~ decode_negTokenInit asn1_open ctx->pointer = NULL -> 初始化为NULL asn1_header_decode *eoc = ctx->pointer + len; // 非法地址 ~~~
### 补丁信息 ~~~ commit 832c20fc4cc82c497566db35996ea488661fc764 Author: Paulo Alcantara <pc@manguebit.com> Date: Mon Dec 11 10:26:42 2023 -0300 smb: client: fix NULL deref in asn1_ber_decoder() [ Upstream commit 90d025c2e953c11974e76637977c473200593a46 ] If server replied SMB2_NEGOTIATE with a zero SecurityBufferOffset, smb2_get_data_area() sets @len to non-zero but return NULL, so decode_negTokeninit() ends up being called with a NULL @security_blob: ~~~ #### 流程分析 ~~~ smb2_negotiate SMB2_negotiate smb2_get_data_area_len decode_negTokenInit ~~~ smb2_get_data_area_len()中对len和offs检查不充分,导致len != 0 并且 return NULL ~~~c char * smb2_get_data_area_len(int *off, int *len, struct smb2_sync_hdr *shdr) { *off = 0; *len = 0; /* error responses do not have data area */ if (shdr->Status && shdr->Status != STATUS_MORE_PROCESSING_REQUIRED && (((struct smb2_err_rsp *)shdr)->StructureSize) == SMB2_ERROR_STRUCTURE_SIZE2) return NULL; /* * Following commands have data areas so we have to get the location * of the data buffer offset and data buffer length for the particular * command. */ switch (shdr->Command) { case SMB2_NEGOTIATE: *off = le16_to_cpu( ((struct smb2_negotiate_rsp *)shdr)->SecurityBufferOffset); // offs 为 0 *len = le16_to_cpu( ((struct smb2_negotiate_rsp *)shdr)->SecurityBufferLength); // len 不为 0 break; ...... /* // ========== offs == 0 会导致下面的检查全部通过,并且len != 0 ============== * Invalid length or offset probably means data area is invalid, but * we have little choice but to ignore the data area in this case. */ if (*off > 4096) { cifs_dbg(VFS, "offset %d too large, data area ignored\n", *off); *len = 0; *off = 0; } else if (*off < 0) { cifs_dbg(VFS, "negative offset %d to data invalid ignore data area\n", *off); *off = 0; *len = 0; } else if (*len < 0) { cifs_dbg(VFS, "negative data length %d invalid, data area ignored\n", *len); *len = 0; } else if (*len > 128 * 1024) { cifs_dbg(VFS, "data area larger than 128K: %d\n", *len); *len = 0; } /* return pointer to beginning of data area, ie offset from SMB start */ if ((*off != 0) && (*len != 0)) // offs == 0 return (char *)shdr + *off; else return NULL; // 返回NULL,并且len不为0 } ~~~ 随后进入decode_negTokenInit()所在分支 ~~~c int SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) ....... security_blob = smb2_get_data_area_len(&blob_offset, &blob_length, (struct smb2_sync_hdr *)rsp); ...... if (blob_length) { rc = decode_negTokenInit(security_blob, blob_length, server); // security_blob 为 NULL if (rc == 1) rc = 0; else if (rc == 0) rc = -EIO; } ~~~ 对空指针进行操作 ~~~ decode_negTokenInit asn1_open ctx->pointer = NULL -> 初始化为NULL asn1_header_decode *eoc = ctx->pointer + len; // 非法地址 ~~~
Comments (
1
)
Sign in
to comment
Status
Done
Backlog
Doing
Done
Declined
Assignees
Not set
Labels
sig/Kernel
Not set
Projects
Unprojected
Unprojected
Pull Requests
None yet
None yet
Successfully merging a pull request will close this issue.
Branches
No related branch
Branches (
-
)
Tags (
-
)
Planed to start   -   Planed to end
-
Top level
Not Top
Top Level: High
Top Level: Medium
Top Level: Low
Priority
Not specified
Serious
Main
Secondary
Unimportant
Duration
(hours)
参与者(2)
C
1
https://gitee.com/openeuler/kernel.git
git@gitee.com:openeuler/kernel.git
openeuler
kernel
kernel
Going to Help Center
Search
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register