Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
全銀トラブルとC言語とバッファオーバーフロー
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
tsuda.a
December 27, 2023
Technology
160
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
全銀トラブルとC言語とバッファオーバーフロー
全銀トラブル話題にかこつけたC言語でバッファオーバーフローさせる話
tsuda.a
December 27, 2023
More Decks by tsuda.a
See All by tsuda.a
Git を GUI で使う話
tsudaahr
0
150
マジカルインクリメントと指数表記
tsudaahr
0
300
バックアップしていますか?
tsudaahr
0
170
RDB以前のファイル設計の話でもしようか(ぇ
tsudaahr
0
180
NPUわからん
tsudaahr
0
240
計算量オーダーの話
tsudaahr
1
490
クラウド初学者が抱える不安について
tsudaahr
0
480
キューとは何か
tsudaahr
0
310
等幅は死んだ(ぇ
tsudaahr
0
160
Other Decks in Technology
See All in Technology
データマネジメント × 法務で作りあげる、 freeeの新しいデータガバナンスへの軌跡
freee
PRO
3
610
Devin プロモコードの受け取りと適用(2026.10.27)
kinopeee
1
800
Lint の層を組み直した話
bengo4com
1
280
なぜAI時代に技術記事を書くのか?どう書くのか? 〜bunの場合〜
kworkdev
PRO
0
3.4k
2拠点SRE活動始めてみた | sogaoh's LT @ ホンマでっかSRE勉強会 #3
sogaoh
PRO
0
230
WireGuard for Apache NuttX - Bringing Secure Remote Access to embedded Devices -
aki310ooooo
0
110
仕様駆動開発の、その先へ。決める力と確かめる仕組み
inariku
1
150
OneLakeをデータソースにした AI Search(Foundry IQ)の ライフサイクル管理
ryuseiiida
0
220
AIコーディングエージェント開発_全体像
happysamurai294
0
140
E2Eってつらくないですか?E2Eの管理コストを下げる手段とその実践
akaboshinit
6
2.9k
新米を「売り越さない」、Aurora DSQLで作る在庫ゼロ死守の限定ドロップEC
yama3133
0
130
なぜ東京にいる私が、新潟の技術コミュニティを運営するのか by 八雲慎之助
yakumo
0
210
Featured
See All Featured
Site-Speed That Sticks
csswizardry
13
1.6k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
59k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
380
A Modern Web Designer's Workflow
chriscoyier
699
190k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
550
New Earth Scene 8
popppiees
4
2.7k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
240
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Un-Boring Meetings
codingconduct
0
480
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
600
Transcript
全銀トラブルとC言語と バッファオーバーフロー LTDD 2023-12 #2 すごい広島553 with IT初心者の会 忘年会 @tsuda_ahr
全銀システム障害 https://xtech.nikkei.com/atcl/nxt/mag/nc/18/020600011/101800142/
原因は? • バッファオーバーフローらしい? https://it.impress.co.jp/articles/-/25677
いまどき、なぜ? • C言語らしい・・・ _| ̄|◦ https://it.impress.co.jp/articles/-/25677
アーキテクチャ(CPU のビット数)とデータ型とサイズ • C言語における long の値域。 https://marycore.jp/prog/c-lang/data-type-min-max-values/
なぜこんなことが起きるのか? • int は CPU のビット数, long は その倍、という取り決めがあるから? (すみません規格読んでません
>__<;) • しかし、どうもそういうことでもない模様。 • まとめると以下のような感じ。 #ポリシーがよくわからん データ型 16bit CPU 32bit CPU 64bit CPU int 2 byte (INT_16) 4 byte (INT_32) 4 byte (INT_32) long 4 byte (INT_32) 4 byte (INT_32) 8 byte (INT_64) long long - 8 byte (INT_64) 8 byte (INT_64)
Windows の場合 • Windows の場合は変わらない? https://marycore.jp/prog/c-lang/data-type-min-max-values/
Windows (Visual C++) のデータ型とサイズ • int も long も INT32。
種類名 バイト 値の範囲 int 4 -2,147,483,648 ~ 2,147,483,647 __int32 4 -2,147,483,648 ~ 2,147,483,647 long 4 -2,147,483,648 ~ 2,147,483,647 https://learn.microsoft.com/ja-jp/cpp/cpp/data-type-ranges?view=msvc-170
では、Window の場合は安心なのか? • そんなこともない。 • 例えば以下のようなコードを考える #include <iostream> struct TEST
{ int *A; int *B; }; int main() { int a = (int)sizeof(TEST); printf("%d¥n", a); } ポインタ変数 (他の言語では参照型といわれるものに近い)
アーキテクチャ(CPUのビット数)によってサイズが変わる 32bit 64bit 8 16
なので 32bit ではうまく動作したプログラムが 64bit では動かないことがある。 64bit 環境でコンパイル、実行すると、 スタック領域が壊れたっぽいわ、 というメッセージが出る。 転送先バッファのサイズは
8 固定 test の内容を buff に test のサイズ指定でコピー test のサイズは 32bit のとき 8、64 bit のとき 16。
こちらからは以上です(汗 チャンネル登録、高評価をよろしくお願いします。
余談/発表後にした話) ALSR 最近のコンパイラは ALSR(address space layout randomization/アドレス空間配置の ランダム化)という機能があるので、実行の都度、壊れる場所は変わるかも? (つまり、障害が再現したりしなかったりするとかありそう) https://ja.wikipedia.org/wiki/アドレス空間配置のランダム化