question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve Segmentation Semantics for x86

See original GitHub issue

Describe the bug LowIR for instructions accessing segmented memory is “probably” incorrect, e.g.

2e 8b 02    mov eax, cs:[edx]

To Reproduce

  1. Run this piece of code
open B2R2
open B2R2.FrontEnd

[<EntryPoint>]
let main argv =
  let isa = ISA.OfString "x86"
  let bytes = [| 0x2euy; 0x8buy; 0x02uy; |]
  let handler = BinHandler.Init (isa, bytes)
  let ins = BinHandler.ParseInstr handler 0UL
  ins
  |> fun i -> i.Translate handler.TranslationContext
  |> printfn "%A"
  0
  1. See output
[|ISMark (0UL,3u);
  Put
    (Var (32,8,"EAX",IntelRegisterSet<1, 0, 0, 0>),
     Load
       (Little,32,
        BinOp
          (ADD,32,Var (32,1793,"CSBase",IntelRegisterSet<8000000, 0, 0, 0>),
           Var (32,11,"EDX",IntelRegisterSet<8, 0, 0, 0>),
           {HasLoad = false;
            VarInfo = IntelRegisterSet<8000008, 0, 0, 0>;
            TempVarInfo = set [];},None),
        {HasLoad = true;
         VarInfo = IntelRegisterSet<8000008, 0, 0, 0>;
         TempVarInfo = set [];},None)); IEMark 3UL|]

Expected behavior In the Intel’s segmented memory model, the semantics of cs:[edx] is not simply as loading [cs + edx].

Environment:

  • OS: [e.g. iOS]
  • .NET Core version: [e.g. 2.1.502]
  • B2R2 version [e.g. 0.1.0]

Additional context I’m reading the paper but it does not discuss about how the memory is modelled.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sangkilccommented, Feb 27, 2019

I mean you can implement your own analyzer using a memory model that handles the CSBase variable correctly. For documentation, you should take a look at the file LowUIR.fs. There are extensive comments for each expression and statement of our IR. For example, https://github.com/B2R2-org/B2R2/blob/master/src/BinIR/LowUIR.fs#L48

0reactions
stale[bot]commented, Jun 13, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Image Segmentation: Tips and Tricks from 39 Kaggle ...
Clustering of 3d segmentation with the 0.5 threshold; Identify if there is a substantial ... Apply pseudo labeling to test data in order...
Read more >
A 2021 guide to Semantic Segmentation
Low-Latency Video Semantic Segmentation​​ This paper improves on top of the above discussion by adaptively selecting the frames to compute the  ...
Read more >
Semantic Segmentation - The Definitive Guide for 2021
In this article, we'll take a deep dive into the world of semantic segmentation. Some of the items that will be covered include:...
Read more >
Segment size in x86 real mode
The segment limit in real mode is 64K, even on a 386 or later CPU where you can use 32-bit address-size via prefixes....
Read more >
x86 memory segmentation
x86 memory segmentation refers to the implementation of memory segmentation in the Intel x86 computer instruction set architecture.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found