public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: "Theodore Ts'o" <tytso@mit.edu>, наб <nabijaczleweli@nabijaczleweli.xyz>
Cc: Federico Vaga <federico.vaga@vaga.pv.it>,
	Alex Shi <alexs@kernel.org>, Yanteng Si <siyanteng@loongson.cn>,
	Hu Haowen <src.res@email.cn>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-doc-tw-discuss@lists.sourceforge.net
Subject: Re: [PATCH 1/5] tty: remove TTY_MAGIC
Date: Fri, 16 Sep 2022 10:45:50 +0200	[thread overview]
Message-ID: <682df554-0602-2f94-22d1-e39a4dd8f366@kernel.org> (raw)
In-Reply-To: <YyQm4dBVyvefVcAd@mit.edu>

On 16. 09. 22, 9:33, Theodore Ts'o wrote:
> On Fri, Sep 16, 2022 at 03:54:59AM +0200, наб wrote:
>> According to Greg, in the context of magic numbers as defined in
>> magic-number.rst, "the tty layer should not need this and I'll gladly
>> take patches"
>>
>> Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
> 
> Well, I would disagree with Greg K-H on this --- but I haven't been
> tty maintainer in well over a decade.  Assuming code is Bug-Free(tm),
> sure, it's not necessary.  But there is any kind of memory bug (e.g.,
> a corrupted pointer,

I don't think it can help with corrupted pointer much, but:

> a use-after free, some other structure
> corruption), this catches the problem earlier rather than later, and
> it's a light-weight to do a quick sanity check.

Although it's light-weight, it's also NOT that useful. Maybe tty 
_userspace_ functions return EIO, but that's about it (kernel does not 
check magic in any of its code paths, if I am looking correctly). I bet 
users would notice a corrupted tty structure even without this, and 
maybe earlier. And in that case, kmemcheck is next on the list. And that 
tells us much more than "we are corrupted".

> It has certainly caught problems in the past, and I still use this
> programming technique in programs that I do maintain, such as
> e2fsprogs.

Asking google about:
"tty_paranoia_check" "bad magic number"
gives ~149 results, the last one from 2008. And it seems to be the only 
report, the others are links to sources. So yes, it triggered at least 
once, but is it that useful? Looking at the results, I don't think so.

thanks,
-- 
js
suse labs


  reply	other threads:[~2022-09-16  8:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16  1:54 [PATCH 1/5] tty: remove TTY_MAGIC наб
2022-09-16  1:55 ` [PATCH 2/5] tty: remove TTY_DRIVER_MAGIC наб
2022-09-16  6:51   ` Jiri Slaby
2022-09-16  1:55 ` [PATCH 3/5] tty: n_hdlc: remove HDLC_MAGIC наб
2022-09-16  6:51   ` Jiri Slaby
2022-09-16  1:55 ` [PATCH 4/5] tty: synclink_gt: remove MGSL_MAGIC наб
2022-09-16  6:52   ` Jiri Slaby
2022-09-16  1:55 ` [PATCH 5/5] tty: hvc: remove HVC_IUCV_MAGIC наб
2022-09-16  6:52   ` Jiri Slaby
2022-09-16  6:51 ` [PATCH 1/5] tty: remove TTY_MAGIC Jiri Slaby
2022-09-16  7:33 ` Theodore Ts'o
2022-09-16  8:45   ` Jiri Slaby [this message]
2022-09-22 14:12 ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=682df554-0602-2f94-22d1-e39a4dd8f366@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=alexs@kernel.org \
    --cc=federico.vaga@vaga.pv.it \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-doc-tw-discuss@lists.sourceforge.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nabijaczleweli@nabijaczleweli.xyz \
    --cc=siyanteng@loongson.cn \
    --cc=src.res@email.cn \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox