All of lore.kernel.org
 help / color / mirror / Atom feed
From: bugzilla-daemon@kernel.org
To: linux-ext4@vger.kernel.org
Subject: [Bug 218830] lseek on closed file does not trigger an error and affect other files
Date: Mon, 13 May 2024 13:24:07 +0000	[thread overview]
Message-ID: <bug-218830-13602-43d0TVLX5P@https.bugzilla.kernel.org/> (raw)
In-Reply-To: <bug-218830-13602@https.bugzilla.kernel.org/>

https://bugzilla.kernel.org/show_bug.cgi?id=218830

Theodore Tso (tytso@mit.edu) changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |tytso@mit.edu
         Resolution|---                         |INVALID

--- Comment #1 from Theodore Tso (tytso@mit.edu) ---
This is a test/programming bug.   If you change reproduce.c so that it prints
fd_a  and fd_b, you'll see that they have the same value.   So the reason why
lseek didn't fail is because fd_a has the same integer value as fd_b --- and so
lseek didn't fail and affected the current position of fd_b.

This is a documented feature of the Linux/Unix/Posix interface.   File
descriptors are small integers, and if you close a file descriptor, it releases
that integer ---- think of it as an index in an array, i.e., struct file
*fd_array[MAX_FDS].   When you call open, it will find the first NULL pointer
in fd_array, and installs a pointer to the struct file, and returns that
integer as the file descriptor.

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

  reply	other threads:[~2024-05-13 13:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-13  2:39 [Bug 218830] New: lseek on closed file does not trigger an error and affect other files bugzilla-daemon
2024-05-13 13:24 ` bugzilla-daemon [this message]
2024-05-13 14:36 ` [Bug 218830] " bugzilla-daemon

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=bug-218830-13602-43d0TVLX5P@https.bugzilla.kernel.org/ \
    --to=bugzilla-daemon@kernel.org \
    --cc=linux-ext4@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.