Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3240259rwb; Tue, 8 Nov 2022 02:09:16 -0800 (PST) X-Google-Smtp-Source: AMsMyM5WxQFAWheVvmAFwdtDOm0qdFpi8PZlgq3L/hFqPGOVlp42dsCWN6e9/7gOvGYdZA92vhOW X-Received: by 2002:a17:906:2a93:b0:78d:b87e:6aab with SMTP id l19-20020a1709062a9300b0078db87e6aabmr52950090eje.157.1667902156697; Tue, 08 Nov 2022 02:09:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667902156; cv=none; d=google.com; s=arc-20160816; b=BPuYoCTb9kjDEQ3FuAZYeHA5vunhuZGaXgNCFsH0r2XKOKIYWN9VusJaLocjWvWdW0 KIoDKPP60n5Eb+c0dwYeceQMGE5v8qaaYaLum4ZE436a9T2Hd43BWdYKCCgYMl5rE2N2 6l/r6KZjMQv6ehqkXcCeLswH3K/7nGwJ373rCrH5Og9lgUME4I75fLtpoybxbp6lfU6V ukcA9PawR46C06r5WAQOFTshPlvr8EdM3bZLbFwTow9ykcxrITledzmrgfE1HO0yukkO IrMM7A4bWwJx9WmlUBMBm4Z05UyFxwEmbNfvoukmFvLZfixhuCLstBKHlduBBlA+lGhY L8Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=CluqCX0ADFrDDZQq6xryf7aa0ohvzHoVZtL9VKxko5A=; b=IR/VUoyGHzKos+rdXaBWHn8ocn1TCzfefweah5ukal675r51AiQLfG61cZ2OZwU3M9 5gU/rQizTC4iGUtHxpezoq0fiLdPzV8XQYSWTCqnw+j6BuYoB4hp0SBHHJdEUQyXR7mo k+JMDnA3Kh6zJdHfolaPOVyCRBg2Y2TO1K9dpIS7otf8ytApBfX28d6QRFXaNv/+zwf8 /BzdUJUkc3xcgJwkA0h9YLWifueCvJdUJpXHs6HLAXoLhgiy7/A17YPtLt2Oz4pbYgLb mTwNXoiX98o1bS2jeyhLrDWYgXGvDI3p6B3PazpYlC92NO+5oG2Q8fOZh8J/nK8ndhx4 1EXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020a05640250cc00b00461891a8138si12636149edb.446.2022.11.08.02.08.48; Tue, 08 Nov 2022 02:09:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233612AbiKHJ0O convert rfc822-to-8bit (ORCPT + 89 others); Tue, 8 Nov 2022 04:26:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233578AbiKHJ0M (ORCPT ); Tue, 8 Nov 2022 04:26:12 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E88227DD1 for ; Tue, 8 Nov 2022 01:26:11 -0800 (PST) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-275-iyhD-bNnNIqZzr0HEwK7vA-1; Tue, 08 Nov 2022 09:26:08 +0000 X-MC-Unique: iyhD-bNnNIqZzr0HEwK7vA-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Tue, 8 Nov 2022 09:26:07 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.042; Tue, 8 Nov 2022 09:26:07 +0000 From: David Laight To: 'Jann Horn' , Kees Cook , "linux-hardening@vger.kernel.org" , "kernel-hardening@lists.openwall.com" CC: Greg KH , Linus Torvalds , Seth Jenkins , "Eric W . Biederman" , Andy Lutomirski , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] exit: Put an upper limit on how often we can oops Thread-Topic: [PATCH] exit: Put an upper limit on how often we can oops Thread-Index: AQHY8uVtJeqm4QnZJEegjt8nfpQUG640wW1Q Date: Tue, 8 Nov 2022 09:26:06 +0000 Message-ID: <3e2f7e2cb4f6451a9ef5d0fb9e1f6080@AcuMS.aculab.com> References: <20221107201317.324457-1-jannh@google.com> In-Reply-To: <20221107201317.324457-1-jannh@google.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jann Horn > Sent: 07 November 2022 20:13 > > Many Linux systems are configured to not panic on oops; but allowing an > attacker to oops the system **really** often can make even bugs that look > completely unexploitable exploitable (like NULL dereferences and such) if > each crash elevates a refcount by one or a lock is taken in read mode, and > this causes a counter to eventually overflow. > > The most interesting counters for this are 32 bits wide (like open-coded > refcounts that don't use refcount_t). (The ldsem reader count on 32-bit > platforms is just 16 bits, but probably nobody cares about 32-bit platforms > that much nowadays.) > > So let's panic the system if the kernel is constantly oopsing. I think you are pretty much guaranteed to run out of memory (or at least KVA) before any 32bit counter wraps. That is probably even harder to diagnose than a refcount wrap! David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)