mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Kees Cook <keescook@chromium.org>
Cc: David Miller <davem@davemloft.net>,
	LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	George Spelvin <linux@horizon.com>, Jiri Kosina <jkosina@suse.cz>,
	Jan Beulich <jbeulich@suse.com>,
	Eldad Zack <eldad@fogrefinery.com>
Subject: Re: [PATCH] vsprintf: drop comment claiming %n is ignored
Date: Wed, 11 Sep 2013 13:20:22 -0700	[thread overview]
Message-ID: <1378930822.4714.22.camel@joe-AO722> (raw)
In-Reply-To: <CAGXu5jKRmp_Ei=ty05W3SSqQ01agEMDVMGnZCFqQ_yYbZmMSmw@mail.gmail.com>

On Wed, 2013-09-11 at 13:18 -0700, Kees Cook wrote:
> On Wed, Sep 11, 2013 at 1:06 PM, Joe Perches <joe@perches.com> wrote:
> > On Wed, 2013-09-11 at 12:30 -0700, Kees Cook wrote:
> >> The %n format is not ignored, so remove the incorrect comment about it.
> >
> > I think it may be better to reimplement the ignoring.
> 
> Yeah, just had a quick look, and scanf doesn't use this code at all.
> I'd much rather remove %n again instead.
> 
> > Maybe:
> > ---
> >  lib/vsprintf.c      | 18 +++++-------
> >  net/ipv4/fib_trie.c | 30 +++++++++----------
> >  net/ipv4/ping.c     | 19 ++++++------
> >  net/ipv4/tcp_ipv4.c | 84 ++++++++++++++++++++++++++---------------------------
> >  net/ipv4/udp.c      | 19 ++++++------
> >  net/phonet/socket.c | 32 ++++++++++----------
> >  net/sctp/objcnt.c   |  5 ++--
> >  7 files changed, 99 insertions(+), 108 deletions(-)
> 
> This needs fs/proc/consoles.c, nommu.c, task_mmu.c, and task_nommu.c
> added too, if I can believe my "git grep".

Yeah, just found those too.
---
 fs/proc/consoles.c   |  2 +-
 fs/proc/nommu.c      | 20 ++++++++++----------
 fs/proc/task_mmu.c   | 18 +++++++++---------
 fs/proc/task_nommu.c | 20 ++++++++++----------
 4 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/fs/proc/consoles.c b/fs/proc/consoles.c
index b701eaa..42f2bb7 100644
--- a/fs/proc/consoles.c
+++ b/fs/proc/consoles.c
@@ -47,7 +47,7 @@ static int show_console_dev(struct seq_file *m, void *v)
 			con_flags[a].name : ' ';
 	flags[a] = 0;
 
-	seq_printf(m, "%s%d%n", con->name, con->index, &len);
+	len = seq_printf(m, "%s%d", con->name, con->index);
 	len = 21 - len;
 	if (len < 1)
 		len = 1;
diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
index ccfd99b..91cfd19 100644
--- a/fs/proc/nommu.c
+++ b/fs/proc/nommu.c
@@ -50,16 +50,16 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
 		ino = inode->i_ino;
 	}
 
-	seq_printf(m,
-		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
-		   region->vm_start,
-		   region->vm_end,
-		   flags & VM_READ ? 'r' : '-',
-		   flags & VM_WRITE ? 'w' : '-',
-		   flags & VM_EXEC ? 'x' : '-',
-		   flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
-		   ((loff_t)region->vm_pgoff) << PAGE_SHIFT,
-		   MAJOR(dev), MINOR(dev), ino, &len);
+	len = seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
+			 region->vm_start,
+			 region->vm_end,
+			 flags & VM_READ ? 'r' : '-',
+			 flags & VM_WRITE ? 'w' : '-',
+			 flags & VM_EXEC ? 'x' : '-',
+			 flags & VM_MAYSHARE ?
+			 flags & VM_SHARED ? 'S' : 's' : 'p',
+			 ((loff_t)region->vm_pgoff) << PAGE_SHIFT,
+			 MAJOR(dev), MINOR(dev), ino);
 
 	if (file) {
 		len = 25 + sizeof(void *) * 6 - len;
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 107d026..f84ee9f 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -286,15 +286,15 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
 	if (stack_guard_page_end(vma, end))
 		end -= PAGE_SIZE;
 
-	seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
-			start,
-			end,
-			flags & VM_READ ? 'r' : '-',
-			flags & VM_WRITE ? 'w' : '-',
-			flags & VM_EXEC ? 'x' : '-',
-			flags & VM_MAYSHARE ? 's' : 'p',
-			pgoff,
-			MAJOR(dev), MINOR(dev), ino, &len);
+	len = seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
+			 start,
+			 end,
+			 flags & VM_READ ? 'r' : '-',
+			 flags & VM_WRITE ? 'w' : '-',
+			 flags & VM_EXEC ? 'x' : '-',
+			 flags & VM_MAYSHARE ? 's' : 'p',
+			 pgoff,
+			 MAJOR(dev), MINOR(dev), ino);
 
 	/*
 	 * Print the dentry name for named mappings, and a
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 56123a6..1d7bbe5 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -155,16 +155,16 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
 		pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
 	}
 
-	seq_printf(m,
-		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
-		   vma->vm_start,
-		   vma->vm_end,
-		   flags & VM_READ ? 'r' : '-',
-		   flags & VM_WRITE ? 'w' : '-',
-		   flags & VM_EXEC ? 'x' : '-',
-		   flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
-		   pgoff,
-		   MAJOR(dev), MINOR(dev), ino, &len);
+	len = seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
+			 vma->vm_start,
+			 vma->vm_end,
+			 flags & VM_READ ? 'r' : '-',
+			 flags & VM_WRITE ? 'w' : '-',
+			 flags & VM_EXEC ? 'x' : '-',
+			 flags & VM_MAYSHARE ?
+			 flags & VM_SHARED ? 'S' : 's' : 'p',
+			 pgoff,
+			 MAJOR(dev), MINOR(dev), ino);
 
 	if (file) {
 		pad_len_spaces(m, len);



  reply	other threads:[~2013-09-11 20:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-11 19:30 Kees Cook
2013-09-11 20:06 ` Joe Perches
2013-09-11 20:18   ` Kees Cook
2013-09-11 20:20     ` Joe Perches [this message]
2013-09-11 20:30       ` KOSAKI Motohiro
2013-09-11 20:28     ` Joe Perches
2013-09-13 19:53       ` George Spelvin
2013-09-13 22:27         ` Joe Perches
2013-09-13 23:03           ` Kees Cook
2013-09-13 23:23             ` Joe Perches
2013-09-16  2:53               ` George Spelvin
2013-09-14  2:17             ` Al Viro
2013-09-14  2:49             ` Tetsuo Handa
2013-09-14  3:05               ` Al Viro
2013-09-14  3:48                 ` Al Viro
2013-09-14  4:53                   ` Al Viro
2013-09-14  5:26                     ` Joe Perches
2013-09-12  7:03     ` Jan Beulich
2013-09-12  7:31       ` Kees Cook
2013-09-12  7:51         ` Jan Beulich
2013-09-12  7:57       ` Dan Carpenter
2013-09-13 19:49       ` George Spelvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1378930822.4714.22.camel@joe-AO722 \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=eldad@fogrefinery.com \
    --cc=jbeulich@suse.com \
    --cc=jkosina@suse.cz \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@horizon.com \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®