Git Product home page Git Product logo

Comments (2)

adamrk avatar adamrk commented on July 17, 2024 1

I tried running this myself and didn't hit the OOM, but I do see the following right before execution traps on an out-of-bounds table access:

000232 func[7]:
 000233: 02 7c                      | local[3..4] type=f64
 000235: 05 7d                      | local[5..9] type=f32
 000237: 01 7b                      | local[10] type=v128
 000239: 02 7f                      | local[11..12] type=i32
 00023b: 01 70                      | local[13] type=funcref
 00023d: 02 40                      | block
 00023f: 02 40                      |   block
 000241: 42 96 cb 93 d2 97 a2 d5 87 |     i64.const -3094160885426100842
 00024a: 55                         | 
 00024b: 10 03                      |     call 3 <i64.no_fold_f64_u>
 00024d: d0 6f                      |     ref.null extern
 00024f: 41 bc e2 f1 fe 7a          |     i32.const 2950459708
 000255: fc 0f 01                   |     table.grow 1             <------------- Grow table by ~3 billion entries
 000258: 11 06 00                   |     call_indirect 6 0        <------------- Trap with oob table access

Adding the entries from that table.grow instruction will allocate about

2950459708 * 8 = 23603677664 = 0x57EE389E0 bytes

which is pretty close to the amount you see in the failed allocation. So I assume your setup just isn't allowing WSL to allocate that much?

Anyway, there's nothing in the spec that prevents a table from growing this large, so it seems perfectly reasonable for wasm-interp to handle the request. I'd think a user that's concerned about possible DOS attacks would check Wasms to ensure tables and memories have a reasonable maximum size (or modify them to add maximum sizes) before executing.

from wabt.

mobsceneZ avatar mobsceneZ commented on July 17, 2024

I tried running this myself and didn't hit the OOM, but I do see the following right before execution traps on an out-of-bounds table access:

000232 func[7]:
 000233: 02 7c                      | local[3..4] type=f64
 000235: 05 7d                      | local[5..9] type=f32
 000237: 01 7b                      | local[10] type=v128
 000239: 02 7f                      | local[11..12] type=i32
 00023b: 01 70                      | local[13] type=funcref
 00023d: 02 40                      | block
 00023f: 02 40                      |   block
 000241: 42 96 cb 93 d2 97 a2 d5 87 |     i64.const -3094160885426100842
 00024a: 55                         | 
 00024b: 10 03                      |     call 3 <i64.no_fold_f64_u>
 00024d: d0 6f                      |     ref.null extern
 00024f: 41 bc e2 f1 fe 7a          |     i32.const 2950459708
 000255: fc 0f 01                   |     table.grow 1             <------------- Grow table by ~3 billion entries
 000258: 11 06 00                   |     call_indirect 6 0        <------------- Trap with oob table access

Adding the entries from that table.grow instruction will allocate about

2950459708 * 8 = 23603677664 = 0x57EE389E0 bytes

which is pretty close to the amount you see in the failed allocation. So I assume your setup just isn't allowing WSL to allocate that much?

Anyway, there's nothing in the spec that prevents a table from growing this large, so it seems perfectly reasonable for wasm-interp to handle the request. I'd think a user that's concerned about possible DOS attacks would check Wasms to ensure tables and memories have a reasonable maximum size (or modify them to add maximum sizes) before executing.

Thanks for your reply @adamrk, that's a fair point. I shall not consider this kind of issue as bug ๐Ÿค” .

from wabt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.