Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3DD7C433EF for ; Thu, 28 Apr 2022 09:11:27 +0000 (UTC) Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94.2) (envelope-from ) id 1nk0B4-0007Xd-1V; Thu, 28 Apr 2022 05:11:10 -0400 Received: from mxout.security-mail.net ([85.31.212.46] helo=fx303.security-mail.net) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nk0B2-0007Wr-7B for kernelnewbies@kernelnewbies.org; Thu, 28 Apr 2022 05:11:08 -0400 Received: from localhost (localhost [127.0.0.1]) by fx303.security-mail.net (Postfix) with ESMTP id 943BA32379B for ; Thu, 28 Apr 2022 11:11:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1651137066; bh=r6PGN1jgQifdEqSHZRV/XT5kw321k2Zy7HSsOH5qK/E=; h=Date:From:To:Subject; b=dy5rf5BlYacblrT0DWJa2frvLuOLkKrmC/vcjyHqKFCG52ZKlxCqmzlO3tYbT0DSh PDvAI5ohwyEcqXAJJiiuxZhMVmYZh3zG31ukmSfHy5X1HOj2sjeTZ1YGhHsG9+Y8xe +e1+EZYsEPFipGPiJCnhWlQzzEQML3xbsB+5mzq0= Received: from fx303 (localhost [127.0.0.1]) by fx303.security-mail.net (Postfix) with ESMTP id 2C0053236FC for ; Thu, 28 Apr 2022 11:11:06 +0200 (CEST) Received: from zimbra2.kalray.eu (unknown [217.181.231.53]) by fx303.security-mail.net (Postfix) with ESMTPS id 1041532379B for ; Thu, 28 Apr 2022 11:11:05 +0200 (CEST) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTPS id 98F2027E0444 for ; Thu, 28 Apr 2022 11:11:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 8221B27E0448 for ; Thu, 28 Apr 2022 11:11:04 +0200 (CEST) Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id rLwFuiWN-F6k for ; Thu, 28 Apr 2022 11:11:04 +0200 (CEST) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 70F6F27E0444 for ; Thu, 28 Apr 2022 11:11:04 +0200 (CEST) X-Virus-Scanned: E-securemail, by Secumail Secumail-id: <1227c.626a5a29.f2e5.0> DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 8221B27E0448 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalrayinc.com; s=4F334102-7B72-11EB-A74E-42D0B9747555; t=1651137064; bh=O7fKweGvuGm52QLReB3bzzOxcbjvOJdviHjY5VRWdUs=; h=Date:From:To:Message-ID:MIME-Version; b=n6MXzCKuM5cE/Q4t2FZxkwsADERjpLFntSJKW4OK+tLhyr4IDAznvJwDGso5FlHha JoLpNza/V117SDmoFyaXY0jkxIHmSGp9xUIiyhz8wdoWf3Tp/pBw5MF5nxtnogjyBR VXwRTWmO5nMqlICYY8UEMKQ+Pqh5rDEk4crjfwXlvixc0mKAhzW5uRGQXls7DMfxbz 4EVA6nEikmkcumi+DH0hrlYnBPCKRg24PvOkx05lIODKQm17cs3wZic76/PDoz8K3r iBHwHM1RQPW9QQXvUTEPY5UgCsumOl0QpXqZYsnMDBu21Cj4CV9ftOIEHQCsAL24FZ y2AbvB99MVkhg== Date: Thu, 28 Apr 2022 11:11:04 +0200 (CEST) From: Vincent Ray To: kernelnewbies@kernelnewbies.org Message-ID: <238346256.12547726.1651137064390.JavaMail.zimbra@kalray.eu> Subject: rcu / rcu_bh and ddos MIME-Version: 1.0 X-Originating-IP: [192.168.40.202] X-Mailer: Zimbra 9.0.0_GA_4126 (ZimbraWebClient - FF99 (Linux)/9.0.0_GA_4126) Thread-Index: O4Lsvh/LHItjNhqVIpImug0zUPXFeQ== Thread-Topic: rcu / rcu_bh and ddos X-ALTERMIMEV2_out: done X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============3063142361857366762==" Errors-To: kernelnewbies-bounces@kernelnewbies.org This message is in MIME format. --===============3063142361857366762== Content-Type: multipart/alternative; boundary=secu_57107f860ad3ac3a5c86917075fe5c27_part1 This message is in MIME format. --secu_57107f860ad3ac3a5c86917075fe5c27_part1 Content-Type: text/plain; charset=utf-8 Hello Linux hackers, I was reading some kernel code and documentation, and came to learn about the RCU mechanism. I think I've more or less understood what it is and how it works, but still something puzzles me : Why is the *_bh flavor not used pretty much everywhere ? I mean, at least where the "classic" flavor is used (not dealing with srcu or rcu_sched for now ...) If I undestand well, rcu_read_lock_bh and friends protect us from ddos style attacks where one or more CPUs may loop executing only soft-irqs forever. They do that by : - disabling soft-irqs inside the read-side critical sections - and consider that completing a soft-irq is a transition to quiescent state, in addition to context switching Yet I see that rcu_read_lock is far more employed in the kernel than rcu_read_lock_bh is, the latter being apparently restricted to the net subsystem area. What I don't get is : sure ddos attacks can be related to the net area (e.g. with someone flooding us with small packets), but why would kernel code dealing with other things be immune to such attacks ? I mean : what if some code in the kernel, maybe dealing with the implementation of a particular scall (having nothing to do with the net subsystem), uses rcu_read_lock(), and then our system suffers a ddos attack, leading one of our CPUs to remain in a soft-irq loop forever ? Wouldn't that mean that the thread performing the related synchronize_rcu() would never finish ? And then we would be deadlocked by this ddos attack, although the "victim" rcu was made from a place / on a structure that has nothing to do with the network itself ? Obviously I must be missing something otherwise *_bh would be used everywhere .... Can you enlighten me ? Thanks a lot ! Vincent Ray --secu_57107f860ad3ac3a5c86917075fe5c27_part1 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hello Linux hackers,

I was reading s= ome kernel code and documentation, and came to learn about the RCU mechanis= m.
I think I've more or less understood what it is and how it= works, but still something puzzles me :

Why is the *_bh = flavor not used pretty much everywhere ? I mean, at least where the "classi= c" flavor is used (not dealing with srcu or rcu_sched for now ...)

If I undestand well, rcu_read_lock_bh and friends protect us from= ddos style attacks where one or more CPUs may loop executing only soft-irq= s forever.
They do that by :
- disabling soft-i= rqs inside the read-side critical sections
- and consider tha= t completing a soft-irq is a transition to quiescent state, in addition to = context switching

Yet I see that rcu_read_lock is far mor= e employed in the kernel than rcu_read_lock_bh is, the latter being apparen= tly restricted to the net subsystem area.

What I don't ge= t is : sure ddos attacks can be related to the net area (e.g. with someone = flooding us with small packets), but why would kernel code dealing with oth= er things be immune to such attacks ?
I mean : what if some c= ode in the kernel, maybe dealing with the implementation of a particular sc= all (having nothing to do with the net subsystem), uses rcu_read_lock(), an= d then our system suffers a ddos attack, leading one of our CPUs to remain = in a soft-irq loop forever ?
Wouldn't that mean that the thread p= erforming the related synchronize_rcu() would never finish ?
= And then we would be deadlocked by this ddos attack, although the "victim" = rcu was made from a place / on a structure that has nothing to do with the = network itself ?

Obviously I must be missing something ot= herwise *_bh would be used everywhere ....
Can you enlighten me ?=

Thanks a lot !
<= br>
Vincent Ray
= --secu_57107f860ad3ac3a5c86917075fe5c27_part1-- --===============3063142361857366762== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============3063142361857366762==--