public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] vsprintf: ignore %n again
@ 2013-09-16  7:43 Kees Cook
  2013-09-16  7:43 ` [PATCH 1/2] remove all uses of printf's %n Kees Cook
                   ` (2 more replies)
  0 siblings, 3 replies; 46+ messages in thread
From: Kees Cook @ 2013-09-16  7:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: joe, George Spelvin, dan.carpenter, viro, Jan Beulich,
	KOSAKI Motohiro, Tetsuo Handa, akpm

Whether seq_printf should return void or error, %n still needs to be removed.
As such, instead of changing the seq_file structure and adding instructions
to all callers of seq_printf, just examine seq->count for the callers that
care about how many characters were put into the buffer, as suggested by
George Spelvin. First patch removes all %n usage in favor of checking
seq->count before/after. Second patch makes %n ignore its argument.

Testing shows this all works happily, and everything is still getting
padded correctly:

/proc/consoles:
ttyS0                -W- (EC   a)    4:64
netcon0              -W- (E     )

/proc/self/maps:
...
01ee7000-01f08000 rw-p 00000000 00:00 0                                  [heap]
7fdc79bd4000-7fdc79bf6000 r-xp 00000000 fd:01 394247                     /lib/x86_64-linux-gnu/libtinfo.so.5.9
...

/proc/net/tcp
  sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode
   0: 00000000:0016 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 2239 1 ffff88007bfd0000 100 0 0 10 0
...

/proc/net/udp
  sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode ref pointer drops
   12: 0DAAA8C0:D9D1 0100000A:0035 01 00000000:00000000 00:00000000 00000000     0        0 7534 2 ffff880078048000 0


And a test with a %n in a format string shows the warning:

[   10.693638] ------------[ cut here ]------------
[   10.693657] WARNING: CPU: 0 PID: 2048 at lib/vsprintf.c:1693 vsnprintf+0x5c1/0x600()
[   10.693660] Please remove ignored %n in '%n
[   10.693663] '
...

Fixing the other callers of seq_printf to do the right thing (void or not)
can be separate from this series.

-Kees


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

end of thread, other threads:[~2013-09-30  8:18 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-16  7:43 [PATCH 0/2] vsprintf: ignore %n again Kees Cook
2013-09-16  7:43 ` [PATCH 1/2] remove all uses of printf's %n Kees Cook
2013-09-16  8:09   ` Geert Uytterhoeven
2013-09-16 15:00     ` Kees Cook
2013-09-17 13:06       ` Tetsuo Handa
2013-09-17 14:34         ` Kees Cook
2013-09-17 20:57           ` George Spelvin
2013-09-19  8:56             ` Tetsuo Handa
2013-09-19 14:28               ` Kees Cook
2013-09-20  4:09                 ` Tetsuo Handa
2013-09-20  4:23                   ` Joe Perches
2013-09-20  4:53                     ` Kees Cook
2013-09-20  8:08                   ` Jiri Slaby
2013-09-20 19:24                     ` Kees Cook
2013-09-20 19:33                       ` Joe Perches
2013-09-21  0:28                       ` Tetsuo Handa
2013-09-22  8:09                         ` George Spelvin
2013-09-22  8:16                         ` Geert Uytterhoeven
2013-09-23 21:24                   ` Kees Cook
2013-09-30  8:16                     ` Tetsuo Handa
2013-09-16 11:41   ` Tetsuo Handa
2013-09-16 14:59     ` Kees Cook
2013-09-16 15:09       ` Joe Perches
2013-09-16 15:25         ` Kees Cook
2013-09-16 15:44           ` Joe Perches
2013-09-16 17:21         ` George Spelvin
2013-09-16 18:03           ` Joe Perches
2013-09-16 16:07   ` George Spelvin
2013-09-16 16:13     ` Joe Perches
2013-09-16 16:39       ` George Spelvin
2013-09-16 17:53         ` Joe Perches
2013-09-16 19:15           ` George Spelvin
2013-09-16 19:25             ` Joe Perches
2013-09-16  7:43 ` [PATCH 2/2] vsprintf: ignore %n again Kees Cook
2013-09-16 15:55 ` [PATCH 0/2] " Al Viro
2013-09-16 16:15   ` Lars-Peter Clausen
2013-09-16 16:30   ` George Spelvin
2013-09-16 18:20   ` Kees Cook
2013-09-18 13:14     ` Tetsuo Handa
2013-09-18 14:11       ` Dan Carpenter
2013-09-18 14:28         ` Dan Carpenter
2013-09-18 15:22         ` George Spelvin
2013-09-18 14:32       ` Kees Cook
2013-09-19  2:11         ` Tetsuo Handa
2013-09-19  7:08           ` Tetsuo Handa
2013-09-18 14:47       ` Kees Cook

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