lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101023120426.GN19804@ZenIV.linux.org.uk>
Date:	Sat, 23 Oct 2010 13:04:26 +0100
From:	Al Viro <viro@...IV.linux.org.uk>
To:	Jiri Slaby <jslaby@...e.cz>
Cc:	Greg Kroah-Hartman <gregkh@...e.de>, linux-kernel@...r.kernel.org,
	"Dr. Werner Fink" <werner@...e.de>,
	Alan Cox <alan@...rguk.ukuu.org.uk>
Subject: Re: [PATCH 28/49] tty: Add a new file /proc/tty/consoles

On Sat, Oct 23, 2010 at 12:51:29PM +0100, Al Viro wrote:
> On Sat, Oct 23, 2010 at 01:40:24PM +0200, Jiri Slaby wrote:
> > On 10/22/2010 08:21 PM, Greg Kroah-Hartman wrote:
> > > +/*
> > > + * Used for open /proc/tty/consoles. Before this detect
> > > + * the device ID of file descriptor 0 of the current
> > > + * reading task if a character device...
> > > + */
> > > +static int tty_consoles_open(struct inode *inode, struct file *file)
> > > +{
> > > +	struct files_struct *curfiles;
> > > +
> > > +	current_dev = 0;
> > > +	curfiles = get_files_struct(current);
> > > +	if (curfiles) {
> > > +		const struct file *curfp;
> > > +		spin_lock(&curfiles->file_lock);
> > > +		curfp = fcheck_files(curfiles, 0);
> > > +		if (curfp && curfp->private_data) {
> > > +			const struct inode *inode;
> > > +			dget(curfp->f_dentry);
> > > +			inode = curfp->f_dentry->d_inode;
> > > +			if (S_ISCHR(inode->i_mode)) {
> > > +				struct tty_struct *tty;
> > > +				tty = (struct tty_struct *)curfp->private_data;
> > > +				if (tty && tty->magic == TTY_MAGIC) {
> > 
> > Ah, I've just understood what this code does. It seems, that the 'tty'
> > at this point may be already freed (e.g. people don't set private_data
> > to NULL). Please explain in the code why it can't...
> 
> Please, don't.  Even leaving aside the fact that it's mind-bogglingly
> broken (->private_data can be _ANYTHING_, including arbitrary number cast
> to pointer), you really shouldn't screw your way through the descriptor
> table in the first place.
> 
> Strongly NACKed.

PS: "you" above applies to whoever had produced that patch, of course, not
to Jiri.

PPS: "device name of stdin of last process opening that file, if that
stdin happened to be a tty" is an interesting thing to put into global
variable.  What does one do to it?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ