Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1170693lqm; Thu, 2 May 2024 07:15:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVatYZFILr0m6fGYJJrwWJ+cgVkCvlCMwvop86ICiOgCFmlD4UGqlqXev5hIo6c6dVUqC4dtyfTLlKLsrNsuUTzwJVAHPsy0vV6EnB8KA== X-Google-Smtp-Source: AGHT+IFaG83IXFEkVCkOBNX3GtIk5O2akSZGoOBcyesCFM8RH9xJWRTmvcrGIy9j6nhPturOLV8T X-Received: by 2002:a17:906:300e:b0:a59:732a:159c with SMTP id 14-20020a170906300e00b00a59732a159cmr834918ejz.31.1714659315833; Thu, 02 May 2024 07:15:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714659315; cv=pass; d=google.com; s=arc-20160816; b=UrBtFX/whshrAh4IUSZIuva5/Jsmz+q8J35nELp0G12//IjdGw+pG/3QuWM9a4F+Jl 3IeEJO5QoS7yS9yOh/A5npa2Ht0J64PHo15NddtzJ0ZcBNsb/2CWsbLhxASQsAI6FmcV dKiaLml3JcXvJxmiWOn6TXvEVjppvGMUW2PCpwmVIFq4GC9PgZTSxbEbJBwtynMit0Vp QipaM08zoHem4YvhpOd+UjxciiGBNj0OwZ7EPSGPagNiF8lYHOxoDL9BBFGXckQm3Y6H 0nFdpV+Hkar4JN4agVJoNH91/zcA+4WrRdTiCssZL9WKAmxcg6k61nIENwJWMI4d4h6s MgxA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=3X7xru1omPYA6l4R3nqNUFsGsK7E2fsHc6EKFxBQBYc=; fh=fzy3UOLY2XENKtBV3QqxPbn+XA7ovv4gUuUPiKaxS+I=; b=ve3PBr+HIoDosoCH3hTqamtlxz/uQtBR2VZ7CAaXb8cm6QpAkaJ74v/Suj8oQMpwjV Uo9qzJQ1bGMLkymJPVe4+JbA4YPHS5N2+CsfZ7cDu2wE4iCYGT4rR1ShjjVirGZqovtm XXY/gngNtiZmMjLVXQixxFk6YeQA4Ffn46Ga4v9U1H5EAODXmxRBOlbE2gcXmeWftMyW fkx+wDh4agvrNrC0VU4FYma+y2il616iDG6th1893yXPuzblEHpP4Dk0k3bPpMtf6HB3 U+4PAkc8HzOK20Y2h0YnuM2MMASFhrmPyLvx4r2OnsFRuS5etbl9Q8YUh6QcBizRph5y FpQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=bSoaFphU; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-166548-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166548-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bv21-20020a170906b1d500b00a51d7203458si533856ejb.778.2024.05.02.07.15.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 07:15:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166548-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=bSoaFphU; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-166548-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166548-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8CCA11F24D9B for ; Thu, 2 May 2024 14:15:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5534B13C69B; Thu, 2 May 2024 14:15:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bSoaFphU" Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D878C13C692 for ; Thu, 2 May 2024 14:15:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714659307; cv=none; b=sHIHE8j5c9n9Hzw5WAD9n3hrVaCGDmqTNGfmEC3guE6JouaWy/smK+1zIHPxvvxI5N0fLJO7UsTB2ycpcJG32vErmmrYvtCi3B6kWnx/R9srAri7draWXVntr7+0/m3fMzArSKIVCSIQF3puKMeo2fcPB5K9VX6LPMgqzvuOtH4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714659307; c=relaxed/simple; bh=X25at9+jpvUR/gjEBumSvhwcXP2ZqF5tD9Lgc/oVnvk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=kV/0zp7Z+ddFoEJq7UP3aOiZv0xpC4LJ3UuGwvKsfwQx2bnOa/a6z6zvQ0pswvFYO1RmudN28iYRPT9FREEpFeUpO1oHTX0G7QUJRBpMPWHpDYZPw5cNeAMqBQPISn4RQlYrENbXTzV19Ryd1Cpt5+9Ff5Ruzll5lassTI/kyQo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=bSoaFphU; arc=none smtp.client-ip=209.85.208.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2df9af57b5eso79019871fa.2 for ; Thu, 02 May 2024 07:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714659304; x=1715264104; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=3X7xru1omPYA6l4R3nqNUFsGsK7E2fsHc6EKFxBQBYc=; b=bSoaFphUiOer7DVUxk/yuIQjhhEbJsJrmTDQBbW56uIbS0WPbqCCM5a66AZCPiipYa IsM0eoPUzaCkpCDhilc63QX9bx8NvXO2rloEGHQ9EpSD7At2lnfljl19rJHY5Obsr8Sf Ua0Sx4ynwJlnnSfle/AH5mfUOAiU2s9KspRdXioPgEe/6vm2n/vUpK38k4tg5o8oc8ck rQ0Fbnn3bRaDqL5SY+PtltapJC6bEIE1G7z5+HMVRcJZZk+91EQPSCVpde/ihGzFi7U9 MSfhsEXTPboQ6xKShYacfb8EjUZTFk4HwSEocpJpcvkBwKFddh/d6YHgv8UbVrmGx9dn z5wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714659304; x=1715264104; h=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=3X7xru1omPYA6l4R3nqNUFsGsK7E2fsHc6EKFxBQBYc=; b=fuf8ehgETIsQdatSSnFGNDEFu6rpn0Ln2r0UG/xiMATRz/TsHIBdlyB2pFaI5mHuoE fQBHrNTOkERPFDOoMjaYDuG9Yb3eQT7QMS6ae51cdviqO7R3Z2Rdk2YY47uX+OTxMUYW Zsv4IEt2bqZ2vBWGFOGX0L9ufGeuR9EZsd8/HEE4sjW25RUvPlXZQ9/Tynfvl8qbrLpa g+aUwFj8MlteJs1jZ+NQznnxV3YCmkzqBD+0bTU/TAX8fDuxh2HhwFN4DNm+fPt4OQ+8 MG3yrTViQoQ+chBdCfDI9xsP0ft2TyZPm/KN7zxAO7e3V8ufnuNRjrAOpIlK5qVZeJMK l7rg== X-Forwarded-Encrypted: i=1; AJvYcCXLgin7EnkXJ1RXbsFc33c7HisVMR5prWilaHSpEhs/cECDZkuhe+NVWU8l43dWBKIrh6smBATVInuxHFA0joJvSgP0WjRhMAkuxu/R X-Gm-Message-State: AOJu0Yzi6B7fNxqAHBwGaTqoGTt4Ow40T1XyMqjum/JIbf7IufU0ibn2 8YHCooP2yE/CKQJ2lX4MEzLYtk6Rr5FbwVVZeaWPC6I+OXCXjFYiWIP+G4Ab6bLUKAJpFAAcYko honydXw+1nJV5FfE6GAHjxkMf1Hdh9Pz3VH2i X-Received: by 2002:a2e:bc1c:0:b0:2d6:e295:e81f with SMTP id b28-20020a2ebc1c000000b002d6e295e81fmr2291285ljf.35.1714659303881; Thu, 02 May 2024 07:15:03 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <8edbd558-a05f-c775-4d0c-09367e688682@I-love.SAKURA.ne.jp> <2023053048-saved-undated-9adf@gregkh> <18a58415-4aa9-4cba-97d2-b70384407313@I-love.SAKURA.ne.jp> <892324fc-9b75-4e8a-b3b6-cf3c5b4c3506@paulmck-laptop> In-Reply-To: From: Marco Elver Date: Thu, 2 May 2024 16:14:23 +0200 Message-ID: Subject: Re: [PATCH v3] tty: tty_io: remove hung_up_tty_fops To: Linus Torvalds Cc: paulmck@kernel.org, Tetsuo Handa , Greg Kroah-Hartman , Dmitry Vyukov , syzbot , linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Nathan Chancellor , Arnd Bergmann , Al Viro , Jiri Slaby Content-Type: text/plain; charset="UTF-8" On Wed, 1 May 2024 at 23:06, Linus Torvalds wrote: > On Wed, 1 May 2024 at 13:15, Marco Elver wrote: > > > > This is relatively trivial: > > > > #ifdef __SANITIZE_THREAD__ > > #define __data_racy volatile > > #endif > > I really wouldn't want to make a code generation difference, but I > guess when the sanitizer is on, the compiler generating crap code > isn't a huge deal. > > > In some cases it might cause the compiler to complain if converting a > > volatile pointer to a non-volatile pointer > > No. Note that it's not the *pointer* that is volatile, it's the > structure member. > > So it would be something like > > const struct file_operations * __data_racy f_op; > > and only the load of f_op would be volatile - not the pointer itself. > > Of course, if somebody then does "&file->f_op" to get a pointer to a > pointer, *that* would now be a volatile pointer, but I don't see > people doing that. This is the case I thought of. I still think everything is working as intended then, since passing a pointer to a __data_racy variable should be done with pointers to __data_racy (just like other type qualifiers - the rules are by virtue of implementation equivalent to volatile). Not a problem, just an observation. > So I guess this might be a way forward. Anybody want to verify? I sent a patch to add the type qualifier - in a simple test I added it does what we want: https://lore.kernel.org/all/20240502141242.2765090-1-elver@google.com/T/#u I'll leave it to Tetsuo to amend the original patch if __data_racy makes sense. Thanks, -- Marco > Now, the "hung_up_tty_fops" *do* need to be expanded to have hung up > ops for every op that is non-NULL in the normal tty ops. That was a > real bug. We'd also want to add a big comment to the tty fops to make > sure anybody who adds a new tty f_op member to make sure to populate > the hung up version too. > > Linus