From: Michael Buesch <mbuesch@freenet.de>
To: linux kernel mailing list <linux-kernel@vger.kernel.org>
Cc: andrea@e-mind.com
Subject: sys_swapoff() symlink bug
Date: Mon, 15 Mar 2004 19:52:05 +0100 [thread overview]
Message-ID: <200403151952.17430.mbuesch@freenet.de> (raw)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
The following script demonstrates a bug in the swapon/swapoff
syscalls in the latest 2.6 kernel (I did not check 2.4).
#/bin/sh
# 3:12 is hda12, which is a swap partition on my system.
SWAP_MAJOR=3
SWAP_MINOR=12
echo "running swaps:"
cat /proc/swaps
echo "--"
mkdir /testdev
mknod /testdev/testnode b $SWAP_MAJOR $SWAP_MINOR
ln -s /testdev/testnode /testdev/testlink
swapon /testdev/testlink
echo "swapon returned $?"
echo "running swaps:"
cat /proc/swaps
echo "--"
swapoff /testdev/testdev
echo "swapoff returned $?"
echo "running swaps:"
cat /proc/swaps
echo "--"
rm -Rf /testdev
The output of this script on my system is:
running swaps:
- --
swapon returned 0
running swaps:
Filename Type Size Used Priority
/testdev/testnode partition 976712 0 -32
- --
swapoff returned 255
running swaps:
Filename Type Size Used Priority
/testdev/testnode partition 976712 0 -32
- --
As you can see the swapoff fails, because it is called on
the node instead of the symlink that was used for swapon.
I think this should not fail.
The code that fails to detect, that the symlink _is_ actually
the same swapspace as the node itself, is mm/swapfile.c:1038
for (type = swap_list.head; type >= 0; type = swap_info[type].next) {
p = swap_info + type;
if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) {
/* I'm not really sure about what we should check here, instead
* of f_mapping to detect it.
*/
if (p->swap_file->f_mapping == mapping)
break;
}
prev = type;
}
- --
Regards Michael Buesch [ http://www.tuxsoft.de.vu ]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAVftgFGK1OIvVOP4RAqMeAKCa8YNIziH6/HCYLjTxg98MBzUE+wCgv6pw
qUptbBGt+jCXeDdJpQk71l4=
=+JkD
-----END PGP SIGNATURE-----
reply other threads:[~2004-03-15 18:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200403151952.17430.mbuesch@freenet.de \
--to=mbuesch@freenet.de \
--cc=andrea@e-mind.com \
--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®