Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp32335689rwd; Fri, 7 Jul 2023 12:09:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlHU+iC/9iaYPH62gRjc2LnDKBQCXvUpKwCRMrFkeg0gWi0g9LaPVFixwmW+DzTexCsVBHl4 X-Received: by 2002:a05:6830:10c:b0:6b5:d364:6238 with SMTP id i12-20020a056830010c00b006b5d3646238mr6335468otp.35.1688756991226; Fri, 07 Jul 2023 12:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688756991; cv=none; d=google.com; s=arc-20160816; b=zBzkunnGrBQhf/Cja0BAJpB5MDu8BJf3/lmIfKCfACaOfalmqfEX2RpKk19z8LsVee ITP/qsSRZ2OKgaUmTGCmlvQwy3hvvuuE3Mv9K+9IEUZAICt9bBN4Hfq+0fCKweQUB1iA LfJmUIP0tZKU8DB+LbhOohBY5fZNJ84SGKh+Jc+lP1d8YWqUvZ8AoTBanKfVLfTOv/SL Qk5vNhp6mmcgjvb3jsjdivS+uzHwmC72Tdb8wVuJ0F2Sx3fm8d5/c1Q9af2ZE49wNpmO gCW+esqmL/pgWH0IdNgVODMSEqSrYfy0LlEl7Ob+6M6YZ0wd9g1ClFF2YjCobkQBZgAO K+iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=iKKhHf4vxup8Dipa1rYXDF76sBEYhb1cNBcsVojkLVg=; fh=3yzGdWwN0VULAxM4B0NLev2gFfh1j/LoIgPAT6HgP4s=; b=j8F+ZpgtLzKfZNgOX4lzvrURo+4PXneSzGISXy1Wb8hKpaRq5AQGjMjAU9fxisPyXp EV94wkYj3FcNScv3iowA0kw9kAp/h6cMEjRO+Tlcxwzono/FJEYRodT+3bsjXNhh8IT5 h9sUm9OKpyNKpE7hvPfHgKXvqQ8jjMyRXjFL+auFdhoQUZkPcwX6VcaeFlUCEHNfeQta RTo7VR/Ui06JB8auNxEiSXjC1gkpvAAzknIXdNLGAoWya8D7F2i3ZPNe+WZC+Ga0JVDE HV2JIlTI5E8ZCE1WLue04wnhuk8pbn/rShAtluJU9qjrhINhmdpBF9eyENijFpg9dUEQ DZ4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=1Y8zfepe; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a654145000000b005573b42d9e3si4376198pgp.593.2023.07.07.12.09.38; Fri, 07 Jul 2023 12:09:51 -0700 (PDT) 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; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=1Y8zfepe; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231845AbjGGS44 (ORCPT + 99 others); Fri, 7 Jul 2023 14:56:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbjGGS4x (ORCPT ); Fri, 7 Jul 2023 14:56:53 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6295C10C; Fri, 7 Jul 2023 11:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=iKKhHf4vxup8Dipa1rYXDF76sBEYhb1cNBcsVojkLVg=; b=1Y8zfepe1HJaB2bncP9IilTchy XCv61wfpmXga1uA8Crnf9g52NAmOUgaNJSgXd48VbP+c4aYnZJzGMBL2UlxkKY+wY+wu045TIhXS1 JTDh0hsNwCuUqqlmnf3xoy+E6nlepQkL9zcwiBVQsL9zCVf1c7zBPtxq3KUt9gGLVae37lxLH6xiv XiND/Kl7cDK+rkZWi+ZH9Of9s2k/8++XAPtFUhw4cKlLx8QobWgyGprzCcdiWMEjmL0PIeppGGqkV i8wEnfIRcLJy0NqO75bwOT25b5EQB6Rk7Gox7tAeGGERaFzijHOVyzL3oqKuB9MBGDzSrpMDMkfQs qNnwc2xA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1qHqdN-005TDU-0T; Fri, 07 Jul 2023 18:56:49 +0000 Date: Fri, 7 Jul 2023 11:56:49 -0700 From: Luis Chamberlain To: Michal Hocko Cc: Jean Delvare , linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] module: print module name on refcount error Message-ID: References: <20230626123252.73dbc139@endymion.delvare> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Luis Chamberlain X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 On Mon, Jul 03, 2023 at 03:47:22PM +0200, Michal Hocko wrote: > On Fri 30-06-23 16:05:33, Luis Chamberlain wrote: > [...] > > What prevents code from racing the free with a random module_put() > > called by some other piece of code? > > Wouldn't be ref count a garbage already? How can you race when freeing > if module_put fail? It could yes, ie, so this risks at all being junk. So best IMHO is to tidy up all the get / puts and add respective tests to fix all this mess with proper messages as needed. My cursory review of the refcnt stuf is I see some races possible. While I'd be happy to help debugging aids, adding accesses to random memory for a string seems more risk prone. Luis