Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1439923lqm; Thu, 2 May 2024 15:14:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUUk+FkXzFgcvT1TcN8MZFUERzr92CSF1KnOYvNpnhgt2nboYU2B26DUG+a/4ynRcjwi5/GKZ91vqnzKI0JU4HtDxubVn5HvB/xi2oqCg== X-Google-Smtp-Source: AGHT+IHVYnPBKnk2WEmQQGATayq8V5t4WJLWyTqyTrqijIkcr7gevJy8U/OJNCC94n0m0occ6JDP X-Received: by 2002:a92:c541:0:b0:36c:4cbd:ec88 with SMTP id a1-20020a92c541000000b0036c4cbdec88mr1367419ilj.6.1714688084602; Thu, 02 May 2024 15:14:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714688084; cv=pass; d=google.com; s=arc-20160816; b=cPRh5E3i8Emnt10lEPczh/WTI9g9ciHuLUHcmLyb9E/wAtoYxCt1CfN6kcTjc1oxIT U16DAtlcjt2ewLM02ttgbsdyc30AaZqUK086u32MbgxqX6xpjXdX2iJX/kfOSww2nNmt 38v2H21WVnZQgepKZZAFW8LLorot5gBgvRY7zZ8Et10IOTDzNv3BpkUbDTtaPI2lBP91 xGVpBOmTXBNRhWCUtxxt7dV9vSbqhf/YQO1oqIxGcSCh6O98vrO9F2W7JjjvUwUnwhA5 ieMMxVTAdkOI8BSFpZc8GSGxxAYzBn2pNRoWzRrRbsv/dAZDKdHPeF6bL6rtUxc4Hg+L oQsQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=QZy81ykq8OJZJBea1Ve4W5aphIuVf2I+J1Ov16wYfZA=; fh=7mG25O5AVS7u1PtoJuiCGYBo4EtWjQczIA/suoTyFvE=; b=ZuPtNIOSV/TeuQTi1RR4ee5DLYPIruOraWW1TEV5V24V705AlgXUOYbYy1Aw+2qkHW Sg3/rwEuzGfTBKjZTze/jwemHzjsPhCTNh85tCVQM3YFHNg7SgCj3t0vNapSqxelOUt9 Gv31OC7ggwdXcX9mYAOvkMjIYy2bWWv2NKlP3JjHT+iffHdpQ3lRkKHEMaF3iTQRNAvp hxPsR3g1k/nTFH1rCeL795n6q2vChPZ3269gdKfZpaTvCu0by/X8nXX0e6nm06XqJ+Q7 rG10e8pBPtuWvL3IwrriG4AVcFNYvvAqsW6ARQs3DJKvvQsICrLXJeIvAbgCd4p66HNK wc+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=lRMm4d8O; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-166827-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166827-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m65-20020a633f44000000b0061d2394ddcdsi42470pga.724.2024.05.02.15.14.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 15:14:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166827-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=lRMm4d8O; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-166827-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166827-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C326C2885A8 for ; Thu, 2 May 2024 18:15:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B490172BC4; Thu, 2 May 2024 18:14:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="lRMm4d8O" Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF04B16FF2B for ; Thu, 2 May 2024 18:14:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714673697; cv=none; b=qjl+Nh8mLe6Sq3OeA+880HpmuTfEaRBgb/FlhI67oHRz+APcF+PqYRxWeFF7taDcW4crTNVCJsXLyYmgrd1dibk0k9eFH0mqU+/x5Tt2KdA4tZ61v65n1RF0OPSVPIxb5FTkofk1FDs2awRjsndropKlyRo7jaByjUJEsA0/2Fc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714673697; c=relaxed/simple; bh=YoJFzgY7p1NKm94W467Kl9UkLkc4xTsT4UF50wV/ekY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iKymClVvTHLAKDO0BND46eaeEV4U2HTa8xNFmtRUWDNRvSiT3DVFmJHuTXmghJ/VIGbMB8NxDgoQJYCF55KjgyzAMo+PfLK133RU1YsnZ384rn1POyLVETrDqPhPRGlJmkwrtarVzHwsX2pLgBjB5yWKM2fSbfnUI2PMnKXfWDU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=lRMm4d8O; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; 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=QZy81ykq8OJZJBea1Ve4W5aphIuVf2I+J1Ov16wYfZA=; b=lRMm4d8OjpyCEjRGZXYGHj+dLM wACF3cLWIzB/G2qm4snoeoStB+uqqOCwx7AfD4xVG46dwtyR2MjTdz4E+A1VV8EjtFQwYMtlB8Jn5 ujOAr1WE6lxuY+IJB4r2s8lXC/uyWny/lp/DRYkX58vx/pm8dVuqh7xLaWFaiJiXwNftG1Xn/6wWs d7AblKGmlOGbgrhgPKR81uzRC5zFzDplNYrG5NA2hTA9JJxx9hcOdgvSU6RtHcKneKgFAXCczU3l6 2UUCqZWSLtRkkj0RcyEQwrQQYKflgDkBkk4lsNpRjGadv7+9ec8Q1MjM1LC0959WE/3rCoG13/wS+ a3AU1o/g==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1s2axB-009clW-01; Thu, 02 May 2024 18:14:45 +0000 Date: Thu, 2 May 2024 19:14:44 +0100 From: Al Viro To: Linus Torvalds Cc: Tetsuo Handa , Marco Elver , paulmck@kernel.org, Greg Kroah-Hartman , Dmitry Vyukov , syzbot , linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Nathan Chancellor , Arnd Bergmann , Jiri Slaby Subject: Re: [PATCH v3] tty: tty_io: remove hung_up_tty_fops Message-ID: <20240502181444.GF2118490@ZenIV> References: <892324fc-9b75-4e8a-b3b6-cf3c5b4c3506@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro On Thu, May 02, 2024 at 10:29:52AM -0700, Linus Torvalds wrote: > Yes, this is unusual. The *common* thing is to mark pointers as being > volatile. But this really is something entirely different from that. The common thing is to mark pointers are pointers to volatile; calling them "volatile pointers" is common and incorrect, and the only reason why that sloppy turn of phrase persists is that real "volatile pointers" are rare... Marco, struct foo volatile *p; declares p as a (non-volatile) pointer to volatile struct foo. struct foo * volatile p; declares p as volatile pointer to (non-volatile) struct foo. The former is a statement about the objects whose addresses might be stored in p; the latter is a statement about the object p itself. Replace volatile with const and it becomes easier to experiment with: char const *p; char s[] = "barf"; char * const q = s; ... p = "yuck"; - fine, p itself can be modified *p = 'a'; - error *p can not be modified, it's an l-value of type const char q = s + 1; - error, can't modify q *q = 'a'; - fine, *q is l-value of type char p = q; - fine, right-hand side of assignment loses the top qualifier, so q (const pointer to char as l-value) becomes a plain pointer to char, which can be converted to pointer to const char, and stored in p (l-value of type pointer to const char) strlen(q); - almost the same story, except that it's passing an argument rather than assignment; they act the same way. strcpy(q, "s"); - almost the same, except that here the type of argument is pointer to char rather than pointer to const char (strlen() promises not to modify the string passed to it, strcpy() obviously doesn't) strcpy(p, "s"); - error; pointer to char converts to a pointer to const char, but not the other way round. The situations where you want a const (or volatile) pointer (as opposed to pointer to const or volatile object) are rare, but this is exactly what you are asking for - you want to say that the value of 'f_op' member in any struct file can change at any time. That value is an address of some instance of struct file_operations and what you want to express is the property of f_op member itself, not that of the objects whose addresses might end up stored there. So having a driver do const struct file_operations *ops = file->f_op; is fine - it's basically "take the value of 'file'; it will be an address of some struct file instance. Fetch 'f_op' from that instance, without any assumptions of the stability of that member. Use whatever value you find there as initial value of 'ops'". That's fine, and since nobody is going to change 'ops' itself behind your back, you don't need any qualifiers on it. The type of 'ops' here is "(unqualified) pointer to const struct file_operations".