Linux filesystem development
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: "张子勋(Zhang Zixun)" <zhangzixun1@oppo.com>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: DoS in lseek inodes with proc_ops
Date: Mon, 18 Sep 2023 12:59:47 +0300	[thread overview]
Message-ID: <fe27461f-69ef-41aa-bc8c-6e3fbb7f67ee@p183> (raw)
In-Reply-To: <SEZPR02MB70394C03FD07798864962C7C8EFBA@SEZPR02MB7039.apcprd02.prod.outlook.com>

On Mon, Sep 18, 2023 at 07:39:51AM +0000, 张子勋(Zhang Zixun) wrote:
> Hi,
> There is a null pointer dereference DoS issue when I use lseek syscall to inode with proc_ops.
> I find the root cause is https://lore.kernel.org/all/YFYX0Bzwxlc7aBa%2F@localhost.localdomain/ .
> In this patch, the lseek syscall is set to mandatory. So, if proc_lseek is not set in proc_ops, pde->proc_ops->proc_lseek will get a null pointer.
> I want to know why all inode in proc need to set its own lseek, and why set default_llseek in pde_lseek isn’t a good idea?
> By the way, although every inode need set a lseek to use lseek syscall, lseek to a inode without lseek should get a fail return and the kernel should’t panic.

It removes 1 branch and make code smaller too.
You can switch to nonseekable_open() if you don't need lseeks.

           reply	other threads:[~2023-09-18 10:00 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <SEZPR02MB70394C03FD07798864962C7C8EFBA@SEZPR02MB7039.apcprd02.prod.outlook.com>]

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=fe27461f-69ef-41aa-bc8c-6e3fbb7f67ee@p183 \
    --to=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zhangzixun1@oppo.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