René's URL Explorer Experiment


Title: fix: correct pinned maps handling and implement missing userspace setup by SiyuanSun0736 · Pull Request #13 · multikernel/kernelscript · GitHub

Open Graph Title: fix: correct pinned maps handling and implement missing userspace setup by SiyuanSun0736 · Pull Request #13 · multikernel/kernelscript

X Title: fix: correct pinned maps handling and implement missing userspace setup by SiyuanSun0736 · Pull Request #13 · multikernel/kernelscript

Description: Summary This PR fixes critical issues in the pin keyword implementation for map declarations. Previously, pinned maps were incorrectly treated as global variables, leading to runtime failures. Additionally, this PR introduces a robust userspace setup including automatic directory creation and unique variable naming. Problems Addressed IR Generation Conflict: Pinned maps incorrectly generated both an IR map definition and an IR global variable. This caused userspace codegen to search for a non-existent __pinned_globals map, resulting in: Failed to find pinned globals map in eBPF object. Missing Setup Logic: Map pinning logic was only triggered if the map was explicitly accessed in userspace C code. Pinned maps must be initialized even if used solely within the eBPF program. Variable Name Collisions: Multiple pinned maps caused C compilation errors due to the hardcoded use of a single variable name (existing_fd) for all map instances. FS Path Failures: The pinning process failed if the target directory in /sys/fs/bpf/ did not already exist. Implementation Details (Before vs. After) 1. Fixing Incorrect Map Handling Before: The generator erroneously looked for a __pinned_globals map for any pinned variable. /* FAULTY LOGIC: Searching for non-existent global map */ pinned_globals_map_fd = bpf_obj_get("/sys/fs/bpf/maps_demo/globals/pinned_globals"); if (pinned_globals_map_fd < 0) { struct bpf_map *pinned_globals_map = bpf_object__find_map_by_name(obj->obj, "__pinned_globals"); if (!pinned_globals_map) { fprintf(stderr, "Failed to find pinned globals map in eBPF object\n"); // <--- Runtime Error return 1; } } After: Directly handles the specific map and ensures the BPF file system path is ready. /* CORRECTED LOGIC: Direct map handling with unique naming and directory setup */ struct bpf_map *event_log_map = bpf_object__find_map_by_name(obj->obj, "event_log"); int event_log_existing_fd = bpf_obj_get("/sys/fs/bpf/maps_demo/maps/event_log"); if (event_log_existing_fd >= 0) { event_log_fd = event_log_existing_fd; } else { ensure_bpf_dir("/sys/fs/bpf/maps_demo/maps"); // Recursive directory creation bpf_map__pin(event_log_map, "/sys/fs/bpf/maps_demo/maps/event_log"); event_log_fd = bpf_map__fd(event_log_map); } 2. Robust Directory Creation Added ensure_bpf_dir C helper function to recursively create paths (e.g., /sys/fs/bpf//maps/) before pinning, preventing "No such file or directory" errors. Proposed Changes IR Generator (ir_generator.ml): Modified to ensure map-type global declarations only produce map definitions, preventing redundant global variable entries. Userspace Codegen (userspace_codegen.ml): Forced map setup/FD declarations if has_pinned_maps is detected. Implemented unique variable naming (e.g., %s_existing_fd) to support multiple pinned maps. Injected ensure_bpf_dir helper and required headers (, ). Verification Results Test Case: examples/maps_demo.ks Results: * Resolved the __pinned_globals lookup error. Verified maps are correctly pinned to /sys/fs/bpf/maps_demo/maps/. Verified successful compilation and multi-map support.

Open Graph Description: Summary This PR fixes critical issues in the pin keyword implementation for map declarations. Previously, pinned maps were incorrectly treated as global variables, leading to runtime failures. Addi...

X Description: Summary This PR fixes critical issues in the pin keyword implementation for map declarations. Previously, pinned maps were incorrectly treated as global variables, leading to runtime failures. Addi...

Opengraph URL: https://github.com/multikernel/kernelscript/pull/13

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:1cda1a30-6b61-5bc9-6852-180c8f5c0c53
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idACFE:2102F4:6736DA:9597C2:6A622A2F
html-safe-nonced0a7f754378a7770674f5fab88f2d9055a86544d6eea6a7a51ab7ae31548b95d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQ0ZFOjIxMDJGNDo2NzM2REE6OTU5N0MyOjZBNjIyQTJGIiwidmlzaXRvcl9pZCI6IjM2NDcxMDQ3NjcxNzk3NjIyMjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmace000252718debd09fbba4c10df109bc7876e44eedbeab5495d5c88d4632c796d
hovercard-subject-tagpull_request:3366950025
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/multikernel/kernelscript/pull/13/files
twitter:imagehttps://avatars.githubusercontent.com/u/100674758?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/100674758?s=400&v=4
og:image:altSummary This PR fixes critical issues in the pin keyword implementation for map declarations. Previously, pinned maps were incorrectly treated as global variables, leading to runtime failures. Addi...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None0e882415c7b47986d65f899389c870b31642bb1c6f36516eb042618596c60e62
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/multikernel/kernelscript git https://github.com/multikernel/kernelscript.git
octolytics-dimension-user_id202362072
octolytics-dimension-user_loginmultikernel
octolytics-dimension-repository_id1019261571
octolytics-dimension-repository_nwomultikernel/kernelscript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1019261571
octolytics-dimension-repository_network_root_nwomultikernel/kernelscript
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release230e2af5fc0870303dd4569d72d2bb393ed52c52
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/multikernel/kernelscript/pull/13/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmultikernel%2Fkernelscript%2Fpull%2F13%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmultikernel%2Fkernelscript%2Fpull%2F13%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=multikernel%2Fkernelscript
Reloadhttps://github.com/multikernel/kernelscript/pull/13/files
Reloadhttps://github.com/multikernel/kernelscript/pull/13/files
Reloadhttps://github.com/multikernel/kernelscript/pull/13/files
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/13/files
multikernel https://github.com/multikernel
kernelscripthttps://github.com/multikernel/kernelscript
Notifications https://github.com/login?return_to=%2Fmultikernel%2Fkernelscript
Fork 23 https://github.com/login?return_to=%2Fmultikernel%2Fkernelscript
Star 501 https://github.com/login?return_to=%2Fmultikernel%2Fkernelscript
Code https://github.com/multikernel/kernelscript
Issues 2 https://github.com/multikernel/kernelscript/issues
Pull requests 0 https://github.com/multikernel/kernelscript/pulls
Actions https://github.com/multikernel/kernelscript/actions
Projects https://github.com/multikernel/kernelscript/projects
Security and quality 0 https://github.com/multikernel/kernelscript/security
Insights https://github.com/multikernel/kernelscript/pulse
Code https://github.com/multikernel/kernelscript
Issues https://github.com/multikernel/kernelscript/issues
Pull requests https://github.com/multikernel/kernelscript/pulls
Actions https://github.com/multikernel/kernelscript/actions
Projects https://github.com/multikernel/kernelscript/projects
Security and quality https://github.com/multikernel/kernelscript/security
Insights https://github.com/multikernel/kernelscript/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fmultikernel%2Fkernelscript%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmultikernel%2Fkernelscript%2Fissues%2Fnew%2Fchoose
congwang-mkhttps://github.com/congwang-mk
multikernel:mainhttps://github.com/multikernel/kernelscript/tree/main
SiyuanSun0736:fix_pin_var_maphttps://github.com/SiyuanSun0736/kernelscript/tree/fix_pin_var_map
Conversation 3 https://github.com/multikernel/kernelscript/pull/13
Commits 3 https://github.com/multikernel/kernelscript/pull/13/commits
Checks 0 https://github.com/multikernel/kernelscript/pull/13/checks
Files changed https://github.com/multikernel/kernelscript/pull/13/files
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/13/files
fix: correct pinned maps handling and implement missing userspace setup https://github.com/multikernel/kernelscript/pull/13/files#top
Show all changes 3 commits https://github.com/multikernel/kernelscript/pull/13/files
b850632 fix bugs in pin var maps SiyuanSun0736 Mar 4, 2026 https://github.com/multikernel/kernelscript/pull/13/commits/b8506325ccc9b5869ef4c87276135dfb08606de7
4e39a7d Add path length checks to ensure the security of creating BPF directo… SiyuanSun0736 Mar 10, 2026 https://github.com/multikernel/kernelscript/pull/13/commits/4e39a7dae7b5a9e9b6b94943976bcaf374f801df
1585094 tests: add comprehensive test suite for userspace map generation and … SiyuanSun0736 Mar 10, 2026 https://github.com/multikernel/kernelscript/pull/13/commits/15850942337635f9825a0e1d4459fba79b1c0f6c
Clear filters https://github.com/multikernel/kernelscript/pull/13/files
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/13/files
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/13/files
ir_generator.ml https://github.com/multikernel/kernelscript/pull/13/files#diff-7b7b3d36c6a326e1a022a7eaf0e67082de1abe843a789dc49e3580493ba9ffdf
userspace_codegen.ml https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
test_userspace_maps.ml https://github.com/multikernel/kernelscript/pull/13/files#diff-cd1f472eed7ea998fc791ec3e4e10456557e965feabb7cd51993d87800cbb184
src/ir_generator.mlhttps://github.com/multikernel/kernelscript/pull/13/files#diff-7b7b3d36c6a326e1a022a7eaf0e67082de1abe843a789dc49e3580493ba9ffdf
View file https://github.com/SiyuanSun0736/kernelscript/blob/15850942337635f9825a0e1d4459fba79b1c0f6c/src/ir_generator.ml
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/multikernel/kernelscript/pull/13/{{ revealButtonHref }}
https://github.com/multikernel/kernelscript/pull/13/files#diff-7b7b3d36c6a326e1a022a7eaf0e67082de1abe843a789dc49e3580493ba9ffdf
https://github.com/multikernel/kernelscript/pull/13/files#diff-7b7b3d36c6a326e1a022a7eaf0e67082de1abe843a789dc49e3580493ba9ffdf
https://github.com/multikernel/kernelscript/pull/13/files#diff-7b7b3d36c6a326e1a022a7eaf0e67082de1abe843a789dc49e3580493ba9ffdf
https://github.com/multikernel/kernelscript/pull/13/files#diff-7b7b3d36c6a326e1a022a7eaf0e67082de1abe843a789dc49e3580493ba9ffdf
src/userspace_codegen.mlhttps://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
View file https://github.com/SiyuanSun0736/kernelscript/blob/15850942337635f9825a0e1d4459fba79b1c0f6c/src/userspace_codegen.ml
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/multikernel/kernelscript/pull/13/{{ revealButtonHref }}
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
congwang-mkhttps://github.com/congwang-mk
Mar 9, 2026https://github.com/multikernel/kernelscript/pull/13/files#r2908361284
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/13/files
https://github.com/multikernel/kernelscript/pull/13/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/13/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.