Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[19' 김관영] 최종보고서 #93

Closed
gy741 opened this issue Oct 18, 2019 · 0 comments
Closed

[19' 김관영] 최종보고서 #93

gy741 opened this issue Oct 18, 2019 · 0 comments

Comments

@gy741
Copy link

gy741 commented Oct 18, 2019

학습내용

  • Git / Github 기본실습 (add, commit, push, PR, rebase, rebase -i, blame)
  • uftrace 개발 환경구성 및 실습 (clone, build, 실행, test)
  • uftrace python script 기능이해 및 사용법 학습
  • uftrace 동작 관련 스터디 (ELF, PLT/GOT, Calling convention 등)
  • uftrace Internals (주요로직 소스분석)

활동내역

1. 기능추가

2. 버그수정

Memory leak

Null Pointer Dereference

Code Refactoring / code style

compiler error

  • Issue A compiler warning namhyung/uftrace#936
    문제설명: uftrace를 특정 gcc 구버전(5,6) 에서 빌드를 시도하면 warning: dereferencing type-punned pointer will break strict-aliasing rules 메세지가 출력되는 문제가 있음.
    대응방안: union 공용체를 사용하여 문제 해결.
    Fix commit: No commit. Currently communicating.

3. 버그 레포팅

Memory leak

Overflow

4. 오타수정

5. 문서 번역

6. 위키 (사용자 케이스 추가)

yara : https://github.com/namhyung/uftrace/wiki/uftrace-for-yara
cURL: https://github.com/namhyung/uftrace/wiki/uftrace-for-cURL
Apache HTTP Server: https://github.com/namhyung/uftrace/wiki/uftrace-for-Apache-HTTP-Server
Squid: https://github.com/namhyung/uftrace/wiki/uftrace-for-Squid
TCPDUMP: https://github.com/namhyung/uftrace/wiki/uftrace-for-TCPDUMP
Libav: https://github.com/namhyung/uftrace/wiki/uftrace-for-Libav
Wireshark: https://github.com/namhyung/uftrace/wiki/uftrace-for-Wireshark

7. 커널패치

  • 1번 패치 ( 코드 리팩토링)
    설명: uftrace가 의존하고 있는 libtraceevent 소스코드에서 조건문의 논리적인 버그를 찾아냄. 이에 libtraceevent 메인테이너에게 문제를 보고하고 패치파일을 전달함.
    메일링: https://lkml.org/lkml/2019/10/18/1252
Seems that the value returned by eval_type_str() were always unsigned, and
never signed extended. Luckily, looking at all the trace events that
actually have a signed value seldom (if ever) are negative, so this bug
never showed its face, and if it has, nobody noticed it.

Converted the sign variable to boolean while at it.

Link: http://lkml.kernel.org/r/[email protected]
Fixes: f7d82350e597d ("tools/events: Add files to create libtraceevent.a")
Reported-by: GwanYeong Kim <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
---
 tools/lib/traceevent/event-parse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index d948475585ce..2b20063813ac 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -2217,7 +2217,7 @@ static char *arg_eval (struct tep_print_arg *arg);
 static unsigned long long
 eval_type_str(unsigned long long val, const char *type, int pointer)
 {
-	int sign = 0;
+	bool sign = true;
 	char *ref;
 	int len;
 
@@ -2277,7 +2277,7 @@ eval_type_str(unsigned long long val, const char *type, int pointer)
 		return (unsigned long long)(int)val & 0xffffffff;
 
 	if (strncmp(type, "unsigned ", 9) == 0) {
-		sign = 0;
+		sign = false;
 		type += 9;
 	}
 
-- 
2.20.1
  • 2번 패치 (코드 리팩토링)
    설명: uftrace에서 발견된 fread() 함수 사용 문제를 커널 소스코드에서 똑같이 발견함. 커널패치를 생성하여 담당자에게 커널패치 전달
    메일링: https://www.spinics.net/lists/linux-usb/msg186609.html
This isn't really accurate right. fread() doesn't always
return 0 in error. It could return < number of elements
and set errno.

Signed-off-by: GwanYeong Kim <gy741.kim@xxxxxxxxx>
---
 tools/usb/usbip/libsrc/usbip_device_driver.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/usb/usbip/libsrc/usbip_device_driver.c b/tools/usb/usbip/libsrc/usbip_device_driver.c
index 051d7d3f443b..927a151fa9aa 100644
--- a/tools/usb/usbip/libsrc/usbip_device_driver.c
+++ b/tools/usb/usbip/libsrc/usbip_device_driver.c
@@ -69,7 +69,7 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev)
 	FILE *fd = NULL;
 	struct udev_device *plat;
 	const char *speed;
-	int ret = 0;
+	size_t ret;
 
 	plat = udev_device_get_parent(sdev);
 	path = udev_device_get_syspath(plat);
@@ -79,8 +79,10 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev)
 	if (!fd)
 		return -1;
 	ret = fread((char *) &descr, sizeof(descr), 1, fd);
-	if (ret < 0)
+	if (ret != 1) {
+		err("Cannot read vudc device descr file: %s", strerror(errno));
 		goto err;
+	}
 	fclose(fd);
 
 	copy_descr_attr(dev, &descr, bDeviceClass);
-- 

7. 의견

: hacktoberfest : hacktoberfest는 10월간 오픈소스 컨트리뷰션 활성화를 위해 매년 10월에 열리는 대표적인 글로벌 오픈소스 컨트리뷰션 행사임.

8. 시도중이던 내용

uftrace에서 효과적으로 버그를 찾기 위하여, libfuzzer를 이용하여 테스트 케이스를 제작하였음.
이러한 시도가 성공적으로 완료될 경우 google ossfuzz에 병합시켜 google 인프라를 사용하여 버그를 효과적으로 찾을 수 있음.

9. 후기

작년에도 컨트리뷰톤을 통해 많은것들을 배울 수 있었다. 그래서 올해 컨트리뷰톤에 동일한 프로젝트에 참가하였고 작년과 다른 관점에서 코드레벨 버그 패치뿐만 아니라 기능추가, 문서번역, 버그레포팅, 의견제시, 커널기여 등 다양한 영역에서 활동하여 많은 것들을 배울 수 있었다.

특히나 이번 기회를 통해 처음으로 커널에도 컨트리뷰션을 할 수 있었고 매우 값진 경험이었다.

@gy741 gy741 closed this as completed Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant