JP2007041777A - Language processing method - Google Patents

Language processing method Download PDF

Info

Publication number
JP2007041777A
JP2007041777A JP2005224121A JP2005224121A JP2007041777A JP 2007041777 A JP2007041777 A JP 2007041777A JP 2005224121 A JP2005224121 A JP 2005224121A JP 2005224121 A JP2005224121 A JP 2005224121A JP 2007041777 A JP2007041777 A JP 2007041777A
Authority
JP
Japan
Prior art keywords
function
program
function pointer
list
pointer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
JP2005224121A
Other languages
Japanese (ja)
Inventor
Yuichiro Aoki
雄一郎 青木
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hitachi Ltd
Original Assignee
Hitachi Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP2005224121A priority Critical patent/JP2007041777A/en
Publication of JP2007041777A publication Critical patent/JP2007041777A/en
Withdrawn legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To generate a program or an object code capable of protecting function pointer variables against buffer overflow attacks and to reduce execution time overhead caused by a security check process. <P>SOLUTION: A function pointer variable within an input program is detected and a list of functions that a function pointer can indicate is generated. A process for checking to see if the value of the function pointer variable is an illegal value by use of the list of functions is added immediately before a function call that uses the function pointer variable. <P>COPYRIGHT: (C)2007,JPO&INPIT

Description

本発明は、ソースプログラムを入力して、コンピュータで実行可能なプログラムまたはオブジェクトコードを生成する言語処理方法に関する。   The present invention relates to a language processing method for inputting a source program and generating a computer-executable program or object code.

プログラムに対するセキュリティ攻撃の1つに、バッファオーバフロー攻撃がある。これは、プログラムの関数スタック上のローカル変数に変数サイズ以上の長さの不正な入力データを与えることによって、関数スタックの破壊や、関数スタック上に格納されているリターンアドレスの書き換えなどを行い、プログラムの制御を奪うものである。   One of the security attacks against the program is a buffer overflow attack. This is done by giving invalid input data longer than the variable size to local variables on the function stack of the program, thereby destroying the function stack and rewriting the return address stored on the function stack. It takes control of the program.

従来、このような攻撃を防御するコンパイラを用いた言語処理方法として、StackGuardが知られている(例えば、非特許文献1参照)。これは、関数プロローグで、関数スタックのリターンアドレス格納部の直前にcanaryと呼ばれる特別な値を設定し、関数エピローグでcanaryの値が変更されていたら、バッファオーバフロー攻撃を受けたと判断してプログラムを終了させるという方法である。ここで、関数プロローグとは、コンパイラが関数内に追加する前処理のことであり、関数エピローグとは、コンパイラが関数内に追加する後処理のことである。   Conventionally, StackGuard is known as a language processing method using a compiler that protects against such attacks (see Non-Patent Document 1, for example). This is a function prologue that sets a special value called canary just before the return address storage part of the function stack, and if the value of canary has been changed by the function epilogue, it is determined that a buffer overflow attack has occurred and the program is executed. It is a method of terminating. Here, the function prologue is preprocessing added by the compiler in the function, and the function epilogue is postprocessing added by the compiler in the function.

また、別の言語処理方法としてPointGuardが知られている(例えば、非特許文献2参照)。これは、関数ポインタの値をメモリ上では暗号化しておき、関数ポインタがプロセッサのレジスタにロードされる場合に、関数ポインタの値を復号化するという方法である。PointGuardの方法を適用すると、バッファオーバフロー攻撃を受けて関数ポインタの値を書き換えられても、プロセッサのレジスタにロードされる値は書き換えた値を更に復号化した値になるため、攻撃を行った悪意あるユーザが書き換えた値はロードされず、攻撃は成功しない。
Crispin Cowan, Calton Pu, Dave Maier, Jonathan Walpole, Peat Bakke, Steve Beattie, Aaron Grier, Perry Wagle, and Qian Zhang “StackGuard: Automatic Adaptive Detection and Prevention of Buffer-Overflow Attacks”, Proceedings of the 7th USENIX Security Symposium, pp.26-29, 1998 Crispin Cowan, Steve Beattie, John Johansen, and Perry Wagle, “PointGuard(TM): Protecting Pointers From Buffer Overflow Vulnerabilities”, Proceedings of the 12th USENIX Security Symposium, 2003
Further, PointGuard is known as another language processing method (see, for example, Non-Patent Document 2). In this method, the value of the function pointer is encrypted on the memory, and when the function pointer is loaded into the register of the processor, the value of the function pointer is decrypted. When PointGuard's method is applied, even if the value of the function pointer is rewritten due to a buffer overflow attack, the value loaded into the processor's register becomes a value obtained by further decoding the rewritten value. The value rewritten by a user is not loaded and the attack is not successful.
Crispin Cowan, Calton Pu, Dave Maier, Jonathan Walpole, Peat Bakke, Steve Beattie, Aaron Grier, Perry Wagle, and Qian Zhang “StackGuard: Automatic Adaptive Detection and Prevention of Buffer-Overflow Attacks”, Proceedings of the 7th USENIX Security Symposium, pp.26-29, 1998 Crispin Cowan, Steve Beattie, John Johansen, and Perry Wagle, “PointGuard (TM): Protecting Pointers From Buffer Overflow Vulnerabilities”, Proceedings of the 12th USENIX Security Symposium, 2003

非特許文献1のStackGuardは、関数スタック上のローカル変数から関数スタック上のリターンアドレスまでを、不正な入力データが書きつぶすことを前提とした防御方法である。そのため、このような書きつぶしを行わない攻撃を防御することはできない。   Non-Patent Document 1 StackGuard is a defense method based on the premise that illegal input data is written from a local variable on the function stack to a return address on the function stack. Therefore, it is not possible to defend against attacks that do not perform such writing.

例として、関数ポインタ変数が、関数スタック上の変数、つまりローカル変数である場合を考える。当該関数ポインタ変数以外のローカル変数に、関数ポインタ変数を書き換えることはできるがリターンアドレスを書き換えるほどは長くない不正な入力データが与えられるとする。この場合、リターンアドレスは書き換えられないので、前記従来技術のStackGuardでは攻撃を検出できない。また、不正な入力データが与えられた点からこの関数が終了するまでの間に、書き換えられた関数ポインタ変数を用いた関数呼出しがあった場合、書き換えられた値をアドレスとしてもつ場所へ制御が移ってしまう。このアドレスが悪意あるコードの先頭であった場合は、攻撃を仕掛けたユーザに制御が奪われる可能性がある。   As an example, consider a case where the function pointer variable is a variable on the function stack, that is, a local variable. It is assumed that invalid input data is given to a local variable other than the function pointer variable, which can rewrite the function pointer variable but is not long enough to rewrite the return address. In this case, since the return address cannot be rewritten, the prior art StackGuard cannot detect an attack. In addition, if there is a function call using a rewritten function pointer variable between the point when invalid input data is given and the end of this function, control is made to a location having the rewritten value as an address. It will move. If this address is at the beginning of a malicious code, there is a possibility that control will be taken away by the user who made the attack.

非特許文献2のPointGuardは、関数ポインタ変数への書き込み時およびレジスタへの読み出し時に、それぞれ値の暗号化、復号化を行うので、関数ポインタ変数がローカル変数であった場合でも攻撃を検出できる。しかし、関数ポインタ変数へのすべての書き込み/読み出し時に値の暗号化/復号化を行うので、このセキュリティチェック処理による実行時オーバヘッドが大きいという問題があった。   Since PointGuard of Non-Patent Document 2 encrypts and decrypts values when writing to a function pointer variable and when reading from a register, respectively, even when the function pointer variable is a local variable, an attack can be detected. However, since the value is encrypted / decrypted at every writing / reading to the function pointer variable, there is a problem that the overhead at the time of execution by this security check process is large.

本発明は、以上のような問題点に鑑みてなされたものであり、関数ポインタ変数に対するバッファオーバフロー攻撃を防御可能なプログラムまたはオブジェクトコードを生成することを目的とする。また、セキュリティチェック処理による実行時オーバヘッドを軽減させることを目的とする。   The present invention has been made in view of the above problems, and an object of the present invention is to generate a program or object code that can prevent a buffer overflow attack on a function pointer variable. It is another object of the present invention to reduce runtime overhead due to security check processing.

前記目的を達成するため、本発明の言語処理方法は、ソースプログラムを入力して、コンピュータで実行可能なプログラムまたはオブジェクトコードを生成するコンピュータにより実行される言語処理方法であって、前記コンピュータが、前記ソースプログラムを格納する記憶部と、処理部とを備え、前記処理部が、前記記憶部から前記ソースプログラムを読み出し、そのソースプログラムの構文を解析して、当該ソースプログラムを中間語に変換するステップと、当該中間語中の関数ポインタ変数により呼出される可能性がある関数の関数リストを作成するステップと、当該関数ポインタ変数が当該関数リストに登録されている関数を指すか否かを判定し、当該関数ポインタ変数が当該関数リストに登録されていない関数を指すと判定された場合には、関数呼出しを中止する関数ポインタチェックコードを、前記中間語中の関数ポインタ変数を用いた関数呼出しの直前に挿入するステップと、前記関数ポインタチェックコードが挿入された当該中間語を、前記コンピュータで実行可能なプログラムまたはオブジェクトコードに変換するステップと、を実行することを特徴とした。   To achieve the above object, a language processing method of the present invention is a language processing method executed by a computer that inputs a source program and generates a computer-executable program or object code. A storage unit for storing the source program; and a processing unit. The processing unit reads the source program from the storage unit, analyzes the syntax of the source program, and converts the source program into an intermediate language. Step, creating a function list of functions that may be called by the function pointer variable in the intermediate language, and determining whether the function pointer variable points to a function registered in the function list The function pointer variable is determined to point to a function not registered in the function list. The function pointer check code for canceling the function call is inserted immediately before the function call using the function pointer variable in the intermediate language, and the intermediate language in which the function pointer check code is inserted is And converting the program into an object code executable by the computer.

かかる方法によれば、関数ポインタ変数に対するバッファオーバフロー攻撃を防御可能なプログラムまたはオブジェクトコードを生成することが可能である。また、セキュリティチェックによる実行時オーバヘッドを軽減させることができる。   According to such a method, it is possible to generate a program or object code that can prevent a buffer overflow attack on a function pointer variable. In addition, it is possible to reduce runtime overhead due to security checks.

ここで、関数呼出しの直前とは、関数ポインタ変数による関数の呼出し実行直前を意味する。例えば、行や、<>、カンマ等で区切られた列の直前が該当する。しかし、たとえ関数の呼出し実行前であっても、関数ポインタ変数に設定されているアドレスの値を書き換える処理がある場合には、その処理よりも前であってはならない。関数ポインタチェックコードによってチェックされたアドレスと、実際にその関数ポインタを用いて呼出す関数のアドレスとが異なってしまう可能性があるからである。   Here, “immediately before a function call” means immediately before a function call is executed by a function pointer variable. For example, it corresponds to a line or immediately before a column delimited by <> or comma. However, even before a function call is executed, if there is a process for rewriting the address value set in the function pointer variable, it must not be before that process. This is because the address checked by the function pointer check code may be different from the address of the function that is actually called using the function pointer.

本発明の言語処理方法によれば、関数ポインタ変数に対するバッファオーバフロー攻撃を防御可能なプログラムまたはオブジェクトコードを生成することが可能である。また、セキュリティチェックによる実行時オーバヘッドを軽減させることが可能である。   According to the language processing method of the present invention, it is possible to generate a program or object code that can prevent a buffer overflow attack on a function pointer variable. It is also possible to reduce the runtime overhead due to the security check.

(第1の実施形態)
以下、図面を用いて本発明の第1の実施形態について説明する。
図1は、第1の実施形態における高信頼プログラム生成コンパイラの機能例を示す図である。
図1に示すように、高信頼プログラム生成コンパイラ10は、構文解析部11と、高信頼プログラム生成部13と、コード生成部15とを含んで構成されている。
(First embodiment)
Hereinafter, a first embodiment of the present invention will be described with reference to the drawings.
FIG. 1 is a diagram illustrating an example of functions of the highly reliable program generation compiler according to the first embodiment.
As shown in FIG. 1, the highly reliable program generation compiler 10 includes a syntax analysis unit 11, a high reliability program generation unit 13, and a code generation unit 15.

構文解析部11は、入力プログラム90を入力して中間語91を出力する。構文解析部11の処理は、通常のコンパイラが有する公知の構文解析の機能による処理と特に変わらないため、重複説明は省略する。   The syntax analysis unit 11 inputs the input program 90 and outputs an intermediate language 91. The processing of the parsing unit 11 is not particularly different from the processing by a known parsing function of a normal compiler, and thus a duplicate description is omitted.

高信頼プログラム生成部13は、中間語91を入力し、後記するチェックコード等を挿入した中間語91を出力する。高信頼プログラム生成部13は、関数リスト作成部131と、関数ポインタチェック挿入部133とを含んで構成されている。
関数リスト作成部131は、中間語91を入力して、その中からローカルな関数ポインタを見つけ、当該関数ポインタが指す可能性のある関数のリストである関数リスト93を出力する。
関数ポインタチェック挿入部133は、中間語91および関数リスト93を入力して、当該関数ポインタ変数を用いた関数呼出しの直前に、当該関数ポインタ変数の値が不正な値でないかを調べる関数ポインタチェックコードを挿入し、中間語91を出力する。関数ポインタチェック挿入部133は、関数ポインタ変数の値が、関数リスト93に登録されているものでなければ、不正な値であると判定する。
The high-reliability program generation unit 13 inputs the intermediate language 91 and outputs the intermediate language 91 into which a check code or the like to be described later is inserted. The high reliability program generation unit 13 includes a function list creation unit 131 and a function pointer check insertion unit 133.
The function list creation unit 131 receives the intermediate language 91, finds a local function pointer from the intermediate word 91, and outputs a function list 93 that is a list of functions that the function pointer may point to.
The function pointer check insertion unit 133 receives the intermediate language 91 and the function list 93, and checks whether the value of the function pointer variable is an invalid value immediately before the function call using the function pointer variable. The code is inserted and the intermediate language 91 is output. If the value of the function pointer variable is not registered in the function list 93, the function pointer check insertion unit 133 determines that the value is invalid.

コード生成部15は、関数ポインタチェックコードを挿入した中間語91を入力して、プログラムまたはオブジェクトコードである出力プログラム92を出力する。コード生成部15の処理は、通常のコンパイラが有する公知のコード生成の機能による処理と特に変わらないため、重複説明は省略する。   The code generation unit 15 inputs the intermediate language 91 into which the function pointer check code is inserted, and outputs an output program 92 that is a program or object code. The processing of the code generation unit 15 is not particularly different from the processing by a known code generation function of a normal compiler, and thus a duplicate description is omitted.

図2は、第1の実施形態における高信頼プログラム生成コンパイラ10(図1参照)による処理を実行する言語処理装置のハードウェア構成の一例を示す図である。
図2において、言語処理装置520は、コンピュータであり、表示装置521と、入力装置522と、外部記憶装置523と、情報処理装置524と、記録媒体525と、駆動装置526とを含んで構成される。表示装置521は、LCD(Liquid Crystal Display)等によって構成され、文字や画像等を表示する。入力装置522は、キーボードやマウス等によって構成され、操作者からの指示を入力する。外部記憶装置523は、HDD(Hard Disk Drive)等によって構成され、大容量のデータやプログラム等を記憶する。情報処理装置524は、処理部5241と記憶部5242とを含んで構成され、処理部5241は、例えばCPU(Central Processing Unit)等の処理装置であり、記憶部5242は、例えば主メモリ等の記憶装置である。情報処理装置524は、蓄積プログラム方式による演算処理を行う。記録媒体525は、後記処理手順に係るプログラムやデータを記録した光ディスク等である。駆動装置526は、記録媒体525を駆動する装置である。
FIG. 2 is a diagram illustrating an example of a hardware configuration of a language processing apparatus that executes processing by the high-reliability program generation compiler 10 (see FIG. 1) according to the first embodiment.
In FIG. 2, the language processing device 520 is a computer, and includes a display device 521, an input device 522, an external storage device 523, an information processing device 524, a recording medium 525, and a driving device 526. The The display device 521 is configured by an LCD (Liquid Crystal Display) or the like, and displays characters, images, and the like. The input device 522 is configured by a keyboard, a mouse, and the like, and inputs instructions from the operator. The external storage device 523 is configured by an HDD (Hard Disk Drive) or the like, and stores large-capacity data, programs, and the like. The information processing device 524 includes a processing unit 5241 and a storage unit 5242. The processing unit 5241 is a processing device such as a CPU (Central Processing Unit), for example. The storage unit 5242 is a storage such as a main memory, for example. Device. The information processing device 524 performs arithmetic processing by an accumulation program method. The recording medium 525 is an optical disk or the like on which a program and data related to a later-described processing procedure are recorded. The driving device 526 is a device that drives the recording medium 525.

情報処理装置524は、駆動装置526を介して読み出された記録媒体525内のデータやプログラム等を外部記憶装置523に記憶させる。情報処理装置524は、外部記憶装置523に記憶されたデータやプログラムを主メモリにロードし、そのデータを利用し、プログラムを実行する。これにより、各処理部によって構成される高信頼プログラム生成コンパイラ10(図1参照)や、高信頼プログラム生成リンカ20(図12参照)などといった高信頼プログラムを生成するためのソフトウェアを実現する。   The information processing device 524 stores data, programs, and the like in the recording medium 525 read through the driving device 526 in the external storage device 523. The information processing device 524 loads the data and program stored in the external storage device 523 into the main memory, uses the data, and executes the program. Thus, software for generating a highly reliable program such as the highly reliable program generating compiler 10 (see FIG. 1) and the highly reliable program generating linker 20 (see FIG. 12) configured by each processing unit is realized.

図3は、第1の実施形態における入力プログラム90(図1参照)の一例を示す図である。ここでは、入力プログラム901は、コンパイルに必要なすべてのソースプログラムであると仮定する。入力プログラム901の左端にある番号は行番号を示している。
入力プログラム901の1行目は標準ライブラリヘッダファイルstdlib.hをインクルードする文である。2行目は関数funcのプロトタイプ宣言である。3〜4行目は入力プログラム901の主処理関数mainであり、その中の4行目はプログラム起動時のコマンドライン第1引数を実引数として関数funcを呼び出す関数呼出し文である。5〜11行目は関数funcの本体である。6行目でローカルな関数ポインタ変数testが宣言され、8行目でこの変数testに標準ライブラリ関数exitの関数ポインタを代入し、9行目で関数funcの第1引数inputの値を要素数3のローカル配列bufにコピーし、10行目で関数ポインタtestを介して関数exitを呼び出す。
FIG. 3 is a diagram illustrating an example of the input program 90 (see FIG. 1) in the first embodiment. Here, it is assumed that the input program 901 is all source programs necessary for compilation. The number at the left end of the input program 901 indicates a line number.
The first line of the input program 901 is a statement that includes the standard library header file stdlib.h. The second line is the prototype declaration of the function func. The 3rd to 4th lines are the main processing function main of the input program 901, and the 4th line therein is a function call statement that calls the function func with the command line first argument at the time of starting the program as an actual argument. Lines 5-11 are the body of the function func. The local function pointer variable test is declared in the 6th line, the function pointer of the standard library function exit is assigned to this variable test in the 8th line, and the value of the first argument input of the function func is set to the number of elements 3 in the 9th line. The function exit is called via the function pointer test on the 10th line.

図4は、第1の実施形態における関数リスト93(図1参照)の一例を示す図である。関数リスト931の第1フィールドには、次の関数リスト932へのポインタが設定され、関数リスト931の第2フィールドには、図3の入力プログラム901から呼び出される可能性のある関数funcの名前が登録されている。同様に、関数リスト932の第1フィールドには、次の関数リスト933へのポインタが設定され、関数リスト932の第2フィールドには、図3の入力プログラム901から呼び出される可能性のある関数strcpyの名前が登録されている。関数リスト933の第1フィールドには、次のリストがないことを表すNULL値が設定され、関数リスト933の第2フィールドには、図3の入力プログラム901から呼び出される可能性のある関数exitの名前が登録されている。図3の入力プログラム901に含まれる関数mainは、プログラム冒頭で1度だけ呼び出されるものであるので、関数リスト93には登録しない。なお、関数リスト93の表現については、線形リストに限らず、配列、ビットベクトル等による表現でも良い。   FIG. 4 is a diagram illustrating an example of the function list 93 (see FIG. 1) in the first embodiment. In the first field of the function list 931, a pointer to the next function list 932 is set. In the second field of the function list 931, the name of the function func that may be called from the input program 901 in FIG. It is registered. Similarly, a pointer to the next function list 933 is set in the first field of the function list 932, and a function strcpy that may be called from the input program 901 in FIG. 3 is set in the second field of the function list 932. The name of is registered. A NULL value indicating that there is no next list is set in the first field of the function list 933, and a function exit that may be called from the input program 901 in FIG. 3 is set in the second field of the function list 933. The name is registered. Since the function main included in the input program 901 in FIG. 3 is called only once at the beginning of the program, it is not registered in the function list 93. The expression of the function list 93 is not limited to a linear list, and may be expressed by an array, a bit vector, or the like.

図5は、第1の実施形態における出力プログラム92(図1参照)の一例を示す図である。ここでは、図3の入力プログラム901を図1における入力プログラム90とした場合に得られる出力プログラム92を示す。出力プログラム921の左端にある番号は行番号である。出力プログラム921の1〜9行目および11〜12行目は、入力プログラム901(図3参照)と同一なのでここでは説明しない。10行目は、関数ポインタチェック挿入部133(図1参照)が挿入した行であり、11行目の関数ポインタ変数testによる関数呼出し文の直前に、関数ポインタ変数の値が不正な値でないかを調べる関数_is_legal_func_ptrを呼出し、その返り値を引数として標準ライブラリ関数assertを呼び出す処理である。13〜18行目は関数ポインタチェック挿入部133(図1参照)が挿入した部分であり、引数で与えられた関数ポインタ変数の値が不正な値でないかを調べる関数_is_legal_func_ptrの本体である。14〜17行目は、引数で与えられた関数ポインタの値が、プログラム内で呼び出される可能性のある関数であるfunc、strcpyまたはexitへの関数ポインタと等しいか否かを調べ、等しい場合は1を、どの関数ポインタとも一致しない場合は0を返す処理である。標準ライブラリ関数assertは、引数として関数_is_legal_func_ptrの返り値1を受け取った場合はなにもせず、返り値0を受け取った場合は、標準エラー出力にエラーメッセージを出力してからプログラムを終了させる。プログラム内で呼び出される可能性のある関数は、図4の関数リスト931〜933を使用して列挙する。   FIG. 5 is a diagram showing an example of the output program 92 (see FIG. 1) in the first embodiment. Here, an output program 92 obtained when the input program 901 in FIG. 3 is changed to the input program 90 in FIG. 1 is shown. The number at the left end of the output program 921 is a line number. Lines 1-9 and 11-12 of the output program 921 are the same as the input program 901 (see FIG. 3) and will not be described here. The 10th line is a line inserted by the function pointer check insertion unit 133 (see FIG. 1), and whether the value of the function pointer variable is an invalid value immediately before the function call statement by the function pointer variable test of the 11th line. The function _is_legal_func_ptr is called, and the standard library function assert is called with the return value as an argument. The 13th to 18th lines are parts inserted by the function pointer check insertion unit 133 (see FIG. 1), and are the main body of the function _is_legal_func_ptr for checking whether the value of the function pointer variable given by the argument is an invalid value. Lines 14 to 17 check whether the value of the function pointer given by the argument is equal to the function pointer to func, strcpy, or exit, which is a function that may be called in the program. If 1 does not match any function pointer, 0 is returned. The standard library function assert does nothing when the return value 1 of the function _is_legal_func_ptr is received as an argument. When the return value 0 is received, the standard library function assert outputs an error message to the standard error output and terminates the program. Functions that may be called in the program are listed using the function lists 931 to 933 shown in FIG.

図6は、第1の実施形態における関数リスト作成部131(図1参照)の処理手順を表すフローチャートである。以下では、関数リスト作成部131(図1参照)の処理を中間語91(図1参照)に適用する場合について説明するが、ここでの中間語は、図3の入力プログラム901と同等のものであるため、適宜、入力プログラム901を用いて説明する。   FIG. 6 is a flowchart showing the processing procedure of the function list creation unit 131 (see FIG. 1) in the first embodiment. In the following, the case where the processing of the function list creation unit 131 (see FIG. 1) is applied to the intermediate language 91 (see FIG. 1) will be described. The intermediate language here is equivalent to the input program 901 in FIG. Therefore, description will be given using the input program 901 as appropriate.

まず、プログラム中の関数プロトタイプ宣言のうち、未処理のものを1つ選ぶ(S101)。プログラム中にinclude文がある場合は、プリプロセッサによってinclude文がすべて展開された後で本処理を行う。ここでは、未処理の関数プロトタイプ宣言の例として、入力プログラム901(図3参照)の2行目にある関数funcのプロトタイプ宣言を選択する。次に、選択した関数名を関数リストに登録する(S102)。ここでは、選択した関数funcのプロトタイプ宣言から関数名funcを取り出し、図4の関数リスト931の第2フィールドに書き込む。次に、プログラム中の全関数プロトタイプ宣言を処理したか否かを判定する(S103)。全関数プロトタイプ宣言を処理していない場合(S103でNo)は、S101に戻って処理を継続し、全関数プロトタイプ宣言を処理した場合(S103でYes)は、処理を終了する。ここでは、プロトタイプ宣言から関数名func、strcpyおよびexitをすべて取り出すまではS101に戻って処理を継続し、すべて取り出した後は、処理を終了する。   First, one unprocessed function prototype declaration in the program is selected (S101). If there is an include statement in the program, this process is performed after all the include statements are expanded by the preprocessor. Here, as an example of an unprocessed function prototype declaration, the prototype declaration of the function func on the second line of the input program 901 (see FIG. 3) is selected. Next, the selected function name is registered in the function list (S102). Here, the function name func is extracted from the prototype declaration of the selected function func, and is written in the second field of the function list 931 in FIG. Next, it is determined whether all function prototype declarations in the program have been processed (S103). If all function prototype declarations have not been processed (No in S103), the process returns to S101 to continue the process. If all function prototype declarations have been processed (Yes in S103), the process ends. Here, the process returns to S101 until the function names func, strcpy, and exit are all extracted from the prototype declaration, and the process is continued. After all the functions are extracted, the process ends.

図7は、第1の実施形態における関数ポインタチェック挿入部133(図1参照)の処理手順を表すフローチャートである。ここで例として扱う中間語は、入力される中間語は図3の入力プログラム901と、出力される中間語は図5の出力プログラム921と同等なので、適宜、入力プログラム901(図3参照)または出力プログラム921(図5参照)を用いて説明する。   FIG. 7 is a flowchart showing the processing procedure of the function pointer check insertion unit 133 (see FIG. 1) in the first embodiment. The intermediate language treated as an example here is that the input intermediate language is equivalent to the input program 901 in FIG. 3 and the output intermediate language is equivalent to the output program 921 in FIG. 5, so the input program 901 (see FIG. 3) or This will be described using the output program 921 (see FIG. 5).

まず、プログラム中の関数のうち、未処理のものを1つ選ぶ(S201)。プログラム中にinclude文がある場合は、プリプロセッサによってinclude文がすべて展開された後で本処理を行う。ここでは、未処理の関数の例として、入力プログラム901(図3参照)の5〜11行目にある関数funcを選択する。次に、選択した関数のローカル変数宣言に未処理の関数ポインタ変数宣言があるか否かを判定する(S202)。未処理の関数ポインタ変数宣言がある場合(S202でYes)は、S203に進む。未処理の関数ポインタ変数宣言がない場合(S202でNo)は、S204に進む。ここでは、入力プログラム901(図3参照)の6行目に示すように、選択した関数funcのローカル変数宣言の中に未処理の関数ポインタ変数宣言testがあるので、S203に進む。   First, one unprocessed function is selected from the functions in the program (S201). If there is an include statement in the program, this process is performed after all the include statements are expanded by the preprocessor. Here, as an example of an unprocessed function, the function func on the 5th to 11th lines of the input program 901 (see FIG. 3) is selected. Next, it is determined whether or not there is an unprocessed function pointer variable declaration in the local variable declaration of the selected function (S202). If there is an unprocessed function pointer variable declaration (Yes in S202), the process proceeds to S203. If there is no unprocessed function pointer variable declaration (No in S202), the process proceeds to S204. Here, as shown in the sixth line of the input program 901 (see FIG. 3), since there is an unprocessed function pointer variable declaration test in the local variable declaration of the selected function func, the process proceeds to S203.

S203では、S201において選択された関数内の関数ポインタ変数を用いたすべての関数呼出しに対して、その直前に関数ポインタチェック関数呼出しを挿入し(S203)、S202に戻る。S202の詳細は前記したのでここでは述べない。ここでは、中間語91(図1参照)の中から、S202で見つけた関数ポインタ変数testを用いた関数呼出し文をすべて探し、当該関数呼出し文の直前に、当該関数ポインタ変数を引数とした関数ポインタチェック関数の呼出し文を挿入する。出力プログラム921では、10行目の関数呼出し文が挿入された文に相当する。そして、関数ポインタ宣言がtest以外にはないので、S204に進む。   In S203, a function pointer check function call is inserted immediately before every function call using the function pointer variable in the function selected in S201 (S203), and the process returns to S202. The details of S202 have been described above and will not be described here. Here, all the function call statements using the function pointer variable test found in S202 are searched from the intermediate language 91 (see FIG. 1), and the function using the function pointer variable as an argument immediately before the function call statement. Insert a call statement for the pointer check function. The output program 921 corresponds to a statement in which the function call statement on the 10th line is inserted. Since there is no function pointer declaration other than test, the process proceeds to S204.

S204では、プログラム中の全関数を処理したかを判定する(S204)。プログラム中の全関数が処理済であればS205に進み、そうでなければS201に戻って処理を継続する。ここでは、中間語91(図1参照)内に、関数がfunc以外にないので、全関数が処理済であり、S205に進む。   In S204, it is determined whether all functions in the program have been processed (S204). If all functions in the program have been processed, the process proceeds to S205; otherwise, the process returns to S201 to continue the process. Here, since there is no function other than func in the intermediate language 91 (see FIG. 1), all functions have been processed, and the process proceeds to S205.

S205では、関数リスト93(図1参照)を用いて、関数ポインタチェック関数の本体を作成し、作成した本体をプログラム中に挿入する(S205)。ここでは、関数リスト931〜933(図4参照)を順にたどって関数リスト第2フィールドの関数名を抜き出し、抜き出した関数名で表される関数の関数ポインタと関数ポインタチェック関数の引数とを比較し、一致すれば1を、どの関数とも一致しなければ0を返す関数を作成する。出力プログラム921(図5参照)では、13〜18行目の処理が、本ステップで作成する関数に相当する。   In S205, a function pointer check function body is created using the function list 93 (see FIG. 1), and the created body is inserted into the program (S205). Here, the function list 931 to 933 (see FIG. 4) is traced to extract the function name in the second field of the function list, and the function pointer of the function represented by the extracted function name is compared with the argument of the function pointer check function. Then, a function is created that returns 1 if they match and returns 0 if they do not match any function. In the output program 921 (see FIG. 5), the processing in the 13th to 18th lines corresponds to the function created in this step.

このように、本実施形態に示した言語処理方法は、ソースプログラムを入力して、コンピュータで実行可能なプログラムまたはオブジェクトコードを生成するコンピュータにより実行される方法であり、ソースプログラムを格納する記憶部と処理部を備えたコンピュータの処理部が、記憶部からソースプログラムを読み出し、そのソースプログラムの構文を解析して、ソースプログラムを中間語に変換するステップと、中間語中の関数ポインタ変数により呼出される可能性がある関数の関数リストを作成するステップと、関数ポインタ変数が関数リストに登録されている関数を指すか否かを判定し、関数ポインタ変数が関数リストに登録されていない関数を指すと判定された場合には、関数呼出しを中止する関数ポインタチェックコードを、中間語中の関数ポインタ変数を用いた関数呼出しの直前に挿入するステップと、関数ポインタチェックコードが挿入された中間語を、コンピュータで実行可能なプログラムまたはオブジェクトコードに変換するステップとを実行する方法である。   As described above, the language processing method shown in the present embodiment is a method executed by a computer that inputs a source program and generates a computer-executable program or object code, and stores a source program. The processing unit of the computer having the processing unit reads the source program from the storage unit, analyzes the syntax of the source program, converts the source program into an intermediate language, and calls with the function pointer variable in the intermediate language Creating a function list of functions that may be generated, determining whether the function pointer variable points to a function registered in the function list, and determining whether the function pointer variable is not registered in the function list. If it is determined that it points to the function pointer check code to cancel the function call, A method of executing a step of inserting immediately before a function call using a function pointer variable in a language, and a step of converting an intermediate language in which a function pointer check code is inserted into a computer executable program or object code It is.

本実施形態で示したように、例えば、関数リスト作成部131(図1参照)は、プログラム中の関数プロトタイプ宣言に存在する関数名を関数リスト93(図1参照)に登録することが可能である。続いて、関数ポインタチェック挿入部133(図1参照)は、プログラム中の関数内のローカル変数宣言を検出し、その関数ポインタ変数を用いたすべての関数呼出しに対して、その直前に関数ポインタチェック関数呼出しを挿入することが可能である。その後、関数ポインタチェック挿入部133(図1参照)は、関数リスト93(図1参照)を用いて、関数ポインタチェック関数の本体を作成し、作成した本体をプログラム中に挿入することが可能である。   As shown in the present embodiment, for example, the function list creation unit 131 (see FIG. 1) can register the function name existing in the function prototype declaration in the program in the function list 93 (see FIG. 1). is there. Subsequently, the function pointer check insertion unit 133 (see FIG. 1) detects a local variable declaration in the function in the program, and performs a function pointer check immediately before every function call using the function pointer variable. It is possible to insert function calls. Thereafter, the function pointer check insertion unit 133 (see FIG. 1) can create a function pointer check function body using the function list 93 (see FIG. 1) and insert the created body into the program. is there.

以上のように、本実施形態によれば、関数ポインタ変数に対するバッファオーバフロー攻撃を防御可能なプログラムまたはオブジェクトコードを生成することが可能である。また、セキュリティチェックによる実行時オーバヘッドを軽減させることが可能である。   As described above, according to this embodiment, it is possible to generate a program or object code that can prevent a buffer overflow attack on a function pointer variable. It is also possible to reduce the runtime overhead due to the security check.

(第2の実施形態)
次に、本発明の第2の実施形態について説明する。この第2の実施形態は、関数リスト作成部131(図1参照)に関するものであり、第1の実施形態と共通する部分については、重複説明を省略する。
第2の実施形態では、図8に示す入力プログラム951、図9に示す関数リスト934を例にあげて説明する。この関数リスト934は、第1の実施形態における関数リスト93(図1参照)と異なり、代入文と呼出し点を組にして登録できるよう修正してある。具体的には、関数exitへのポインタが変数testに設定されている。変数testは、入力プログラム951(図8参照)の12行目の関数呼出し文において関数呼出しに使われていることを示す情報である。
(Second Embodiment)
Next, a second embodiment of the present invention will be described. The second embodiment relates to the function list creation unit 131 (see FIG. 1), and redundant description of portions common to the first embodiment is omitted.
In the second embodiment, the input program 951 shown in FIG. 8 and the function list 934 shown in FIG. 9 will be described as examples. Unlike the function list 93 (see FIG. 1) in the first embodiment, this function list 934 is modified so that an assignment statement and a call point can be registered as a pair. Specifically, a pointer to the function exit is set in the variable test. The variable test is information indicating that it is used for a function call in the function call statement on the 12th line of the input program 951 (see FIG. 8).

図10は、第2の実施形態における出力プログラム92(図1参照)の一例を示す図である。ここでは、図8の入力プログラム951を図1における入力プログラム90とした場合に得られる出力プログラム92を示している。以下では、図8の入力プログラム951との違いのみを説明する。出力プログラム952の12行目は、図1の関数ポインタチェック挿入部133が挿入した行であり、13行目の関数ポインタ変数testによる関数呼出し文の直前に、関数ポインタ変数testの値が不正な値でないかを調べる関数_is_legal_func_ptrを呼出し、その返り値を引数として標準ライブラリ関数assertを呼び出す処理である。15〜18行目は関数ポインタチェック挿入部133(図1参照)が挿入した部分であり、引数で与えられた関数ポインタ変数の値が不正な値でないかを調べる関数_is_legal_func_ptrの本体である。16行目は、引数で与えられた関数ポインタの値が、13行目の関数ポインタ変数testの呼出しに到達する定義値であるexitへの関数ポインタと等しいか否かを調べ、等しい場合は1を、そうでない場合は0を返す処理である。本実施形態では、関数_is_legal_func_ptrは、生成した関数リストを用いて、チェックする関数呼出し点毎に、関数名を変えて、当該関数呼出し点専用の処理として生成される。これにより、関数_is_legal_func_ptr内の不要なチェックコードが削減され、チェック処理を高速化することが可能である。   FIG. 10 is a diagram illustrating an example of the output program 92 (see FIG. 1) in the second embodiment. Here, an output program 92 obtained when the input program 951 in FIG. 8 is the input program 90 in FIG. 1 is shown. Only the differences from the input program 951 in FIG. 8 will be described below. The 12th line of the output program 952 is the line inserted by the function pointer check insertion unit 133 in FIG. 1, and the value of the function pointer variable test is invalid immediately before the function call statement by the function pointer variable test on the 13th line. This is a process of calling the function _is_legal_func_ptr for checking whether it is a value and calling the standard library function assert with the return value as an argument. The 15th to 18th lines are parts inserted by the function pointer check insertion unit 133 (see FIG. 1), and are the main body of the function _is_legal_func_ptr for checking whether the value of the function pointer variable given by the argument is an invalid value. The 16th line checks whether or not the value of the function pointer given by the argument is equal to the function pointer to exit, which is a definition value that reaches the call of the function pointer variable test on the 13th line. If not, 0 is returned. In this embodiment, the function_is_legal_func_ptr is generated as a process dedicated to the function call point by changing the function name for each function call point to be checked using the generated function list. Thereby, unnecessary check codes in the function _is_legal_func_ptr are reduced, and the check process can be speeded up.

図11は、第2の実施形態における関数リスト作成部131(図1参照)の処理手順を表すフローチャートである。以下では、関数リスト作成部131(図1参照)の処理を中間語91(図1参照)に適用する場合について説明するが、適宜、図8の入力プログラム951を、本処理における入力プログラムとして用いる。   FIG. 11 is a flowchart showing the processing procedure of the function list creation unit 131 (see FIG. 1) in the second embodiment. In the following, a case where the process of the function list creation unit 131 (see FIG. 1) is applied to the intermediate language 91 (see FIG. 1) will be described. However, the input program 951 in FIG. .

まず、プログラム中にある本体を持つ関数のうち、未処理のものを1つ選ぶ(S301)。ここでは、未処理の関数の例として、入力プログラム951(図8参照)の6〜13行目にある関数funcを選択する。次にS302に進む。   First, one unprocessed function is selected from functions having a main body in the program (S301). Here, as an example of an unprocessed function, the function func on the 6th to 13th lines of the input program 951 (see FIG. 8) is selected. Next, the process proceeds to S302.

S302では、選択した関数のローカル変数宣言に、未処理の関数ポインタ変数宣言が存在するかを調べ(S302)、存在すれば(S302でYes)、S303へ進み、存在しなければ(S302でNo)、S305へ進む。S305の処理については後記する。ここでは、未処理の関数ポインタ変数宣言として、入力プログラム951(図8参照)の7行目の変数testの宣言が選択され、S303に進む。   In S302, it is checked whether an unprocessed function pointer variable declaration exists in the local variable declaration of the selected function (S302). If it exists (Yes in S302), the process proceeds to S303, and if it does not exist (No in S302). ), And proceeds to S305. The process of S305 will be described later. Here, the declaration of the variable test on the seventh line of the input program 951 (see FIG. 8) is selected as an unprocessed function pointer variable declaration, and the process proceeds to S303.

S303では、S302で選択した宣言をもつ関数ポインタ変数に未処理の呼出しがあるかを判定する(S303)。未処理の関数呼出しがあれば(S303でYes)、S304へ進み、未処理の関数呼出しがなければ(S303でNo)、S302に戻る。ここでは、未処理の関数呼出しとして、入力プログラム951の12行目の変数testを用いた関数呼出し文が見つかり、S304に進む。   In S303, it is determined whether there is an unprocessed call in the function pointer variable having the declaration selected in S302 (S303). If there is an unprocessed function call (Yes in S303), the process proceeds to S304, and if there is no unprocessed function call (No in S303), the process returns to S302. Here, as an unprocessed function call, a function call statement using the variable test on the 12th line of the input program 951 is found, and the process proceeds to S304.

次に、S304では、関数リスト追加処理を行う(S304)。S304では、S302で発見された変数に関して依存解析を行い、S303で見つかった関数呼出し文における当該変数の値を設定する代入文を探し、もしその代入文における定義が当該関数呼出し文に到達するのであれば、そのような代入文の場所すべてを、呼出し点と組にして関数リストに登録し、S303に戻る。ここでは、S302で発見された変数testに関して依存解析を行い、当該変数の値を設定する代入文として、入力プログラム951の9行目、10行目の代入文を検出する。このうち、12行目に到達する定義は、10行目の代入文であるので、この情報を図9に示した関数リスト934に登録する。ここでは、関数exitへのポインタが変数testに設定され、変数testは入力プログラム951の12行目の関数呼出し文において関数呼出しに使われているという情報を設定している。なお、前記した依存解析は、例えば中田育男「コンパイラの構造と最適化」(朝倉書店、1999年)11〜12章に記載されている公知の方法と変わらない。例えば、メモリへの値の書き込みを定義、メモリからの値の読み込みを使用と呼ぶことにすると、プログラム中のある変数xに関する依存解析とは、変数xがどこで定義され、どこで使用されるかを調べることである。依存関係を調べることにより、例えば、プログラム中のある点で使用される変数の値が、どの点で定義された値であるかを知ることができる。なお、関数リスト934の表現については、線形リストに限らず、配列、ビットベクトルなどによる表現でも良い。   Next, in S304, a function list addition process is performed (S304). In S304, dependency analysis is performed on the variable found in S302, and an assignment statement that sets the value of the variable in the function call statement found in S303 is searched. If the definition in the assignment statement reaches the function call statement. If so, all such assignment statement locations are registered in the function list in pairs with the call point, and the process returns to S303. Here, dependency analysis is performed on the variable test found in S302, and the substitution statements on the ninth and tenth lines of the input program 951 are detected as substitution statements for setting the values of the variables. Among these, since the definition reaching the 12th line is the assignment statement on the 10th line, this information is registered in the function list 934 shown in FIG. Here, the pointer to the function exit is set in the variable test, and the variable test sets information that is used for the function call in the function call statement on the 12th line of the input program 951. The dependency analysis described above is not different from a known method described in, for example, Chapters 11-12 of Ikuo Nakata “Compiler Structure and Optimization” (Asakura Shoten, 1999). For example, if we call the definition of writing a value to memory and the use of reading a value from memory, the dependency analysis for a variable x in the program is where the variable x is defined and where it is used. It is to investigate. By examining the dependency relationship, for example, it is possible to know at which point the value of a variable used at a certain point in the program is a defined value. Note that the expression of the function list 934 is not limited to a linear list, and may be expressed by an array, a bit vector, or the like.

S305では、プログラム中の全関数を処理したか否かを判定する(S305)。未処理の関数があれば(S305でNo)、S301に戻り、処理を継続する。また、未処理の関数なければ(S305でYes)、関数リスト作成部131(図1参照)の処理を終了する。ここでは、関数名funcを取り出した後、処理を終了する。   In S305, it is determined whether all functions in the program have been processed (S305). If there is an unprocessed function (No in S305), the process returns to S301 to continue the process. If there is no unprocessed function (Yes in S305), the process of the function list creation unit 131 (see FIG. 1) is terminated. Here, after the function name func is extracted, the process is terminated.

このように、本実施形態に示した言語処理方法は、第1の実施形態に示した言語処理方法における関数のリストを作成するステップにおいて、処理部が、中間語を用いて、依存解析処理によって関数ポインタ変数を用いた関数呼出しへ到達する代入文を見つけ、代入文の右辺変数を関数リストに加える方法である。   As described above, in the language processing method shown in the present embodiment, in the step of creating a list of functions in the language processing method shown in the first embodiment, the processing unit uses the intermediate language and performs dependency analysis processing. In this method, an assignment statement that reaches a function call using a function pointer variable is found, and the variable on the right side of the assignment statement is added to the function list.

本実施形態で示したように、例えば、関数リスト作成部131(図1参照)は、プログラム中にある本体を持つ関数のローカル変数宣言に関数ポインタ変数宣言が存在するかを調べ、発見された変数に関して依存解析を行い、当該変数を用いた関数呼出し文における当該変数の値を設定する代入文を探し、もしその代入文における定義が当該関数呼出し文に到達するのであれば、そのような代入文の場所すべてを、呼出し点と組にして関数リストに登録することが可能である。   As shown in the present embodiment, for example, the function list creation unit 131 (see FIG. 1) has been found by examining whether a function pointer variable declaration exists in a local variable declaration of a function having a body in a program. Dependency analysis is performed on the variable, looking for an assignment statement that sets the value of the variable in the function call statement using the variable, and if the definition in the assignment statement reaches the function call statement, such assignment All sentence locations can be paired with the call point and registered in the function list.

以上のように、本実施形態によれば、依存解析処理によって関数呼出しに使用される可能性のあるポインタ値をさらに絞り込むことが可能である。したがって、関数リスト93(図1参照)にリストアップする関数を少なくすることが可能となり、関数ポインタチェック関数の本体の処理も少なくすることが可能となるため、関数ポインタチェック処理の高速化を図ることが可能となる。   As described above, according to the present embodiment, it is possible to further narrow down pointer values that may be used for function calls by dependency analysis processing. Accordingly, it is possible to reduce the number of functions listed in the function list 93 (see FIG. 1), and it is also possible to reduce the processing of the main body of the function pointer check function, thereby speeding up the function pointer check process. It becomes possible.

(第3の実施形態)
次に、本発明の第3の実施形態について説明する。例えば、C言語で書かれたプログラムの場合、ファイル中に関数本体がない関数を呼び出すためには、当該ファイル中の関数呼出しの前に関数プロトタイプ宣言を書くことが推奨されている。しかし伝統的には、関数プロトタイプ宣言がなくてもプログラムは動作するため、関数プロトタイプ宣言を書いていない古いプログラムも少なくない。本実施形態では、このような関数プロトタイプ宣言を書いていないプログラムでも正しくチェックコードを生成する方法を説明する。なお、第1の実施形態と共通する部分については、同じ符号を付し、説明を省略する。
(Third embodiment)
Next, a third embodiment of the present invention will be described. For example, in the case of a program written in C language, in order to call a function that does not have a function body in a file, it is recommended to write a function prototype declaration before the function call in the file. Traditionally, however, programs run without function prototype declarations, so many older programs do not write function prototype declarations. In this embodiment, a method for correctly generating a check code even in a program in which such a function prototype declaration is not written will be described. In addition, about the part which is common in 1st Embodiment, the same code | symbol is attached | subjected and description is abbreviate | omitted.

図12は、第3の実施形態におけるコンパイラとリンカの構成を示す図である。図12に示すように、本構成は、高信頼プログラム生成コンパイラ30と、高信頼プログラム生成リンカ20とを含んでいる。高信頼プログラム生成コンパイラ30は、入力プログラム90および中間語91を入力し、チェックコード等を挿入した中間語91、関数リスト93および出力プログラム92を出力する。ここで、出力プログラム92は、機械語であっても良いし、ソースプログラムであっても良い。高信頼プログラム生成リンカ20は、出力プログラム92、中間語94およびライブラリ関数96を入力し、チェックコード等を挿入した中間語94、関数リスト95および実行プログラム97を出力する。   FIG. 12 is a diagram showing the configuration of the compiler and linker in the third embodiment. As shown in FIG. 12, this configuration includes a high-reliability program generation compiler 30 and a high-reliability program generation linker 20. The high-reliability program generation compiler 30 inputs the input program 90 and the intermediate language 91, and outputs the intermediate language 91, the function list 93, and the output program 92 into which the check code and the like are inserted. Here, the output program 92 may be a machine language or a source program. The high-reliability program generation linker 20 inputs the output program 92, the intermediate language 94, and the library function 96, and outputs the intermediate language 94, the function list 95, and the execution program 97 into which check codes and the like are inserted.

図13は、高信頼プログラム生成コンパイラ30(図12参照)の構成を示す図である。高信頼プログラム生成コンパイラ30は、構文解析部11と、関数検査・コード生成部17とを含んで構成されている。構文解析部11は、図1の高信頼プログラム生成コンパイラ10と特に変わらないのでこれ以上説明しない。関数検査・コード生成部17は、中間語91と関数リスト93を入力し、チェックコード等を挿入した中間語91、関数リスト93および出力プログラム92を出力する。   FIG. 13 is a diagram showing a configuration of the highly reliable program generating compiler 30 (see FIG. 12). The high-reliability program generation compiler 30 includes a syntax analysis unit 11 and a function check / code generation unit 17. The syntax analysis unit 11 is not particularly different from the high-reliability program generation compiler 10 of FIG. 1 and will not be described further. The function check / code generation unit 17 receives the intermediate language 91 and the function list 93, and outputs the intermediate language 91, the function list 93, and the output program 92 into which the check code and the like are inserted.

図14は、高信頼プログラム生成リンカ20(図12参照)の構成を示す図である。高信頼プログラム生成リンカ20は、構文解析部11と、高信頼プログラムリンク時生成部22と、リンク部23とを含んで構成される。構文解析部11は、通常のコンパイラが有する構文解析の機能と特に変わらない。高信頼プログラムリンク時生成部22は、中間語94と関数リスト95とを入力して、チェックコード等を挿入された中間語94を出力する。また、高信頼プログラムリンク時生成部22は、関数リスト95を出力する。リンク部23は、チェックコード等を挿入された中間語94とライブラリ関数96とを入力して、実行プログラム97を出力する。リンク部23は、通常のリンカと特に変わらない。   FIG. 14 is a diagram showing the configuration of the highly reliable program generation linker 20 (see FIG. 12). The high-reliability program generation linker 20 includes a syntax analysis unit 11, a high-reliability program link time generation unit 22, and a link unit 23. The parsing unit 11 is not particularly different from the parsing function of a normal compiler. The highly reliable program link time generation unit 22 inputs the intermediate language 94 and the function list 95, and outputs the intermediate language 94 into which a check code or the like is inserted. Further, the high reliability program link time generation unit 22 outputs a function list 95. The link unit 23 inputs the intermediate language 94 into which the check code or the like is inserted and the library function 96, and outputs an execution program 97. The link part 23 is not particularly different from a normal linker.

図15は、関数検査・コード生成部17(図13参照)の処理手順を表すフローチャートである。   FIG. 15 is a flowchart showing the processing procedure of the function checking / code generating unit 17 (see FIG. 13).

まず、プログラム中にある関数本体から未処理のものを1つ選ぶ(S401)。プログラム中にinclude文がある場合は、プリプロセッサによってinclude文がすべて展開された後で本処理を行う。ここで、プログラムとは、中間語91(図13参照)を意味する。次に、S401で選択した関数本体に対応する関数プロトタイプ宣言を、プログラム中から探す(S402)。次に、S402を行った結果、関数プロトタイプ宣言が見つかった場合(S403でYes)は、S404に進み、見つからなかった場合(S403でNo)は、S406に進む。   First, one unprocessed function is selected from the function bodies in the program (S401). If there is an include statement in the program, this process is performed after all the include statements are expanded by the preprocessor. Here, the program means the intermediate language 91 (see FIG. 13). Next, a function prototype declaration corresponding to the function body selected in S401 is searched for in the program (S402). Next, as a result of performing S402, if a function prototype declaration is found (Yes in S403), the process proceeds to S404, and if not found (No in S403), the process proceeds to S406.

S404では、プログラム中の関数すべてを処理したかどうかを判定し(S404)、全関数本体を処理した場合(S404でYes)は、高信頼プログラム生成処理を行い(S405)、S406に進む。また、未処理の関数本体がある場合(S404でNo)は、S401に戻って処理を継続する。ここで、高信頼プログラム生成処理S405は、第1の実施形態における高信頼プログラム生成部13(図1参照)の処理、すなわち図6および図7の処理と変わらないので、これ以上説明しない。   In S404, it is determined whether all the functions in the program have been processed (S404). If all the function bodies have been processed (Yes in S404), a highly reliable program generation process is performed (S405), and the process proceeds to S406. If there is an unprocessed function body (No in S404), the process returns to S401 to continue the process. Here, the high-reliability program generation processing S405 is not different from the processing of the high-reliability program generation unit 13 (see FIG. 1) in the first embodiment, that is, the processing of FIGS. 6 and 7, and will not be described further.

S406では、コード生成処理を行い(S406)、処理を終了する。ここで、コード生成処理S406が終了すると、出力プログラム92(図13参照)が出力され、高信頼プログラム生成リンカ20(図12参照)に渡される。また、コード生成処理S406は、第1の実施形態におけるコード生成部15(図1参照)の処理と変わらないので、これ以上説明しない。   In S406, a code generation process is performed (S406), and the process ends. Here, when the code generation process S406 ends, an output program 92 (see FIG. 13) is output and passed to the highly reliable program generation linker 20 (see FIG. 12). Further, the code generation process S406 is not different from the process of the code generation unit 15 (see FIG. 1) in the first embodiment, and thus will not be further described.

なお、プログラム中の関数本体に対応するプロトタイプ宣言がすべての関数に対して見つかった場合にのみ、高信頼プログラム生成処理S405を行うこととしたが、高信頼プログラム生成処理S405を行うタイミングはこれに限定されない。例えば、関数本体に対応する関数プロトタイプ宣言が存在する(S403でYes)と判定された直後に、高信頼プログラム生成処理S405を行うようにすることも可能である。そうすることで、対応する関数プロトタイプ宣言が存在する関数については、高信頼プログラム生成コンパイラ30(図12参照)が関数ポインタチェックコードの挿入を行い、対応する関数プロトタイプ宣言が存在しない関数については、高信頼プログラム生成リンカ20(図12参照)が関数ポインタチェックコードの挿入を行うことが可能となる。   Note that the high-reliability program generation processing S405 is performed only when the prototype declaration corresponding to the function body in the program is found for all functions. It is not limited. For example, the highly reliable program generation process S405 may be performed immediately after it is determined that a function prototype declaration corresponding to the function main body exists (Yes in S403). By doing so, for a function having a corresponding function prototype declaration, the high-reliability program generation compiler 30 (see FIG. 12) inserts a function pointer check code, and for a function having no corresponding function prototype declaration, The highly reliable program generation linker 20 (see FIG. 12) can insert the function pointer check code.

図16は、高信頼プログラムリンク時生成部22(図14参照)の処理手順を表すフローチャートである。   FIG. 16 is a flowchart showing the processing procedure of the highly reliable program link time generation unit 22 (see FIG. 14).

まず、プログラム中にチェックコードが挿入されているか調べる(S501)。ここで、プログラムとは、中間語94(図14参照)を意味する。チェックコードが見つかった場合(S501でYes)は、S504に進む。また、見つからなかった場合(S502)は、リンク時生成処理(S502)を実行し、関数ポインタチェック挿入処理(S503)を実行し、S504に進む。   First, it is checked whether a check code is inserted in the program (S501). Here, the program means the intermediate language 94 (see FIG. 14). If a check code is found (Yes in S501), the process proceeds to S504. If not found (S502), a link time generation process (S502) is executed, a function pointer check insertion process (S503) is executed, and the process proceeds to S504.

S504では、コード生成処理(S504)を行い、処理を終了する。ここで、コード生成処理S504が終了すると、実行プログラム97(図14参照)が出力される。リンク時生成処理S502の詳細については、後記する。また、関数ポインタチェック挿入処理S503およびコード生成処理S504については、それぞれ第1の実施形態における関数ポインタチェック挿入部133(図1参照)およびコード生成部15(図1参照)と変わらないので、これ以上説明しない。   In S504, a code generation process (S504) is performed, and the process ends. Here, when the code generation process S504 ends, an execution program 97 (see FIG. 14) is output. Details of the link time generation process S502 will be described later. Since the function pointer check insertion processing S503 and the code generation processing S504 are the same as the function pointer check insertion portion 133 (see FIG. 1) and the code generation portion 15 (see FIG. 1) in the first embodiment, respectively. No further explanation.

図17は、リンク時生成処理S502(図16参照)の処理手順の詳細を表すフローチャートである。   FIG. 17 is a flowchart showing details of the processing procedure of the link time generation processing S502 (see FIG. 16).

まず、リンク対象プログラムの関数本体のうち、未処理のものを1つ選ぶ(S5021)。ここで、リンク対象プログラムとは、中間語94(図14参照)およびライブラリ関数96(図14参照)を意味する。次に、S5021で選んだ関数名を関数リスト95(図14参照)に登録する。次に、リンク対象プログラム中の全関数本体を処理したか否かを判定する(S5023)。未処理の関数本体がある場合(S5023でNo)は、S5021に戻って処理を継続する。未処理の関数本体がない場合(S5023でYes)は、処理を終了する。   First, one unprocessed function body is selected from the function bodies of the link target program (S5021). Here, the link target program means the intermediate language 94 (see FIG. 14) and the library function 96 (see FIG. 14). Next, the function name selected in S5021 is registered in the function list 95 (see FIG. 14). Next, it is determined whether all the function bodies in the link target program have been processed (S5023). If there is an unprocessed function body (No in S5023), the process returns to S5021 to continue the process. If there is no unprocessed function body (Yes in S5023), the process ends.

以上のように、本実施形態によれば、リンク時においても関数リストの作成と関数ポインタチェックコードの挿入とを行うことが可能となる。これによって、分割コンパイルを行った場合等、コンパイル時にすべてのプログラムが揃わない場合であっても、関数ポインタ変数に対するバッファオーバフロー攻撃を防御可能なプログラムまたはオブジェクトコードを生成することが可能となる。また、セキュリティチェックによる実行時オーバヘッドを軽減させることが可能となる。   As described above, according to the present embodiment, it is possible to create a function list and insert a function pointer check code even at the time of linking. This makes it possible to generate a program or object code that can prevent a buffer overflow attack on a function pointer variable even when all programs are not prepared at the time of compilation, such as when divided compilation is performed. It is also possible to reduce the runtime overhead due to the security check.

(第4の実施形態)
次に、本発明の第4の実施形態について説明する。悪意あるユーザは、特定の標準ライブラリ関数がもつ脆弱性を利用して攻撃することがしばしばある。また一般に、実行時のチェック処理はプログラムの実行速度を低下させる。そこで、例えば、脆弱性を持つことが分かっている標準ライブラリ関数の呼出しがないプログラムではチェック処理を行わないといった制御処理を行うことで、チェック処理の回数を減らす例を説明する。なお、第1または第2の実施形態と共通する部分については、同じ符号を付し、説明を省略する。
(Fourth embodiment)
Next, a fourth embodiment of the present invention will be described. Malicious users often attack using the vulnerabilities of certain standard library functions. In general, the check process at the time of execution reduces the execution speed of the program. Thus, for example, an example will be described in which the number of check processes is reduced by performing a control process such that a check process is not performed in a program that does not call a standard library function known to have a vulnerability. In addition, about the part which is common in 1st or 2nd embodiment, the same code | symbol is attached | subjected and description is abbreviate | omitted.

図18は、第4の実施形態における高信頼プログラム生成部13(図1参照)の処理手順を表すフローチャートである。   FIG. 18 is a flowchart showing the processing procedure of the highly reliable program generating unit 13 (see FIG. 1) in the fourth embodiment.

まず、プログラム中にある関数本体から未処理のものを1つ選ぶ(S601)。ここで、プログラムとは、中間語91(図1参照)を意味する。次に、S601で選択した関数本体中に、特定の関数の呼出し、またはアドレス参照による関数呼出しを含むかどうかを調べる(S602)。どちらも含んでいない場合(S602でNo)は、S603に進む。また、少なくとも一方を含んでいる場合(S602でYes)は、S605に進む。ここで、特定の関数とは、例えば、C言語の標準ライブラリ関数strcpyに代表されるセキュリティ上の脆弱性を含む関数とする。しかし、他の特徴を持つ関数を特定の関数とすることを妨げるものではない。また、アドレス参照がどの関数を指しているかは、一般にはコンパイル時に解析できないので、アドレス参照による関数呼出しがある場合にはチェックコードを生成する。   First, one unprocessed function is selected from the function bodies in the program (S601). Here, the program means the intermediate language 91 (see FIG. 1). Next, it is checked whether or not the function body selected in S601 includes a specific function call or a function call by address reference (S602). If neither is included (No in S602), the process proceeds to S603. When at least one is included (Yes in S602), the process proceeds to S605. Here, the specific function is, for example, a function including a security vulnerability represented by the C language standard library function strcpy. However, this does not prevent the function having other characteristics from being a specific function. In addition, since it is generally not possible to analyze which function the address reference points to at compile time, a check code is generated when there is a function call based on the address reference.

S603では、S601で選択した関数を処理済として扱う(S603)。次に、全関数が処理済であるか否かを調べ(S604)、全関数が処理済ならば(S604でYes)、処理を終了し、未処理の関数があれば(S604でNo)、S601に戻って処理を継続する。   In S603, the function selected in S601 is handled as processed (S603). Next, it is checked whether or not all functions have been processed (S604). If all functions have been processed (Yes in S604), the process ends, and if there is an unprocessed function (No in S604), Returning to S601, the processing is continued.

S605では、関数リスト作成処理を行い(S605)、関数ポインタチェック挿入処理を行った後(S606)、処理を終了する。ここで、関数リスト作成処理S605および関数ポインタチェック挿入処理S606は、それぞれ第1の実施形態における関数リスト作成部131(図1参照)および関数ポインタチェック挿入部133(図1参照)の処理、すなわち図6および図7に示した処理と変わらないので、これ以上説明しない。   In S605, a function list creation process is performed (S605), a function pointer check insertion process is performed (S606), and the process ends. Here, the function list creation process S605 and the function pointer check insertion process S606 are the processes of the function list creation unit 131 (see FIG. 1) and the function pointer check insertion unit 133 (see FIG. 1) in the first embodiment, respectively. Since it is not different from the processing shown in FIGS. 6 and 7, it will not be described further.

なお、本実施形態においては、関数本体中に特定の関数呼出し、またはアドレス参照による関数呼出しが存在する関数が見つかった時点で、それ以降の関数すべてに対して、関数リスト作成処理S605および関数ポインタチェック挿入処理S606を行うこととしたが、関数リスト作成処理S605および関数ポインタチェック挿入処理S606を行うタイミングはこれに限定されない。例えば、全関数を処理したか否かを判定する処理S604を、S603とS606の直後に行うようにすることも可能である。そうすることで、関数本体中に特定の関数呼出し、またはアドレス参照による関数呼出しが存在する関数に対してのみ、関数リスト作成処理S605および関数ポインタチェック挿入処理S606を行うことが可能となる。   In this embodiment, when a function having a specific function call or a function call by address reference is found in the function body, the function list creation process S605 and the function pointer are performed for all subsequent functions. Although the check insertion process S606 is performed, the timing of performing the function list creation process S605 and the function pointer check insertion process S606 is not limited to this. For example, the process S604 for determining whether or not all functions have been processed can be performed immediately after S603 and S606. By doing so, it is possible to perform the function list creation process S605 and the function pointer check insertion process S606 only for a function in which a specific function call or a function call by address reference exists in the function body.

以上のように、本実施形態によれば、例えば、脆弱性を持つことが分かっている標準ライブラリ関数の呼出しがないプログラムではチェック処理を行わないといった制御処理を行うことで、チェック処理の回数を減らすことが可能となる。これによって、チェック処理による実行速度の低下を緩和することが可能となる。   As described above, according to the present embodiment, for example, the number of check processes can be reduced by performing a control process such that a check process is not performed in a program that does not call a standard library function known to have a vulnerability. It becomes possible to reduce. As a result, it is possible to alleviate a decrease in execution speed due to the check process.

(第5の実施形態)
次に、本発明の第5の実施形態について説明する。バッファオーバフロー攻撃は、関数スタック上のローカル変数に対して行われることが多い。しかし、グローバル変数に対するバッファオーバフロー攻撃も理論上は可能である。本実施形態では、グローバルな関数ポインタ変数に対するバッファオーバフロー攻撃を防御する方法を説明する。なお、本実施形態における関数リスト作成部131(図1参照)は、第1または第2の実施形態における関数リスト作成部131(図1参照)と同様であるので、説明を省略する。
(Fifth embodiment)
Next, a fifth embodiment of the present invention will be described. Buffer overflow attacks are often performed on local variables on the function stack. However, a buffer overflow attack against global variables is theoretically possible. In the present embodiment, a method for preventing a buffer overflow attack on a global function pointer variable will be described. Note that the function list creation unit 131 (see FIG. 1) in the present embodiment is the same as the function list creation unit 131 (see FIG. 1) in the first or second embodiment, and a description thereof will be omitted.

図19は、第5の実施形態における関数ポインタチェック挿入部133(図1参照)の処理手順を表すフローチャートである。   FIG. 19 is a flowchart showing the processing procedure of the function pointer check insertion unit 133 (see FIG. 1) in the fifth embodiment.

まず、プログラム中にあるグローバルな関数ポインタ変数のうち、未処理のものを1つ選ぶ(S701)。ここで、プログラムとは、中間語91(図1参照)を意味する。次に、S701で選択した関数ポインタ変数を用いたすべての関数呼出しに対して、その直前に関数ポインタチェック関数呼出しを挿入する(S702)。次に、プログラム中のすべてのグローバルな関数ポインタ変数を処理したかを調べ(S703)、すべて処理した場合(S703でYes)は、処理を終了し、そうでない場合(S703でNo)は、S701に戻って処理を継続する。なお、S703でYesの場合には、図7に示した関数リストを用いて関数ポインタチェック関数本体を作成し、プログラム中に挿入する処理S205を行う必要があるが、ローカルな関数ポインタ変数の関数ポインタチェック挿入処理において、関数ポインタチェック関数本体の作成がなされていると仮定して、重複を防ぐために、ここでは関数ポインタチェック関数本体の作成処理を省略してある。   First, one unprocessed function pointer variable in the program is selected (S701). Here, the program means the intermediate language 91 (see FIG. 1). Next, a function pointer check function call is inserted immediately before all the function calls using the function pointer variable selected in S701 (S702). Next, it is checked whether all global function pointer variables in the program have been processed (S703). If all have been processed (Yes in S703), the process ends. If not (No in S703), S701 is executed. Return to and continue processing. In the case of Yes in S703, it is necessary to create a function pointer check function body using the function list shown in FIG. 7 and perform processing S205 to be inserted into the program. In the pointer check insertion process, assuming that the function pointer check function body is created, the function pointer check function body creation process is omitted here in order to prevent duplication.

以上のように、本実施形態によれば、グローバルな関数ポインタ変数に対するバッファオーバフロー攻撃があった場合でも、関数ポインタ変数に対するバッファオーバフロー攻撃を防御可能なプログラムまたはオブジェクトコードを生成することが可能となる。また、セキュリティチェックによる実行時オーバヘッドを軽減させることが可能となる。   As described above, according to the present embodiment, it is possible to generate a program or object code that can prevent a buffer overflow attack against a function pointer variable even when there is a buffer overflow attack against a global function pointer variable. . It is also possible to reduce the runtime overhead due to the security check.

以上、図1〜図19を用いて説明したように、前記実施形態の言語処理方法によって生成されたプログラムまたはオブジェクトコードは、関数ポインタ変数を用いた関数呼出しの直前で、当該関数ポインタ変数の値が、呼び出される可能性のある関数へのポインタの値と一致するか否かを調べる。そのため、バッファオーバフロー攻撃によって当該関数ポインタ変数の値が書き換えられた場合でも、書き換えられた関数の呼出しを検出し、その関数呼出しの実行を防ぐことが可能であり、コンピュータプログラムのセキュリティ向上に利用することが可能である。   As described above with reference to FIGS. 1 to 19, the program or object code generated by the language processing method of the above embodiment is the value of the function pointer variable immediately before the function call using the function pointer variable. Checks whether the value of the pointer to the function that can be called matches. Therefore, even when the value of the function pointer variable is rewritten due to a buffer overflow attack, it is possible to detect a call to the rewritten function and prevent execution of the function call, which is used for improving the security of the computer program. It is possible.

また、前記実施形態の言語処理方法によって生成されたプログラムまたはオブジェクトコードは、関数ポインタ変数を用いた関数呼出し時、すなわち当該変数のレジスタへの読み出し時のみでチェック処理を行うか、または、それに加えて当該関数呼出し点に到達する関数ポインタ変数への定義点で登録処理を行う。従って、関数ポインタ変数へのすべての書き込み時およびすべてのレジスタへの読み出し時にチェック処理を行う場合に比べて、実行時オーバヘッドを軽減することが可能である。   In addition, the program or object code generated by the language processing method of the above embodiment performs check processing only when calling a function using a function pointer variable, that is, when reading the variable into a register, or in addition to that. Registration processing is performed at the definition point to the function pointer variable that reaches the function call point. Therefore, it is possible to reduce the runtime overhead as compared with the case where the check process is performed at the time of all writing to the function pointer variable and at the time of reading to all the registers.

以上、本発明を前記実施形態に基づき詳細に説明したが、本発明は前記実施形態に限定されるものではなく、その要旨を逸脱しない範囲において変更可能である。   As mentioned above, although this invention was demonstrated in detail based on the said embodiment, this invention is not limited to the said embodiment, In the range which does not deviate from the summary, it can change.

第1の実施形態における高信頼プログラム生成コンパイラの機能例を示す図である。It is a figure which shows the function example of the reliable program generation compiler in 1st Embodiment. 第1の実施形態における高信頼プログラム生成コンパイラによる処理を実行する言語処理装置のハードウェア構成の一例を示す図である。It is a figure which shows an example of the hardware constitutions of the language processing apparatus which performs the process by the highly reliable program generation compiler in 1st Embodiment. 第1の実施形態における入力プログラムの一例を示す図である。It is a figure which shows an example of the input program in 1st Embodiment. 第1の実施形態における関数リストの一例を示す図である。It is a figure which shows an example of the function list | wrist in 1st Embodiment. 第1の実施形態における出力プログラムの一例を示す図である。It is a figure which shows an example of the output program in 1st Embodiment. 第1の実施形態における関数リスト作成部の処理手順を表すフローチャートである。It is a flowchart showing the process sequence of the function list preparation part in 1st Embodiment. 第1の実施形態における関数ポインタチェック挿入部の処理手順を表すフローチャートである。It is a flowchart showing the process sequence of the function pointer check insertion part in 1st Embodiment. 第2の実施形態における入力プログラムの一例を示す図である。It is a figure which shows an example of the input program in 2nd Embodiment. 第2の実施形態における関数リストの一例を示す図である。It is a figure which shows an example of the function list | wrist in 2nd Embodiment. 第2の実施形態における出力プログラムの一例を示す図である。It is a figure which shows an example of the output program in 2nd Embodiment. 第2の実施形態における関数リスト作成部の処理手順を表すフローチャートである。It is a flowchart showing the process sequence of the function list preparation part in 2nd Embodiment. 第3の実施形態におけるコンパイラとリンカの構成を示す図である。It is a figure which shows the structure of the compiler and linker in 3rd Embodiment. 図12の高信頼プログラム生成コンパイラの構成を示す図である。It is a figure which shows the structure of the highly reliable program production | generation compiler of FIG. 図12の高信頼プログラム生成リンカの構成を示す図である。It is a figure which shows the structure of the highly reliable program production | generation linker of FIG. 図13の関数検査・コード生成部の処理手順を表すフローチャートである。It is a flowchart showing the process sequence of the function test | inspection and code generation part of FIG. 図14の高信頼プログラムリンク時生成部の処理手順を表すフローチャートである。It is a flowchart showing the process sequence of the high reliable program link time production | generation part of FIG. 図16のリンク時生成処理の処理手順の詳細を表すフローチャートである。It is a flowchart showing the detail of the process sequence of the production | generation process at the time of a link of FIG. 第4の実施形態における高信頼プログラム生成部の処理手順を表すフローチャートである。It is a flowchart showing the process sequence of the reliable program production | generation part in 4th Embodiment. 第5の実施形態における関数ポインタチェック挿入部の処理手順を表すフローチャートである。It is a flowchart showing the process sequence of the function pointer check insertion part in 5th Embodiment.

符号の説明Explanation of symbols

10 高信頼プログラム生成コンパイラ
11 構文解析部
13 高信頼プログラム生成部
15 コード生成部
90 入力プログラム
91 中間語
92 出力プログラム
93 関数リスト
97 実行プログラム
131 関数リスト作成部
133 関数ポインタチェック挿入部
520 言語処理装置
5241 処理部
5242 記憶部
DESCRIPTION OF SYMBOLS 10 Highly reliable program generation compiler 11 Syntax analysis part 13 Highly reliable program generation part 15 Code generation part 90 Input program 91 Intermediate language 92 Output program 93 Function list 97 Execution program 131 Function list creation part 133 Function pointer check insertion part 520 Language processor 5241 processing unit 5242 storage unit

Claims (3)

ソースプログラムを入力して、コンピュータで実行可能なプログラムまたはオブジェクトコードを生成するコンピュータにより実行される言語処理方法であって、
前記コンピュータは、
前記ソースプログラムを格納する記憶部と、処理部とを備え、
前記処理部は、
前記記憶部から前記ソースプログラムを読み出し、そのソースプログラムの構文を解析して、当該ソースプログラムを中間語に変換するステップと、
当該中間語中の関数ポインタ変数により呼出される可能性がある関数の関数リストを作成するステップと、
当該関数ポインタ変数が当該関数リストに登録されている関数を指すか否かを判定し、当該関数ポインタ変数が当該関数リストに登録されていない関数を指すと判定された場合には、関数呼出しを中止する関数ポインタチェックコードを、前記中間語中の関数ポインタ変数を用いた関数呼出しの直前に挿入するステップと、
前記関数ポインタチェックコードが挿入された当該中間語を、前記コンピュータで実行可能なプログラムまたはオブジェクトコードに変換するステップと
を実行することを特徴とする言語処理方法。
A language processing method executed by a computer that inputs a source program and generates a computer-executable program or object code,
The computer
A storage unit for storing the source program; and a processing unit.
The processor is
Reading the source program from the storage unit, analyzing the syntax of the source program, and converting the source program into an intermediate language;
Creating a function list of functions that may be called by function pointer variables in the intermediate language;
It is determined whether or not the function pointer variable points to a function registered in the function list. If it is determined that the function pointer variable points to a function not registered in the function list, a function call is made. Inserting a function pointer check code to be canceled immediately before a function call using a function pointer variable in the intermediate language;
And a step of converting the intermediate language in which the function pointer check code is inserted into a program or object code executable by the computer.
前記処理部は、前記関数のリストを作成するステップにおいて、
前記中間語を用いて、依存解析処理によって前記関数ポインタ変数を用いた関数呼出しへ到達する代入文を見つけ、当該代入文の右辺変数を前記関数リストに加える
ことを特徴とする請求項1に記載の言語処理方法。
In the step of creating the function list, the processing unit includes:
2. The assignment statement reaching the function call using the function pointer variable is found by dependency analysis processing using the intermediate language, and the right-side variable of the assignment statement is added to the function list. Language processing method.
前記記憶部は、あらかじめ設定された特定の関数をさらに格納し、
前記処理部は、前記関数ポインタチェックコードを挿入するステップにおいて、
前記関数ポインタ変数が前記特定の関数を指すか否かを判定し、当該関数ポインタ変数が当該特定の関数を指すと判定した場合に、前記関数ポインタチェックコードを挿入する
ことを特徴とする請求項1または2に記載の言語処理方法。
The storage unit further stores a specific function set in advance,
In the step of inserting the function pointer check code, the processing unit includes:
The function pointer check code is inserted when it is determined whether or not the function pointer variable points to the specific function, and it is determined that the function pointer variable points to the specific function. 3. The language processing method according to 1 or 2.
JP2005224121A 2005-08-02 2005-08-02 Language processing method Withdrawn JP2007041777A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2005224121A JP2007041777A (en) 2005-08-02 2005-08-02 Language processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2005224121A JP2007041777A (en) 2005-08-02 2005-08-02 Language processing method

Publications (1)

Publication Number Publication Date
JP2007041777A true JP2007041777A (en) 2007-02-15

Family

ID=37799709

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2005224121A Withdrawn JP2007041777A (en) 2005-08-02 2005-08-02 Language processing method

Country Status (1)

Country Link
JP (1) JP2007041777A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2021535470A (en) * 2018-08-20 2021-12-16 アーム・リミテッド Devices and methods for controlling the use of bounded pointers
WO2022097799A1 (en) * 2020-11-09 2022-05-12 동국대학교 산학협력단 Security vulnerability analysis method for generating function abstract information and electronic device including same

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2021535470A (en) * 2018-08-20 2021-12-16 アーム・リミテッド Devices and methods for controlling the use of bounded pointers
JP7376571B2 (en) 2018-08-20 2023-11-08 アーム・リミテッド Apparatus and method for controlling use of bounded pointers
WO2022097799A1 (en) * 2020-11-09 2022-05-12 동국대학교 산학협력단 Security vulnerability analysis method for generating function abstract information and electronic device including same

Similar Documents

Publication Publication Date Title
US11507671B1 (en) Detection and healing of vulnerabilities in computer code
JP4976991B2 (en) Information processing apparatus, program verification method, and program
US11507669B1 (en) Characterizing, detecting and healing vulnerabilities in computer code
Almeida et al. Formal verification of side-channel countermeasures using self-composition
US7849509B2 (en) Detection of security vulnerabilities in computer programs
US20170372068A1 (en) Method to identify known compilers functions, libraries and objects inside files and data items containing an executable code
US8539593B2 (en) Extraction of code level security specification
US20080271001A1 (en) Method of generating program, information processing device and microcomputer
US10942718B2 (en) Systems and/or methods for type inference from machine code
JP5863973B2 (en) Program execution device and program analysis device
CN109271789B (en) Malicious process detection method and device, electronic equipment and storage medium
JP2007249884A (en) Program, apparatus and method for verifying software
JP5845888B2 (en) Software correction apparatus, software correction system, software correction method, and software correction program
JP4913353B2 (en) Software operation modeling device and software operation monitoring device
JP2011150716A (en) Program, apparatus and method for auditing vulnerability
JP2007041777A (en) Language processing method
Barthe et al. Verified translation validation of static analyses
CN104680043A (en) Method and device for protecting executable file
JP7008879B2 (en) Information processing equipment, information processing methods and information processing programs
KR102549124B1 (en) Methods and apparatus for for detecting and decoding obfuscated vbscript
KR102494837B1 (en) Methods and apparatus for for detecting and decoding obfuscated javascript
Fu et al. Detecting stack layout corruptions with robust stack unwinding
Cassel et al. Uncovering information flow policy violations in C programs
JP5343840B2 (en) Program analysis apparatus and analysis method
EP4332805A1 (en) Emulation-based malware detection

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20070815

A761 Written withdrawal of application

Free format text: JAPANESE INTERMEDIATE CODE: A761

Effective date: 20091109