From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D834C636D4 for ; Mon, 6 Feb 2023 18:01:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230257AbjBFSB0 (ORCPT ); Mon, 6 Feb 2023 13:01:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230183AbjBFSBZ (ORCPT ); Mon, 6 Feb 2023 13:01:25 -0500 Received: from mail-vs1-xe32.google.com (mail-vs1-xe32.google.com [IPv6:2607:f8b0:4864:20::e32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC70423131 for ; Mon, 6 Feb 2023 10:01:23 -0800 (PST) Received: by mail-vs1-xe32.google.com with SMTP id cz15so3924767vsb.6 for ; Mon, 06 Feb 2023 10:01:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=AovKaYugu50S/f2B978nfmPElm2qMfvoOhokNIP847U=; b=Ops+BJewCRfpBNkWE2t9Nd5h3no2SfuN3xwaX1TPK17nLkUHjJ3d6qCUhmeR6TLOvl KA54u85d7dGY47W0sc1bbgfNIoJdTUXmNTtAPVGRmpeebPedSU5vbnPrvFGWrjDsGQj6 51RKB7l7V3IkE4HUiCwKYm54PVbKp4yKd2nrVDaYfVQfZ76abEKE7a57EH6YHOwAA1oK Blh1XWA+FDzOHH5AYRImKlyKFzaQYVx1YS/A7rkygkrXiQzufHKC//xyDzr8/sNqtStU YOBsUyQ6ODVeEnwY8aR3gy0QByrfgxsVbH4vO1bM3hyfrLYrLp5QKSdBosSKs8Z+YY5o hYtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AovKaYugu50S/f2B978nfmPElm2qMfvoOhokNIP847U=; b=3Gp/tWwJqX7jlxfJWwYu+UaqHmXQNU+bPYtwccQrMquUkfY955hk7/gTxfNTh5e1xA EqrjA7zTwurFd7Sn83xDG1eD6MLIKRcvibO3PU6tEsKmHwe9kDRXlvXxm1QS395BUw7r zdPDf6WJFKei83a5nlIVLrDRXAPTznWJjQdMtG4XqaS7A6P3VIcS16L/+ffZYyWM1+JT KulnycHSEB2AF5KRFeNSA2WCjCOjm1A23His+acKCNU/L1J5XTxCCaMVYGTxbaiRP25/ VUMmZAEzmIm+d3zZzXSyi2aLxnd65oMq5aMTrmwSpTCar7/cx5mrlGFdOLr0mMVcjaiL Sp4Q== X-Gm-Message-State: AO0yUKUCFWwgKexetR3QiI+T/uJYD6P2rHP0Mw96oRW2BnRxXQa1FksF TjOj1KQkpa91c649ZR6vhYSESxS+1z5OgGh2uZ8Zig== X-Google-Smtp-Source: AK7set+9Li15tr3aRCwXnHOJLd/UXJaDEEQSZ2h6RaR4pJm9jBZirB4qGtMmATBxRr5/jYOOz8wpY/MDTGP5DA9dKGk= X-Received: by 2002:a67:c908:0:b0:408:6a8f:d1c6 with SMTP id w8-20020a67c908000000b004086a8fd1c6mr97061vsk.73.1675706482791; Mon, 06 Feb 2023 10:01:22 -0800 (PST) MIME-Version: 1.0 References: <20230118134940.240102-1-brgl@bgdev.pl> <20230206155107.qwf5tbrqsbvv4hln@pengutronix.de> In-Reply-To: <20230206155107.qwf5tbrqsbvv4hln@pengutronix.de> From: Bartosz Golaszewski Date: Mon, 6 Feb 2023 19:01:11 +0100 Message-ID: Subject: Re: [PATCH v3] i2c: dev: don't allow user-space to deadlock the kernel To: =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 6, 2023 at 4:51 PM Uwe Kleine-K=C3=B6nig wrote: > > Hello, > > ah, this is the mail I missed before. > > On Wed, Jan 25, 2023 at 11:11:59PM +0100, Wolfram Sang wrote: > > > > > So, this code handled all my stress-testing well so far. I'll try to > > > think of some more ideas until this evening, but likely I will apply = it > > > later. Nonetheless, more review eyes are still welcome! > > > > Ah yes, I now recalled why I had the gut feeling that this solution is > > not complete. See this mail thread from 2015: > > > > https://lkml.iu.edu/hypermail/linux/kernel/1501.2/01700.html > > > > There are still drivers using i2c_del_adapter()+kfree(), so removing th= e > > completion could cause use-after-free there, or? > > There is also a strange construct in spi that I understand at one point > in time, but I failed to swap it in quickly. It's about commit > 794aaf01444d4e765e2b067cba01cc69c1c68ed9. I think there should be a > nicer solution than to track if the controller was allocated using devm, > but I don't remember the details. But before addressing the i2c problem > it might be worth to invest some time into that spi issue to not make > the same mistake for i2c. > Yeah, I've seen these constructs before elsewhere... Sadly, we have workarounds upon workarounds within workarounds chased by other workarounds due to this issue. Bart