mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Edward Adam Davis <eadavis@sina.com>,
	syzbot+a31cda410a4ccd419712@syzkaller.appspotmail.com
Cc: axboe@kernel.dk, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] loop: prohibit the use of sysfs as a backing file
Date: Mon, 2 Nov 2026 14:49:19 -0800	[thread overview]
Message-ID: <6682f05e-3568-4414-bbae-44d148f0b979@acm.org> (raw)
In-Reply-To: <20261102103354.427722-1-eadavis@sina.com>

On 11/2/26 2:33 AM, Edward Adam Davis wrote:
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index a3325ceab484..71647793a717 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -534,6 +534,9 @@ static int loop_check_backing_file(struct file *file)
>   	if ((file->f_mode & FMODE_WRITE) && !file->f_op->write_iter)
>   		return -EINVAL;
>   
> +	if (file_inode(file)->i_sb->s_magic == SYSFS_MAGIC)
> +		return -EINVAL;

Recently Christoph Hellwig asked not to make this type of changes. From
https://lore.kernel.org/all/20260601071058.GA7468@lst.de/: "NAK. If
people want to do these stupid things we should allow it. Hardcoding
random superblock magics in random drivers is never a good idea."

The minimal reproducer for the syzbot report is as follows:

mkdirat(AT_FDCWD, "./sys", 0777);
mount(NULL, "./sys", "sysfs", 0, NULL);
r0 = open("/dev/loop0", O_RDWR);
r1 = openat(AT_FDCWD, "./sys/block/loop0/queue/scheduler", O_CREAT | 
O_RDWR, 0777);
ioctl(r0, LOOP_SET_FD, r1);
write(r0, "\x00" /* x 4096 */, 4096);
/* process exit closes r0 */

A possible fix for this syzbot bug report is to extend
loop_validate_file() such that it also refuses to bind loop devices
to sysfs attributes associated to the loop block device.

Bart.

      parent reply	other threads:[~2026-11-02 22:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02  3:47 [syzbot] [block?] INFO: task hung in blk_mq_freeze_queue_nomemsave (3) syzbot
2026-11-02 10:33 ` [PATCH] loop: prohibit the use of sysfs as a backing file Edward Adam Davis
2026-11-02 15:59   ` kernel test robot
2026-11-02 18:36   ` kernel test robot
2026-11-02 22:49   ` Bart Van Assche [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=6682f05e-3568-4414-bbae-44d148f0b979@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=eadavis@sina.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+a31cda410a4ccd419712@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /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®