mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Timber <dxdt@dev.snart.me>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/char/mem.c: fix null and zero dev lseek
Date: Sun, 22 Mar 2026 22:20:34 +0900	[thread overview]
Message-ID: <c7b6c6ee-9d8b-4f18-844f-6916e6173cd2@dev.snart.me> (raw)
In-Reply-To: <559131c2-99da-4f3f-9243-0d027de398f8@dev.snart.me>

On 3/22/26 20:52, David Timber wrote:
>> Where does POSIX require this to happen for these device nodes?
> It is inferred from the fact that the offsets to SEEK_DATA and SEEK_HOLE
> cannot be the same. Ever.
>> You just changed how userspace reacts to this, are you SURE that is
>> going to be ok?
> As far as I'm concerned, yes /I/ am sure. As outlined above, the start
> of a hole and data cannot be the same.
On the second thought, one possible scenario where the offsets to hole
and data being the same would be a TOCTOU condition where a hole has
been dug in between lseek() calls. Either way, that means the file is
being manipulated by multiple processes so in fallocate's case, it might
as well just terminate prematurely to be on the safe side.

btw, I don't maintain util-linux, so I'd just like to mention that it's
up to the maintainers to decide. In addition to that, other sparse-aware
userspace tools like compression filter, tar, and rsync always lstat()
before doing anything "sparse". The kernel returning EINVAL is more for
extereme edge cases like fallocate(to prevent such programs from
shooting themselves in the foot).
>> And if you really want to do this, shouldn't you
>> explicitly list what options you are going to return an error for, not
>> the other way around in this switch statement?
> Sure. See rerolled.
I just removed the confusing comments and made the function use one
return statement. We could do other errnos as per POSIX spec, but to be
honest, EINVAL should suffice. I get the gist of where you were getting
at - /dev/null isn't really the scope of POSIX so technically Linux
could do whatever.

I wouldn't complicate things. It's a simple dev node. So keep the code
simple?

Davo

      reply	other threads:[~2026-03-22 13:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20  4:17 David Timber
2026-03-20  6:02 ` Greg KH
2026-03-22 11:52   ` [PATCH v1] " David Timber
2026-03-22 11:52   ` [PATCH] " David Timber
2026-03-22 13:20     ` David Timber [this message]

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=c7b6c6ee-9d8b-4f18-844f-6916e6173cd2@dev.snart.me \
    --to=dxdt@dev.snart.me \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®