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]
Date:	Sat, 23 Oct 2010 13:24:47 +0200
From:	Jiri Slaby <jslaby@...e.cz>
To:	Greg Kroah-Hartman <gregkh@...e.de>
CC:	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 10/22/2010 08:21 PM, Greg Kroah-Hartman wrote:
> --- a/fs/proc/proc_tty.c
> +++ b/fs/proc/proc_tty.c
...
> @@ -137,6 +140,160 @@ static const struct file_operations proc_tty_drivers_operations = {
>  };
>  
>  /*
> + * The device ID of file descriptor 0 of the current reading
> + * task if a character device...
> + */
> +static dev_t current_dev;
> +
> +/*
> + * This is the handler for /proc/tty/consoles
> + */
> +static int show_console_dev(struct seq_file *m, void *v)
> +{
> +	const struct tty_driver *driver;
> +	struct console *con;
> +	int index, len;
> +	char flags[10];
> +	dev_t dev;
> +
> +	if (v == SEQ_START_TOKEN)
> +		return 0;
> +	con = (struct console *)v;

You don't hold the console sem now, so the console may be already gone,
right? You should hold the sem from ->start till ->stop.

> +	if (!con)
> +		return 0;
> +	driver = con->device(con, &index);

Some consoles, especially the early ones don't have con->device IIRC.
If, for some reason, they are not switched to proper ttyS* (e.g. the
port fails to init), this will crash.

> +	if (!driver)
> +		return 0;
> +	dev = MKDEV(driver->major, driver->minor_start) + index;
> +
> +	index = 0;
> +	if (con->flags & CON_ENABLED)
> +		flags[index++] = 'E';
> +	if (con->flags & CON_CONSDEV)
> +		flags[index++] = 'C';
> +	if (con->flags & CON_BOOT)
> +		flags[index++] = 'B';
> +	if (con->flags & CON_PRINTBUFFER)
> +		flags[index++] = 'p';
> +	if (con->flags & CON_BRL)
> +		flags[index++] = 'b';
> +	if (con->flags & CON_ANYTIME)
> +		flags[index++] = 'a';
> +	if (current_dev == dev)
> +		flags[index++] = '*';
> +	flags[index] = 0;
> +
> +	seq_printf(m, "%s%d%n", con->name, con->index, &len);
> +	len = 21 - len;
> +	if (len < 1)
> +		len = 1;
> +	seq_printf(m, "%*c", len, ' ');
> +	seq_printf(m, "%c%c%c (%s)%n", con->read ? 'R' : '-',
> +			con->write ? 'W' : '-', con->unblank ? 'U' : '-',
> +			flags, &len);
> +	len = 13 - len;
> +	if (len < 1)
> +		len = 1;
> +	seq_printf(m, "%*c%4d:%d\n", len, ' ', MAJOR(dev), MINOR(dev));
> +
> +	return 0;
> +}

regards,
-- 
js
suse labs
--
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