public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* Missing Null Pointer check in seq_open
@ 2026-03-05  9:57 Rohit
  2026-04-09  9:14 ` Al Viro
  0 siblings, 1 reply; 2+ messages in thread
From: Rohit @ 2026-03-05  9:57 UTC (permalink / raw)
  To: linux-fsdevel

Hi,

I would like to report a missing NULL pointer check in the fs/seq_file.c APIs.

The seq_open(struct file *file, const struct seq_operations *op) function
does not check whether the second argument is NULL or not.

Other functions, such as seq_read_iter(), directly dereference seq_operations
pointers, possibly resulting in a kernel NULL pointer dereference.

ssize_t seq_read_iter(struct kiocb *iocb, struct iov_iter *iter)
{
struct seq_file *m = iocb->ki_filp->private_data;
....
....

p = m->op->start(m, &m->index);
....
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Missing Null Pointer check in seq_open
  2026-03-05  9:57 Missing Null Pointer check in seq_open Rohit
@ 2026-04-09  9:14 ` Al Viro
  0 siblings, 0 replies; 2+ messages in thread
From: Al Viro @ 2026-04-09  9:14 UTC (permalink / raw)
  To: Rohit; +Cc: linux-fsdevel

On Thu, Mar 05, 2026 at 03:27:08PM +0530, Rohit wrote:
> Hi,
> 
> I would like to report a missing NULL pointer check in the fs/seq_file.c APIs.
> 
> The seq_open(struct file *file, const struct seq_operations *op) function
> does not check whether the second argument is NULL or not.
> 
> Other functions, such as seq_read_iter(), directly dereference seq_operations
> pointers, possibly resulting in a kernel NULL pointer dereference.

It also does not verify that argument is not (void *)0x6969696969696969
and passing that would lead to massive clusterfuck in aforementioned
seq_read_iter().  Your point being...?

Should we check that caller is not passing BS values to arguments to functions
and if we should, where do we stop?

Why is NULL any different from e.g. ERR_PTR(-ENOMEM) in that respect?  Or from
any random invalid value, for that matter?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-09  9:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05  9:57 Missing Null Pointer check in seq_open Rohit
2026-04-09  9:14 ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox