Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7045266rwb; Mon, 12 Dec 2022 09:21:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf5/Wpkr33cgD/p3KgGxTOFI6TTFQduMD8t9pp4KP35bwM/yc+UOpeZTt0kV0cb2gb4XIDce X-Received: by 2002:a17:906:6711:b0:79e:4880:dd85 with SMTP id a17-20020a170906671100b0079e4880dd85mr13069749ejp.47.1670865696214; Mon, 12 Dec 2022 09:21:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670865696; cv=none; d=google.com; s=arc-20160816; b=h+3E5+TvBl0DSnAw5F6KNfrl4iUvyJuXwh/MOldsawv9dB/ZzP6eOU6c9WDbOHUf3R PPbD+KlPUoNap7BkXLYR6uBWWeSJPtHgNApEfDNAvYQYwORDB6wLvtiQ34FLtSC29eiZ kfrlqGnyRve+0SRhUbULlgxkBbzVkKn6Dw/lixCAcLNTgbU3+k1SUiTmKUhbMsh4Azfe w1HNdhZCSkMWyZLoQOBW6M6ToMh1Lr9bm2nWJph4MG/USUr4S7ksRZX/EpDdBZ9dymKZ eepDaQAzRhAbS9J870twg/3aRBW6KHcDOWyszDr67wHBQFgu8a03E/PxgCCqzCSa88Jr IJzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=ENszuHhuwShU0H5MaBl+dngBL/+ZgtAFKMkUaCSUi9E=; b=URlDA9VQSoMbmlULPWQuy9+xgZ5yCmugYjVcoo/5k3oUtllk2YWfRS0wXQ+VfdcECJ 23O7gRgy1y5MSeby6PIrlrNUGyT+z15+wL1BhXOC8e5fmx7lPq5D3BCiCBJ64eX4pwhb vox3r0fM0OXPvSJVxy1S8oz+xHIOPybQKiS79QkCUTdurvfZ+u+mG+H7MSBpVkT5hkqv /JQejQOHzQahuyqIdB0HoWPukrwRr00glh4hG5tZEhISXIZ7R9+Axw1w4hjuNirU3Orz dmCSD0+h4DOri/4Ld7trqHp6ctjRMnfRys11juaKv7Q14LDYXqV/d/hvHVxCn8wj8Zt/ XdiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YzEMZW4Y; 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 wu9-20020a170906eec900b007ad96737de4si6737660ejb.624.2022.12.12.09.21.17; Mon, 12 Dec 2022 09:21:36 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YzEMZW4Y; 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 S232706AbiLLRI2 (ORCPT + 75 others); Mon, 12 Dec 2022 12:08:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232537AbiLLRIX (ORCPT ); Mon, 12 Dec 2022 12:08:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05A9726E6; Mon, 12 Dec 2022 09:08:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 967C060F1A; Mon, 12 Dec 2022 17:08:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1462C433D2; Mon, 12 Dec 2022 17:08:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670864902; bh=2ahBXUJDAK2WR3lhgschSHf1DqybChKQYpTaViFEUFI=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=YzEMZW4YK13QRhfLLVHauaj5+qXYPAZCMdfk/G4b2C57WLp8hl/3qUB23QATOJeev r/FLXZYpLUHF03IBD4PMGBV5zvq0THkMjRWcz4XMx4Qf7cLf2nbx6/7oXGBLwu6x49 ArDeMJsChUFK+CIhkngu+3EsuRQKCHt4PrsiUwM2+DlTjGdu68ngLjW8VQlsWrfOdt wKSu2Xr5hJoQ7ba+3Q5WrfZnGRUQg3t0XwWDlFGeRmQ1lX8oytYhZOmEGmZqtGXQ9m 3lMR6rT1TlbENUP5r/Zz9kxHPGDwB6B0g+AGeHKo8hk9IQHz7rGTjJEhczpgX525Ew /okYoikCnvTZA== Date: Mon, 12 Dec 2022 18:08:20 +0100 (CET) From: Jiri Kosina To: Benjamin Tissoires cc: Greg KH , Jonathan Corbet , Shuah Khan , Alexei Starovoitov , Tero Kristo , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH hid v12 05/15] HID: bpf jmp table: simplify the logic of cleaning up programs In-Reply-To: Message-ID: References: <20221103155756.687789-1-benjamin.tissoires@redhat.com> <20221103155756.687789-6-benjamin.tissoires@redhat.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Mon, 12 Dec 2022, Benjamin Tissoires wrote: > If I compile the kernel with LLVM=1, the function > bpf_prog_put_deferred() is optimized in a weird way: if we are not in > irq, the function is inlined into __bpf_prog_put(), but if we are, the > function is still kept around as it is called in a scheduled work item. > > This is something I completely overlooked: I assume that if the function > would be inlined, the HID entrypoint BPF preloaded object would not be > able to bind, thus deactivating HID-BPF safely. But if a function can be > both inlined and not inlined, then I have no guarantees that my cleanup > call will be called. Meaning that a HID device might believe there is > still a bpf function to call. And things will get messy, with kernel > crashes and others. > > An easy "fix" would be to tag bpf_prog_put_deferred() with "noinline", > but it just feels wrong to have that for this specific reason. > > AFAICT, gcc is not doing that optimisation, but nothing prevents it > from doing it, and suddenly that will be a big whole in the kernel. It's not doing it on this particular function, but in general it's actually quite common for gcc to inline a function in some callsites and leave it out-of-line in others (we are dealing with that in livepatching), so I agree it has to be taken into account irrespective of the compiler used. > As much as I wish I had another option, I think for the sake of everyone > (and for my future holidays) I'll postpone HID-BPF to 6.3. Thanks, -- Jiri Kosina SUSE Labs