LWN: Comments on "The Sequoia seq_file vulnerability" https://lwn.net/Articles/863729/ This is a special feed containing comments posted to the individual LWN article titled "The Sequoia seq_file vulnerability". en-us Sat, 18 Oct 2025 10:50:30 +0000 Sat, 18 Oct 2025 10:50:30 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net The Sequoia seq_file vulnerability https://lwn.net/Articles/865896/ https://lwn.net/Articles/865896/ Margaret48 <div class="FormattedComment"> firefox unlike chromium silently disables most parts of its sandbox when userns aren&#x27;t available leaving only seccomp.<br> </div> Tue, 10 Aug 2021 17:24:45 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/865424/ https://lwn.net/Articles/865424/ Randakar <div class="FormattedComment"> Frankly crashing the kernel is *exactly* the right thing to do. <br> <p> In lieu of the compiler explicitly rejecting such conversions (which it should) the next best thing is to fail in the most loud and noisy way possible so that this type of bug has a bigger chance to get noticed.<br> <p> Silently doing unexpected things is almost always worse than an error, even if it crashes the system.<br> </div> Fri, 06 Aug 2021 09:40:20 +0000 Narrowing conversion https://lwn.net/Articles/864522/ https://lwn.net/Articles/864522/ mathstuf <div class="FormattedComment"> That&#x27;s…quite a narrow view of what Rust provides. I&#x27;m feeling forgetful…what warning flag tells me when my code has data races in C++? When I write `return make_string().c_str();`?<br> </div> Wed, 28 Jul 2021 17:07:04 +0000 Narrowing conversion https://lwn.net/Articles/864520/ https://lwn.net/Articles/864520/ sandsmark <div class="FormattedComment"> <font class="QuotedText">&gt; Since it&#x27;s the topic du jour, in Rust you can&#x27;t have implicit narrowing conversion, but it does provide an explicit conversion that can silently lose information in narrowing, programmers might write:</font><br> <p> Again proving that the safety of Rust is just a subset of C++ with -Werror -Weverything. :-P<br> <p> (And I&#x27;d say C++ discourages it even more because casting is uglier/more verbose, but people tend to just cast everything just to get rid of warnings/errors so you basically end up with implicit casting anyways.)<br> </div> Wed, 28 Jul 2021 16:33:45 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/864283/ https://lwn.net/Articles/864283/ wtarreau <div class="FormattedComment"> Same here and I totally agree.<br> </div> Mon, 26 Jul 2021 06:10:16 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/864258/ https://lwn.net/Articles/864258/ tialaramex <div class="FormattedComment"> For this vulnerability what we&#x27;ve got is a narrowing conversion rather than conventional integer overflow. There&#x27;s discussion above this on LWN. In C narrowing conversions are implicit -- if you assign a huge number into a small integer type, the compiler shrugs and throws away whatever doesn&#x27;t fit. Rust&#x27;s conversions are explicit -- if the types don&#x27;t match you need to say &quot;as&quot; to get it converted, however a programmer may not be brought up short by the need for conversion and realise this is a terrible idea because some of their values get thrown away.<br> <p> If you would rather overflow checks also happen in production, you can ask for the Rust compiler setting overflow-checks = true in your production builds, as well as debug where it is default.<br> <p> However, that would turn such bugs into a kernel crash, rather than local root. Not really what you want.<br> <p> Rust also lets you explicitly say what you intend to happen for overflow. For example you can say you want saturating arithmetic (127_i8.saturating_add(1_i8) == 127_i8) or wrapping arithmetic (127_i8.wrapping_add(1_i8) == -128_i8) and now, at last, you&#x27;ve actually expressed your intention and so it&#x27;s more likely this code might do what you intended rather than crashing or worse.<br> <p> Ultimately if the programmer did not express any intent, it&#x27;s difficult to see what a practical general purpose language ought to do.<br> <p> In WUFFS they get to just reject all programs that don&#x27;t specify. So if you look at byte A and byte B and you purport that you can add those together A+B and store the result as one byte, the WUFFS compiler rejects that code. You need to spell out constraints so that A and B will be small enough for this to work (WUFFS will check the constraints at runtime and error out if they are not met) OR explain how the addition should saturate or wrap to get one byte out (then WUFFS generates code that does so).<br> <p> This feels like an appropriate discipline in their situation, but most programmers would chafe badly under those conditions.<br> <p> <p> </div> Sun, 25 Jul 2021 18:21:15 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/864252/ https://lwn.net/Articles/864252/ aaronmdjones <div class="FormattedComment"> And it&#x27;s times like these that I really thank myself for building my own kernels that only have what I need.<br> <p> I don&#x27;t have userspace helper binary support, I don&#x27;t have BPF support, I don&#x27;t have user namespaces support (unprivileged or not), I don&#x27;t have FUSE support, and I don&#x27;t have userfaultfd support.<br> <p> As far as I can see, between the lack of user namespaces and the lack of FUSE, I have nothing to worry about, since exploiting this vulnerability relies on mounting, which is a privileged operation in my case (no; mount(8) is not setuid).<br> </div> Sun, 25 Jul 2021 13:34:20 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/864243/ https://lwn.net/Articles/864243/ geuder <div class="FormattedComment"> <font class="QuotedText">&gt; Rust seems to check integer overflows at debug builds (s32, s64), and it compiles out checks at production builds.</font><br> <p> I have not liked that approach since the days of assert(3) and NDEBUG, which is from the 1980s or even 70s (didn&#x27;t do any programming during the latter). Code that behaves differently in debug builds just causes loads of new problems. You must fully test both variants to get a benefit reliably.<br> <p> For the vulnerability at hand such mechanism would not have helped: Even if kernel debug builds were tested, it would be unlikely to have a test case creating 10GB of path name.<br> <p> <p> <p> <p> </div> Sun, 25 Jul 2021 09:38:53 +0000 Narrowing conversion https://lwn.net/Articles/864162/ https://lwn.net/Articles/864162/ jezuch <div class="FormattedComment"> I guess it&#x27;s &quot;not great&quot; by design, like the new-style casts in C++ are ugly by design to discourage casting in general.<br> <p> FWIW, AFAICT Rust doesn&#x27;t have implicit *widening* conversion either. Turns out, it too often turns into a footgun.<br> </div> Fri, 23 Jul 2021 16:40:29 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/864090/ https://lwn.net/Articles/864090/ matthias <div class="FormattedComment"> Yes, userfaultfd() is only used to give the write vulnerability time to do its work by suspending the thread responsible for verifying and compiling the BPF in the right moment. On my first read, I was also puzzled, why there was not more talk about this seemingly BPF vulnerability.<br> </div> Fri, 23 Jul 2021 11:59:33 +0000 Narrowing conversion https://lwn.net/Articles/864085/ https://lwn.net/Articles/864085/ khim <p>Not really. In Rust, unlike in C++, editions are supposed to coexist. You can write one crate in Rust 2015, another in Rust 2018, and third in Rust 2021.</p> <p>Sure, if you are actively developing your code then you would probably want to upgrade it, but there are no pressure to do that ASAP.</p> Fri, 23 Jul 2021 09:54:40 +0000 Narrowing conversion https://lwn.net/Articles/864078/ https://lwn.net/Articles/864078/ Fowl <div class="FormattedComment"> The code still would want to be upgraded to a newer edition at some point. <br> </div> Fri, 23 Jul 2021 07:50:44 +0000 Narrowing conversion https://lwn.net/Articles/864059/ https://lwn.net/Articles/864059/ khim <font class="QuotedText">&gt; But obviously a lot of existing code would be affected.</font> <p>Isn't it something Rust editions are supposed to cover?</p> Fri, 23 Jul 2021 00:47:42 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/864058/ https://lwn.net/Articles/864058/ pabs <div class="FormattedComment"> The article made it sound like userfaultfd() could be used to modify the BPF after the verifier ran, re-reading the paragraph it sounds like I missed that that can&#x27;t happen without a memory write vulnerability?<br> </div> Fri, 23 Jul 2021 00:35:46 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/864046/ https://lwn.net/Articles/864046/ Paf <div class="FormattedComment"> The BPF verifier is evaded by writing to the memory containing the program after the verified has run. So, nothing BPF can do about it.<br> </div> Thu, 22 Jul 2021 20:55:05 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/863954/ https://lwn.net/Articles/863954/ smcv <div class="FormattedComment"> I suspect this means that the content processes (`firefox -contentproc`) are not using user namespaces to limit their view of the rest of the system to protect it from the possibility that they might get compromised by a malicious site; or perhaps they&#x27;re using a setuid helper to get into a different user namespace.<br> <p> I don&#x27;t immediately have a Debian 10 system to hand, but on Debian 11 systems with firefox 88.0.1 and firefox-esr 78.11.0esr, the top-level `firefox` process is in the same userns and filesystem namespace as my interactive shell, but each `firefox -contentproc` subprocess has its own userns (you can see this with `ls -l /proc/$pid/ns/user`) and is running in a private filesystem namespace with an empty root directory (you can see this with `ls -l /proc/$pid/root/`).<br> </div> Thu, 22 Jul 2021 13:00:15 +0000 Narrowing conversion https://lwn.net/Articles/863947/ https://lwn.net/Articles/863947/ roc <div class="FormattedComment"> When you read &quot;foobar as u32&quot; it&#x27;s not obvious whether that is (potentially) lossy or not. OK, with rust-analyzer I just have to hover &quot;foobar&quot; to see what type it is, but it would be so simple to just require different syntax for lossy vs non-lossy conversions.<br> </div> Thu, 22 Jul 2021 11:56:06 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/863934/ https://lwn.net/Articles/863934/ jmaa <div class="FormattedComment"> I&#x27;m curious what the fix would be for the BPF? Would have expected jitted code to be read/execute-only when compiled, but perhaps there&#x27;s some limitation preventing W^R?<br> </div> Thu, 22 Jul 2021 10:32:51 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/863937/ https://lwn.net/Articles/863937/ ma4ris5 <div class="FormattedComment"> I found a page which elaborates Rust&#x27;s approach for integer overflows:<br> <a href="http://huonw.github.io/blog/2016/04/myths-and-legends-about-integer-overflow-in-rust/">http://huonw.github.io/blog/2016/04/myths-and-legends-abo...</a><br> <p> Rust seems to check integer overflows at debug builds (s32, s64),<br> and it compiles out checks at production builds. So Rust seems to have too<br> low level approach to overflows.<br> <p> My &quot;expect_range&quot; suggestion is such, that developer could elaborate the range<br> regardless of the value&#x27;s type (u8, s8, ..., u32, u64, s32, s64), (possibly) the bit range<br> of the value, so that compiler could verify that an overflow can&#x27;t happen when<br> doing arithmetic calculations at compile or static analysis time.<br> <p> Thus there should be enough information for static analysis, and, or, compile time,<br> to do mathematical proof, to imply that overflows are absent: out of range values don&#x27;t exist.<br> <p> Mathematical proof would enable compiler to skip unnecessary branches, and remove dead code.<br> <p> Optional warnings could be used to guide development into safe code.<br> <p> <p> Arbitrary precision (integer) arithmetic elaborates a solution for this:<br> <a href="https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic">https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic</a><br> <font class="QuotedText">&gt; In many cases, the task or the programmer can guarantee that the integer values</font><br> <font class="QuotedText">&gt; in a specific application will not grow large enough to cause an overflow. Such</font><br> <font class="QuotedText">&gt; guarantees may be based on pragmatic limits: a school attendance program </font><br> <font class="QuotedText">&gt; may have a task limit of 4,000 students. A programmer may design the computation </font><br> <font class="QuotedText">&gt; so that intermediate results stay within specified precision boundaries. </font><br> <p> </div> Thu, 22 Jul 2021 10:30:55 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/863938/ https://lwn.net/Articles/863938/ immibis <div class="FormattedComment"> I&#x27;m not seeing the problem with the BPF verifier here. It is not concerning that the BPF verifier can malfunction if arbitrary memory is arbitrarily overwritten at arbitrary points in the process. Most code malfunctions most of the time under those conditions.<br> </div> Thu, 22 Jul 2021 10:10:44 +0000 Narrowing conversion https://lwn.net/Articles/863936/ https://lwn.net/Articles/863936/ atnot <div class="FormattedComment"> I think just deferring to experience isn&#x27;t very useful here. Adding explicit conversions quickly becomes muscle memory that isn&#x27;t given the thought it should be given. You might just not consider whether it is lossy or not in that moment. Since languages should make it easier to do the right thing than the wrong thing, requiring different mechanisms for lossy and lossless conversions would give a crucial opportunity to think about how it should really be handled.<br> </div> Thu, 22 Jul 2021 09:53:37 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/863927/ https://lwn.net/Articles/863927/ pabs <div class="FormattedComment"> The BPF verifier evasion seems pretty concerning, but the article didn&#x27;t mention if that has been fixed. I also wonder if changes to block each of the steps in the exploit have been made.<br> </div> Thu, 22 Jul 2021 08:36:40 +0000 Narrowing conversion https://lwn.net/Articles/863925/ https://lwn.net/Articles/863925/ Wol <div class="FormattedComment"> <font class="QuotedText">&gt; You shouldn&#x27;t have the same syntax for both lossy and non-lossy conversions.</font><br> <p> If it is (clearly) changing the length of the storage field - as in between int32 and int64, why not? Only an extreme novice would think that you could stuff an int64 into an int32 and not run at least the risk of truncation. Okay if it&#x27;s not obvious the target is an int32 then it&#x27;s a more fuzzy issue.<br> <p> Cheers,<br> Wol<br> </div> Thu, 22 Jul 2021 08:30:40 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/863917/ https://lwn.net/Articles/863917/ ma4ris5 <div class="FormattedComment"> In this case, seq_buf_alloc() doesn&#x27;t have integer overflow, argument is already an unsigned 64 bit value.<br> <p> How about elaborating for the compiler, what the programmer&#x27;s intention is?<br> What if there would be an attribute, which can elaborate expected valid value range?<br> <p> <font class="QuotedText">&gt; static void *seq_buf_alloc(unsigned long size</font><br> <font class="QuotedText">&gt; __attribute__ ((expect_range (0, MAX_RW_COUNT))) )</font><br> <font class="QuotedText">&gt; {</font><br> <font class="QuotedText">&gt; if (unlikely(size &gt; MAX_RW_COUNT))</font><br> <font class="QuotedText">&gt; return NULL;</font><br> <font class="QuotedText">&gt;</font><br> <font class="QuotedText">&gt; return kvmalloc(size, GFP_KERNEL_ACCOUNT);</font><br> <font class="QuotedText">&gt; }</font><br> <p> Here compiler could warn, if caller of seq_buf_alloc() could pass out of range value for &#x27;size&#x27;.<br> On the other hand, if no caller can create oversized value, compiler could optimize<br> the if condition away as dead code.<br> <p> Older compilers could work still, because their code generation isn&#x27;t affected:<br> They don&#x27;t know about the new &quot;expect_range&quot; attribute.<br> Thus they would keep the check in dead code case.<br> They wouldn&#x27;t be able to show the additional warnings though.<br> <p> </div> Thu, 22 Jul 2021 07:49:59 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/863918/ https://lwn.net/Articles/863918/ ganneff <div class="FormattedComment"> <font class="QuotedText">&gt;Either of these mitigations will break user-space applications that expect to be able to create sandbox environments via user namespaces, such as Firefox, Chromium, podman/toolbox, and all users of bwrap (Flatpak, WebKitGTK, libgnome-desktop (for sandboxed thumbnailers), Steam, etc.), so they should probably only be done on systems where user-space is known not to need sandboxes or containers.</font><br> <p> Firefox (78.12.0esr-1~deb10u1) at least doesn&#x27;t seem to care - or doesn&#x27;t complain.<br> <p> </div> Thu, 22 Jul 2021 07:24:30 +0000 Narrowing conversion https://lwn.net/Articles/863904/ https://lwn.net/Articles/863904/ roc <div class="FormattedComment"> From and TryFrom let you express infallible and fallible scalar conversions. There probably should be a third trait+method to explicitly request a truncating/sign-modifying conversion. But &quot;as&quot; for scalar conversions is a footgun.<br> <p> I&#x27;m not sure what the best way to proceed from here is. One option would be to introduce that trait+method for truncating conversions, and deprecate or ban lossy &quot;as&quot; scalar conversions in a future edition. But obviously a lot of existing code would be affected.<br> </div> Thu, 22 Jul 2021 01:21:07 +0000 Narrowing conversion https://lwn.net/Articles/863903/ https://lwn.net/Articles/863903/ Gaelan <div class="FormattedComment"> For non-lossy conversions, there&#x27;s the alternate syntax u64::from(some_u32), but it&#x27;s still not great.<br> </div> Thu, 22 Jul 2021 00:41:39 +0000 Narrowing conversion https://lwn.net/Articles/863902/ https://lwn.net/Articles/863902/ roc <div class="FormattedComment"> &quot;as&quot; is one of Rust&#x27;s warts. You shouldn&#x27;t have the same syntax for both lossy and non-lossy conversions.<br> </div> Thu, 22 Jul 2021 00:08:25 +0000 The Sequoia seq_file vulnerability https://lwn.net/Articles/863900/ https://lwn.net/Articles/863900/ smcv <div class="FormattedComment"> <font class="QuotedText">&gt; One of the suggested mitigations is turning off the ability for unprivileged users to create user namespaces (via /proc/sys/kernel/unprivileged_userns_clone)</font><br> <p> This sysctl is Debian/Ubuntu-specific; some other distro kernels have picked it up, such as Arch&#x27;s non-default linux-hardened kernel, but it isn&#x27;t an upstream feature. I believe the upstream equivalent is to set /proc/sys/user/max_user_namespaces to 0.<br> <p> Either of these mitigations will break user-space applications that expect to be able to create sandbox environments via user namespaces, such as Firefox, Chromium, podman/toolbox, and all users of bwrap (Flatpak, WebKitGTK, libgnome-desktop (for sandboxed thumbnailers), Steam, etc.), so they should probably only be done on systems where user-space is known not to need sandboxes or containers. This is a security trade-off: the mitigation reduces the kernel&#x27;s attack surface, but also reduces the ability for parts of user-space to distrust other parts of user-space.<br> <p> Some of these applications can work around inability for unprivileged programs to create user namespaces by using a setuid-root helper (Chromium&#x27;s deprecated setuid sandbox helper, or a setuid copy of bwrap), but this is another security tradeoff: a setuid-root helper might have root privilege escalation vulnerabilities itself.<br> <p> It is also not always possible for a setuid-root helper to provide full functionality. A setuid copy of bwrap disables some of its features, because it would not be possible to implement them securely; this reduced functionality is known to break some Flatpak apps, particularly those that make use of sub-sandboxing, notably (again) Chromium.<br> </div> Thu, 22 Jul 2021 00:02:54 +0000 Narrowing conversion https://lwn.net/Articles/863896/ https://lwn.net/Articles/863896/ tialaramex <div class="FormattedComment"> <font class="QuotedText">&gt; Clearly the integer conversion at the heart of the exploit needed fixing; one wonders how many other size_t-to-int problems of that sort still linger in the kernel.</font><br> <p> This is called an implicit narrowing conversion. Many modern languages outright forbid this, requiring that the programmer *explicitly* choose to perform a narrowing conversion or (perhaps better) even requiring that they explicitly decide what happens when the big thing won&#x27;t fit in the small thing.<br> <p> You can imagine that in kernel code, some sort of error, or panic should likely be the choice, if the programmer did not instead decide to approach the problem in a different way to avoid a narrowing conversion. Apparently out-of-box Windows MSVC programs warn if you do an implicit narrowing conversion but alas GCC does not, even under -Wall, although -Wconversion exists.<br> <p> Since it&#x27;s the topic du jour, in Rust you can&#x27;t have implicit narrowing conversion, but it does provide an explicit conversion that can silently lose information in narrowing, programmers might write:<br> <p> let signedInt = sixtyFourBitNumber as s32;<br> <p> Whereas perhaps they ought to write:<br> <p> let signedInt: s32 = sixtyFourBitNumber.try_into().unwrap(); // panic if it doesn&#x27;t fit<br> <p> or indeed:<br> <p> let signedInt: s32 = sixtyFourBitNumber.try_into()? // only compiles if the function we do this in has a suitable error return<br> <p> let signedInt: s32 = sixtyFourBitNumber.try_into().unwrap_or(SAFE_DEFAULT); // we&#x27;re confident SAFE_DEFAULT is fine<br> <p> <p> <p> </div> Wed, 21 Jul 2021 23:05:28 +0000