JPS62232054A - Controlling system for stack frame descriptor - Google Patents

Controlling system for stack frame descriptor

Info

Publication number
JPS62232054A
JPS62232054A JP61075861A JP7586186A JPS62232054A JP S62232054 A JPS62232054 A JP S62232054A JP 61075861 A JP61075861 A JP 61075861A JP 7586186 A JP7586186 A JP 7586186A JP S62232054 A JPS62232054 A JP S62232054A
Authority
JP
Japan
Prior art keywords
stack frame
procedure
segment
descriptor
frame descriptor
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.)
Pending
Application number
JP61075861A
Other languages
Japanese (ja)
Inventor
Youji Kuise
杭瀬 洋司
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.)
NEC Corp
Original Assignee
NEC Corp
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 NEC Corp filed Critical NEC Corp
Priority to JP61075861A priority Critical patent/JPS62232054A/en
Publication of JPS62232054A publication Critical patent/JPS62232054A/en
Pending legal-status Critical Current

Links

Landscapes

  • Storage Device Security (AREA)

Abstract

PURPOSE:To effectively protect a stack frame descriptor from erroneous writing by controlling a stack frame descriptor in a segment different from a segment on a main memory in which a stack frame is formed and writing by procedure is prohibited based on memory protecting function by an operating system. CONSTITUTION:A stack frame 11 used by a main procedure is secured in a segment 10 of a main memory address space. A stack frame descriptor 21 of the stack frame 11 is different from the segment 10, and secured in other segment 20 in which writing by procedure is made impossible by memory protecting function of an operating system based on a technique such as a memory protecting key, etc. Further, a current stack frame descriptor pointer P for designating the stack frame descriptor 21 of main procedure in execution is secured in a general-purpose register, etc., in a CPU.

Description

【発明の詳細な説明】 発明の目的 産業上の利用分野 本発明は、電子計算機システムに適用されるスタックフ
レーム記述子の管理方式に関し、特にスタックフレーム
記述子を誤書込みによる破壊から保護しつつ管理する方
式に関するものである。
DETAILED DESCRIPTION OF THE INVENTION The present invention relates to a stack frame descriptor management method applied to an electronic computer system, and in particular to a method for managing stack frame descriptors while protecting them from destruction due to erroneous writing. This is related to the method of doing so.

従来の技術 ALGOL、PASCALなどの高級言語で記述された
プログラムを構成する各プロシージャについては、それ
ぞれのワーク領域とスタックフレーム記述子の管理領域
を含むスタックフレームが、処理の開始に先立って主記
憶上に確保され、処理の終了に伴って解放される。
Conventional TechnologyFor each procedure that makes up a program written in a high-level language such as ALGOL or PASCAL, a stack frame containing a work area and a stack frame descriptor management area is stored in main memory prior to the start of processing. It is reserved and released when processing ends.

スタックフレーム記述子は、スタックフレームのサイズ
やその先頭アドレス等のスタックフレーム管理情報と、
引数アドレスや呼出し側プロシージャへのリターン・ア
ドレス等のプロシージャ制御情報と、呼出し側プロシー
ジャの各種レジスタの内容、例外発生条件及び例外処理
ルーチンのアドレスやリング保護機構がある場合の走行
していたリング値等のプロシージャ環境情報から構成さ
れる装置 このように、ワーク領域を含むスタックフレーム内でス
タックフレーム記述子を管理しているので、プロシージ
ャ自体や呼出した他のプロシージャがワーク領域を使用
する際の誤書込みによってスタックフレーム記述子が破
壊されてしまう危険がある。スタックフレーム記述子が
破壊されてしまうと、スタックフレームの管理が不能に
なり、プログラムの正常動作が保証されなくなる。
The stack frame descriptor contains stack frame management information such as the size of the stack frame and its start address,
Procedure control information such as argument addresses and return addresses to the calling procedure, the contents of various registers of the calling procedure, exception conditions, the address of the exception handling routine, and the running ring value if a ring protection mechanism is used. A device consisting of procedure environment information such as There is a risk that the stack frame descriptor may be destroyed by writing. If the stack frame descriptor is destroyed, it becomes impossible to manage the stack frame, and normal operation of the program is no longer guaranteed.

一般に電子計算機システムでは、主記憶アドレス空間を
セグメントに分割してセグメントごとに記憶保護キーを
割当てるなどの記憶保護対策がオペレーティング・シス
テムで行われる。しかしながら、各プロシージャによっ
て確保されるワーク領域とスタックフレーム記述子の管
理領域を含むスタックフレームは、同一セグメント内あ
るいは連続したセグメントに渡って形成されることが多
いため上記オペレーティング・システムによる記憶保護
対策も効果がない場合が多い。
Generally, in computer systems, the operating system takes storage protection measures such as dividing the main memory address space into segments and assigning a storage protection key to each segment. However, since the stack frame, which includes the work area secured by each procedure and the stack frame descriptor management area, is often formed within the same segment or across consecutive segments, the above operating system does not take storage protection measures. It is often ineffective.

本出願人の先願に係わる「誤書込防止回路」と題する特
許出願(特願昭60−169413号)によれば、スタ
ックフレーム内の記憶保S!領域を表示するレジスタ、
このレジスタの内容と書込みアドレスに基づき保護領域
に対するデータの書込みを検出し、これを無効にする回
路を不可することによりスタックフレーム記述子を誤書
込みから保護する発明が開示されている。
According to the patent application (Japanese Patent Application No. 60-169413) entitled "Error writing prevention circuit" related to the applicant's earlier application, the memory retention S in the stack frame! A register that displays the area,
An invention has been disclosed in which a stack frame descriptor is protected from erroneous writing by detecting writing of data to a protected area based on the contents of this register and the write address and disabling a circuit to invalidate this.

発明が解決しようとする問題点 上記先願に係わる誤書込み防止回路によれば、スタック
フレーム記述子を誤書込みから有効に保護できるが、多
少のハードウェアを追加しなければならないという問題
がある。
Problems to be Solved by the Invention Although the erroneous write prevention circuit according to the above-mentioned prior application can effectively protect the stack frame descriptor from erroneous writes, there is a problem in that some hardware must be added.

発明の構成 問題点を解決するための手段 上記先行技術の問題点を解決する本発明のスタックフレ
ーム記述子の管理方式は、スタックフレーム記述子を、
スタックフレームが形成されるセグメントとは異なりか
つプロシージャによる書込がオペレーティング・システ
ムによる記憶保護機能に基づき禁止されているセグメン
ト内に格納することにより、ハードウェアを追加するこ
となく、オペレーティング・システムによる既存の記憶
保護機能をそのまま利用してスタックフレーム記述子を
誤書込みから有効に保護するように構成されている。
Means for Solving the Constituent Problems of the Invention The stack frame descriptor management method of the present invention, which solves the problems of the above-mentioned prior art, manages stack frame descriptors by
By storing the stack frame in a segment that is different from the segment in which it is formed and that procedures are prohibited from writing to based on operating system storage protection, the operating system can use existing It is configured to effectively protect the stack frame descriptor from erroneous writing by utilizing the storage protection function of .

以下、本発明の作用を実施例と共に詳細に説明する。Hereinafter, the operation of the present invention will be explained in detail together with examples.

実施例 第1図は、本発明の一実施例において主プロシージャの
実行状態における主記憶アドレス空間の使用状況を示す
概念図である。
Embodiment FIG. 1 is a conceptual diagram showing the usage status of the main memory address space in the execution state of the main procedure in an embodiment of the present invention.

主記憶アドレス空間のセグメント10には、主プロシー
ジャが使用するスタックフレーム11が確保されている
。このスタックフレーム11のスタックフレーム記述子
21は、セグメント10とは異なりかつ記憶保護キーな
どの手法に基づくオペレーティング・システムの記憶保
3!機能によって、プロシージャによる書込みが不能な
他のセグメント(「スタックフレーム管理セグメント」
と称する)20内に確保されている。また、実行中の主
プロシージャのスタックフレーム記述子21を指定する
ためのカレント・スタックフレーム記述子ポインタPが
、CPU内の汎用レジスタなどに確保される。
A stack frame 11 used by the main procedure is reserved in segment 10 of the main memory address space. The stack frame descriptor 21 of this stack frame 11 is different from the segment 10 and is based on the operating system's memory protection 3! based on techniques such as memory protection keys. The functionality allows other segments that are not writable by procedures (the "stack frame management segment")
20). Further, a current stack frame descriptor pointer P for specifying the stack frame descriptor 21 of the main procedure being executed is secured in a general-purpose register or the like within the CPU.

主プロシージャの実行に先立ってスタックフレーム確保
ルーチンが実行され、まず、可変長あるいは固定長サイ
ズのスタックフレーム11がセグメント10内に確保さ
れる。引続き、スタックフレーム管理セグメント20内
に複数用意されているスタックフレーム記述子の格納領
域のうち空き状態にある一つが選択され、ここに、スタ
ックフレーム管理情報、プロシージャ制御情報及び呼出
し側プロシージャのプロシージャ環境情報で構成される
スタックフレーム記述子21が格納、退避される。更に
、カレント・スタックフレーム記述子ポインタPの内容
が新たに確保されたスタックフレーム記述子21を指す
ように変更される。
Prior to execution of the main procedure, a stack frame reservation routine is executed, and first, a stack frame 11 of variable length or fixed length size is secured within the segment 10. Subsequently, one of the stack frame descriptor storage areas provided in the stack frame management segment 20 that is free is selected, and the stack frame management information, procedure control information, and procedure environment of the calling procedure are stored here. A stack frame descriptor 21 consisting of information is stored and saved. Furthermore, the contents of the current stack frame descriptor pointer P are changed to point to the newly secured stack frame descriptor 21.

このスタックフレーム管理セグメント20内への書込み
は、オペレーティング・システムの記憶保護機能に基づ
き、上述のスタックフレーム確保ルーチン及び後述する
スタックフレーム開放ルーチンにだけ許容されており、
プロシージャによるこのセグメントへの書込みは禁止さ
れている。
Based on the storage protection function of the operating system, writing into the stack frame management segment 20 is only permitted by the stack frame allocation routine described above and the stack frame release routine described below.
Writing to this segment by procedures is prohibited.

スタックフレーム記述子21を構成する各フィールドの
うち、aは呼出し側プロシージャのスタックフレーム記
述子へのポインタを格納するフィールド、bはスタック
フレーム11の先頭アドレスを格納するフィー−ルド、
Cはスタックフレーム11のサイズを格納するフィール
ド、dはスタックフレーム11内の引数アドレスを格納
するフィールド、eは呼出し側プロシージャへのリター
ンアドレスを格納するフィールド、fは呼出された時点
における各種レジスタ内容の退避フィールドである。ま
た、副プロシージャに引渡される引数は、スタックフレ
ーム11内の引数領域に格納されている。
Among the fields constituting the stack frame descriptor 21, a is a field that stores a pointer to the stack frame descriptor of the calling procedure, b is a field that stores the start address of the stack frame 11,
C is a field that stores the size of stack frame 11, d is a field that stores argument addresses in stack frame 11, e is a field that stores the return address to the calling procedure, and f is the contents of various registers at the time of calling. This is the evacuation field. Further, arguments passed to the sub-procedure are stored in an argument area within the stack frame 11.

主プロシージャのスタックフレーム記述子21において
は、呼出し側プロシージャが存在しないため、呼出し側
プロシージャのスタックフレーム記述子へのポインタa
、引数アドレス格納フィールドd、呼出し側プロシージ
ャへのリターンアドレス格納フィールドe及び各種レジ
スタ内容の退避フィールドfはいずれも無効となってい
る。
In the stack frame descriptor 21 of the main procedure, since there is no calling procedure, the pointer a to the stack frame descriptor of the calling procedure
, argument address storage field d, return address storage field e for the calling procedure, and save field f for various register contents are all invalid.

このような状態のもとで、主プロシージャが副プロシー
ジャを呼出すものとする。副プロシージャの呼出しに伴
い新たなスタックフレーム確保ルーチンが実行されると
、主記憶アドレス空間の使用状況が第2図に示すような
ものに変化する。
Assume that the main procedure calls the subprocedure under these conditions. When a new stack frame securing routine is executed in response to a sub-procedure call, the usage status of the main memory address space changes to that shown in FIG. 2.

すなわち、スタックフレーム確保ルーチンの実行により
、まず、副プロシージャが使用するスタックフレーム1
2がセグメント10内に確保される。次に、このスタッ
クフレーム12のスタックフレーム記述子22がスタッ
クフレーム管理セグメント30内の空き領域に格納され
る。セグメント10内に確保されたスタックフレーム1
2の先頭アドレスが、セグメント記述子22の先頭アド
レス格納フィールドbに格納され、サイズmがサイズ格
納フィールドCに格納される。主プロシージャから引渡
された引数のアドレスは、引数アドレス格納フィールド
dに格納される。また、主プロシージャへのリターンア
ドレスXがフィールドeに格納され、副プロシージャの
呼出し時点における各種レジスタの内容がレジスタ内容
退避フィールドfに格納される。
That is, by executing the stack frame allocation routine, stack frame 1 used by the subprocedure is first allocated.
2 is reserved in segment 10. Next, the stack frame descriptor 22 of this stack frame 12 is stored in a free area within the stack frame management segment 30. Stack frame 1 secured in segment 10
The start address of 2 is stored in the start address storage field b of the segment descriptor 22, and the size m is stored in the size storage field C. The address of the argument passed from the main procedure is stored in the argument address storage field d. Further, the return address X to the main procedure is stored in the field e, and the contents of various registers at the time the sub procedure is called are stored in the register content save field f.

最後に、カレント・スタックフレーム記述子ポインタP
の内容が、呼出し側プロシージャのスタックフレーム記
述子21のポインタ退避フィールドaに退避されたのち
、その内容が副プロシージャのスタックフレーム記述子
31を指す値に変更される。このスタックフレーム確保
ルーチンが終了すると、副プロシージャの実行が開始さ
れる。
Finally, the current stack frame descriptor pointer P
The contents are saved in the pointer save field a of the stack frame descriptor 21 of the calling procedure, and then the contents are changed to a value pointing to the stack frame descriptor 31 of the sub-procedure. When this stack frame allocation routine ends, execution of the subprocedure begins.

その後側プロシージャの処理が終了すると、スタックフ
レーム解放ルーチンによって、スタックフレーム12が
解放され、またプロシージャ制御情報と呼出し側プロシ
ージャのプロシージャ環境情報とが回復される。
When processing of the subsequent procedure is completed, the stack frame release routine frees the stack frame 12 and restores the procedure control information and the procedure environment information of the calling procedure.

すなわち、スタックフレーム記述子22の呼出し側プロ
シージャへのリターンアドレス格納フィールドeからリ
ターンアドレスXが取出され、各種レジスタ内容の退避
フィールドfの内容が対応のレジスタに戻される。更に
、カレント・スタックフレーム記述子ポインタPに、呼
出し側プロシージャのスタックフレーム記述子31のフ
ィールドaに退避されていた値が戻される。最後に、不
要となったスタックフレーム記述子31がスタックフレ
ーム管理セグメント30上で解放され、主記憶アドレス
空間の使用状態は、第1図の状態に戻る。
That is, the return address X is taken out from the return address storage field e to the calling procedure of the stack frame descriptor 22, and the contents of the save field f of the contents of various registers are returned to the corresponding register. Further, the value saved in field a of the stack frame descriptor 31 of the calling procedure is returned to the current stack frame descriptor pointer P. Finally, the stack frame descriptor 31 that is no longer needed is released on the stack frame management segment 30, and the usage state of the main memory address space returns to the state shown in FIG.

発明の効果 以上詳細に説明したように、本発明のスタックフレーム
記述子の管理方式は、スタックフレーム記述子を、スタ
ックフレームが形成される主記憶上のセグメントとは異
なりかつプロシージャによる書込みがオペレーティング
・システムによる記憶保護機能に基づき禁止されている
セグメント内で管理する構成であるから、ハードウェア
をなんら付加することなく、オペレーティング・システ
ムによる既存の記憶保護機能をそのまま利用してスタッ
クフレーム記述子を誤書込みから有効に保護することが
できる。
Effects of the Invention As explained in detail above, the stack frame descriptor management method of the present invention allows the stack frame descriptor to be written in a manner that is different from the main memory segment in which the stack frame is formed and which cannot be written by the operating system. Since the configuration is such that management is performed within a segment that is prohibited based on the system's memory protection function, it is possible to use the existing memory protection function of the operating system without adding any hardware to prevent errors in stack frame descriptors. It can be effectively protected from writing.

【図面の簡単な説明】[Brief explanation of drawings]

第1図は本発明の一実施例において主プロシージャ実行
時の主記憶アドレス空間の使用状況を示す概念図、第2
図は上記主プロシージャによって副プロシージャが呼出
されたのちの主記憶アドレス空間の使用状況を説明する
ための概念図である。 10.20・・主記憶アドレス空間の異なるセグメント
、11・・主プロシージャに割当てられたスタックフレ
ーム、12・・副プロシージャに割当てられたスタック
フレーム、21・・スタックフレーム11の記述子、2
2・・スタックフレーム12の記述子、P・・カレント
・スタックフレーム記述子を指すポインタ、 a・・呼出し側ブロシージ中のスタックフレーム記述子
のポインタ格納フィールド、 b・・スタックフレーム・アドレスの格納フィールド C・・スタックフレーム・サイズの格納フィールド d・・引数アドレスの格納フィールド、e・・呼出し側
フィールドへのリターンアドレス格納フィールド
FIG. 1 is a conceptual diagram showing the usage status of the main memory address space during execution of the main procedure in an embodiment of the present invention;
The figure is a conceptual diagram for explaining the usage status of the main memory address space after the sub-procedure is called by the main procedure. 10.20... Different segments of main memory address space, 11... Stack frame allocated to main procedure, 12... Stack frame allocated to sub procedure, 21... Descriptor of stack frame 11, 2
2. Descriptor of stack frame 12, P. Pointer pointing to the current stack frame descriptor, a. Pointer storage field for the stack frame descriptor in the calling program, b. Storage field for the stack frame address. C: Storage field for stack frame size d: Storage field for argument address, e: Storage field for return address to caller field

Claims (1)

【特許請求の範囲】 主記憶アドレス空間がセグメントに分割され、オペレー
ティング・システムによってセグメントごとの記憶保護
が行われる電子計算機システムにおいて、 スタックフレーム管理情報、プロシージャ制御情報及び
呼出し側のプロシージャの環境情報を含むスタックフレ
ーム記述子を、スタックフレームが形成されるセグメン
トとは異なりかつプロシージャによる書込みが前記オペ
レーティング・システムによる記憶保護機能に基づき禁
止されているセグメント内で管理することを特徴とする
スタックフレーム記述子の管理方式。
[Claims] In a computer system in which a main memory address space is divided into segments and memory protection is performed for each segment by an operating system, stack frame management information, procedure control information, and environment information of a calling procedure are stored. A stack frame descriptor comprising a stack frame descriptor managed in a segment that is different from the segment in which the stack frame is formed and in which writing by a procedure is prohibited based on a memory protection function of the operating system. management method.
JP61075861A 1986-04-02 1986-04-02 Controlling system for stack frame descriptor Pending JPS62232054A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP61075861A JPS62232054A (en) 1986-04-02 1986-04-02 Controlling system for stack frame descriptor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP61075861A JPS62232054A (en) 1986-04-02 1986-04-02 Controlling system for stack frame descriptor

Publications (1)

Publication Number Publication Date
JPS62232054A true JPS62232054A (en) 1987-10-12

Family

ID=13588448

Family Applications (1)

Application Number Title Priority Date Filing Date
JP61075861A Pending JPS62232054A (en) 1986-04-02 1986-04-02 Controlling system for stack frame descriptor

Country Status (1)

Country Link
JP (1) JPS62232054A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE19846673A1 (en) * 1998-10-09 2000-04-20 Siemens Ag Stack manipulation activity prevention procedure for intelligent chip-card integrated circuits (ICs)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE19846673A1 (en) * 1998-10-09 2000-04-20 Siemens Ag Stack manipulation activity prevention procedure for intelligent chip-card integrated circuits (ICs)

Similar Documents

Publication Publication Date Title
US5950221A (en) Variably-sized kernel memory stacks
US7809911B2 (en) Write protection of subroutine return addresses
EP1012715B1 (en) Hardware assisted method of context switching
KR100848603B1 (en) A data processing apparatus and method for saving return state
JPH0619798A (en) Method and system for avoidance of loading of value of selector
JPH0114611B2 (en)
US20040122834A1 (en) Apparatus and method for switching mode in a computer system
US7089242B1 (en) Method, system, program, and data structure for controlling access to sensitive functions
EP0230350A2 (en) Protection of data in a multiprogramming data processing system
US6895583B1 (en) Task control block for a computing environment
KR100791815B1 (en) Privilege promotion based on check of previous privilege level
JP2850808B2 (en) Data processing device and data processing method
US20020013907A1 (en) Method of preventing stack manipulation attacks during function calls
WO2019237865A1 (en) Data protection method and computing device
JP2004326331A (en) Unauthorized memory access detection method and program of the same
JPS62232054A (en) Controlling system for stack frame descriptor
US7814288B2 (en) Protecting memory operations involving zero byte allocations
US6687845B2 (en) Fault vector pointer table
JPH0484224A (en) Stack area protection circuit
JPH1153249A (en) Memory managing method
JP2005209178A (en) Memory protection unit, memory protection method, and memory protection program
KR100928865B1 (en) Stack expansion and protection methods in computer systems and devices therefor
JPS60142452A (en) Storage protecting system
WO1990005951A1 (en) Method of handling unintended software interrupt exceptions
JPH01180656A (en) Memory protecting device