Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1720791

Re: [PATCH] of: do not leak console options

From Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] of: do not leak console options
Date 2017-08-27 10:10 +0200
Message-ID <uj0NP-50d-5@gated-at.bofh.it> (permalink)
References <uiqU2-71g-5@gated-at.bofh.it> <uivqG-1qN-1@gated-at.bofh.it> <uj0b8-4uh-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On (08/27/17 16:19), Sergey Senozhatsky wrote:
[..]
> int uart_parse_earlycon(char *p, unsigned char *iotype, resource_size_t *addr,
> 			char **options)
> {
> 	if (strncmp(p, "mmio,", 5) == 0) {
> 		*iotype = UPIO_MEM;
> 		p += 5;
> 	} else if (strncmp(p, "mmio16,", 7) == 0) {
> 		*iotype = UPIO_MEM16;
> 		p += 7;
> 	} else if (strncmp(p, "mmio32,", 7) == 0) {
> 		*iotype = UPIO_MEM32;
> 		p += 7;
> 	} else if (strncmp(p, "mmio32be,", 9) == 0) {
> 		*iotype = UPIO_MEM32BE;
> 		p += 9;
> 	} else if (strncmp(p, "mmio32native,", 13) == 0) {
> 		*iotype = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) ?
> 			UPIO_MEM32BE : UPIO_MEM32;
> 		p += 13;
> 	} else if (strncmp(p, "io,", 3) == 0) {
> 		*iotype = UPIO_PORT;
> 		p += 3;
> 	} else if (strncmp(p, "0x", 2) == 0) {
> 		*iotype = UPIO_MEM;
> 	} else {
> 		return -EINVAL;
> 	}
> 
> 	/*
> 	 * Before you replace it with kstrtoull(), think about options separator
> 	 * (',') it will not tolerate
> 	 */
> 	*addr = simple_strtoull(p, NULL, 0);
> 	p = strchr(p, ',');
> 	if (p)
> 		p++;
> 
> 	*options = p;
> 	return 0;
> }
> 
> that's just one example I found after a very quick grepping. may be
> there are other control paths that can change ->options.

well, obviously, it doesn't change the options per se, but it sort of
demonstrates that _probably_ somewhere ->options could be changed. on
the other hand, that ->options = ->options + X makes it rather hard
to kfree() the ->options. well, we never kfree() the ->options anyway,
as far as I can tell...

	-ss

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] of: do not leak console options Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2017-08-25 19:50 +0200
  Re: [PATCH] of: do not leak console options Rob Herring <robh@kernel.org> - 2017-08-26 00:40 +0200
    Re: [PATCH] of: do not leak console options Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2017-08-27 09:30 +0200
      Re: [PATCH] of: do not leak console options Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2017-08-27 10:10 +0200
      Re: [PATCH] of: do not leak console options Petr Mladek <pmladek@suse.com> - 2017-09-06 14:50 +0200
        Re: [PATCH] of: do not leak console options Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-09-06 15:40 +0200
          Re: [PATCH] of: do not leak console options Rob Herring <robh@kernel.org> - 2017-09-06 17:30 +0200
            Re: [PATCH] of: do not leak console options Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-09-07 12:10 +0200

csiph-web