linux-hexagon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek-IBi9RG/b67k@public.gmane.org>
To: Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Cc: Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	Maninder Singh
	<maninder1.s-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	bcain-jfJNa2p1gH1BDgjK7y7TUQ@public.gmane.org,
	mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org,
	benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org,
	paulus-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org,
	hca-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org,
	gor-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org,
	agordeev-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org,
	borntraeger-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org,
	svens-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org,
	satishkh-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org,
	sebaddel-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org,
	kartilak-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org,
	jejb-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org,
	martin.petersen-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
	mcgrof-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	jason.wessel-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org,
	daniel.thompson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	naveen.n.rao-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org,
	anil.s.keshavamurthy-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
	mhiramat-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
	mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	will-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	boqun.feng-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org,
	senozhatsky-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
	linux-qQsb+v5E8BnlAoU/VqSP6n9LOBIZ5rWg@public.gmane.org
Subject: Re: [PATCH 0/5] kallsyms: make kallsym APIs more safe with scnprintf
Date: Wed, 15 Jun 2022 10:01:57 +0200	[thread overview]
Message-ID: <YqmR9ZeiwMQLyKDu@alley> (raw)
In-Reply-To: <202205231238.FAF6D28@keescook>

On Mon 2022-05-23 12:39:12, Kees Cook wrote:
> On Sat, May 21, 2022 at 11:07:52PM -0700, Christoph Hellwig wrote:
> > On Fri, May 20, 2022 at 02:06:56PM +0530, Maninder Singh wrote:
> > > kallsyms functionality depends on KSYM_NAME_LEN directly.
> > > but if user passed array length lesser than it, sprintf
> > > can cause issues of buffer overflow attack.
> > > 
> > > So changing *sprint* and *lookup* APIs in this patch set
> > > to have buffer size as an argument and replacing sprintf with
> > > scnprintf.
> > 
> > This is still a pretty horrible API.  Passing something like
> > a struct seq_buf seems like the much better API here.  Also with
> > the amount of arguments and by reference passing it might be worth
> > to pass them as a structure while you're at it.
> 
> Yeah, I agree. It really seems like seq_buf would be nicer.

There is a new patchset that is trying to use this kind of buffer
in vsprintf.

It introduces another buffer struct because vsprintf() needs a bit
different semantic than the one used in seq_buf. But it actually
replaces seq_buf() in the end. I am not sure if this is the right
approach.

Anyway, the initial API is very simple, see
https://lore.kernel.org/r/20220604193042.1674951-2-kent.overstreet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

And it makes the internal vsprintf() API more sane, see
https://lore.kernel.org/r/20220604193042.1674951-4-kent.overstreet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

It would eventually solve also concerns about the kallsysms API.
Any comments on the new printbuf API are much appreaciated.

Best Regards,
Petr

      reply	other threads:[~2022-06-15  8:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20220520083715epcas5p400b11adef4d540756c985feb20ba29bc@epcas5p4.samsung.com>
2022-05-20  8:36 ` [PATCH 0/5] kallsyms: make kallsym APIs more safe with scnprintf Maninder Singh
     [not found]   ` <CGME20220520083725epcas5p1c3e2989c991e50603a40c81ccc4982e0@epcas5p1.samsung.com>
2022-05-20  8:36     ` [PATCH 1/5] kallsyms: pass buffer size in sprint_* APIs Maninder Singh
2022-05-20 19:52       ` Waiman Long
2022-05-22  9:43         ` Andy Shevchenko
     [not found]   ` <CGME20220520083733epcas5p4ff2414309bf128f40b0bbd3adde52297@epcas5p4.samsung.com>
2022-05-20  8:36     ` [PATCH 2/5] kallsyms: replace sprintf with scnprintf Maninder Singh
     [not found]   ` <CGME20220520083742epcas5p4fa741caf7079a1305ef99cf00a07054a@epcas5p4.samsung.com>
     [not found]     ` <20220520083701.2610975-1-maninder1.s-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2022-05-20  8:36       ` [PATCH 3/5] arch:hexagon/powerpc: use KSYM_NAME_LEN as array size Maninder Singh
2022-05-20  8:37       ` [PATCH 4/5] kallsyms: pass buffer size argument in *lookup* APIs Maninder Singh
     [not found]   ` <CGME20220520083805epcas5p40642f5a7f9844c61792cd3ac41ac01d3@epcas5p4.samsung.com>
2022-05-20  8:37     ` [PATCH 5/5] kallsyms: remove unsed API lookup_symbol_attrs Maninder Singh
2022-05-22  6:07   ` [PATCH 0/5] kallsyms: make kallsym APIs more safe with scnprintf Christoph Hellwig
2022-05-23 19:39     ` Kees Cook
2022-06-15  8:01       ` Petr Mladek [this message]

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=YqmR9ZeiwMQLyKDu@alley \
    --to=pmladek-ibi9rg/b67k@public.gmane.org \
    --cc=agordeev-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
    --cc=andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=anil.s.keshavamurthy-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=bcain-jfJNa2p1gH1BDgjK7y7TUQ@public.gmane.org \
    --cc=benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org \
    --cc=boqun.feng-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=borntraeger-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
    --cc=daniel.thompson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=gor-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
    --cc=hca-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
    --cc=hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=jason.wessel-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org \
    --cc=jejb-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
    --cc=kartilak-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org \
    --cc=keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=linux-qQsb+v5E8BnlAoU/VqSP6n9LOBIZ5rWg@public.gmane.org \
    --cc=longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=maninder1.s-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=martin.petersen-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=mcgrof-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=mhiramat-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org \
    --cc=naveen.n.rao-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
    --cc=paulus-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org \
    --cc=peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org \
    --cc=satishkh-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org \
    --cc=sebaddel-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org \
    --cc=senozhatsky-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=svens-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
    --cc=will-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).