linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] namei: fix use-after-free and adjust calling conventions
@ 2021-09-08  0:04 Stephen Brennan
  2021-09-08  0:04 ` [PATCH v3 1/4] namei: Fix use after free in kern_path_locked Stephen Brennan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Stephen Brennan @ 2021-09-08  0:04 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-fsdevel, linux-kernel, Stephen Brennan

Currently filename_parentat() is inherently buggy, and results in a
use after free bug. But removing it and renaming __filename_parentat()
destroys its symmetry with the other functions:

   __filename_create   filename_create()
   __filename_lookup   filename_lookup()

The ones with leading double-underscores do not free their struct
filename arguments, while the ones without double-underscores always do.

I looked at the callers of filename_create and filename_lookup. All are
small functions which are trivial to modify to include a putname(). It
seems to me that adding a few more lines to these functions is a good
traedoff for better clarity on lifetimes (as it's uncommon for functions
to drop references to their parameters) and better consistency.

This small series fixes the UAF and makes it so all three families of
functions have just one variation, which does *not* free its pathname
arguments.

v3: Split patch 1 into a fix and a rename
v2: Fix double getname in user_path_create()

Stephen Brennan (4):
  namei: Fix use after free in kern_path_locked
  namei: Rename __filename_parentat()
  namei: Standardize callers of filename_lookup()
  namei: Standardize callers of filename_create()

 fs/fs_parser.c |   1 -
 fs/namei.c     | 125 ++++++++++++++++++++++++++-----------------------
 2 files changed, 67 insertions(+), 59 deletions(-)

-- 
2.30.2


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

end of thread, other threads:[~2021-09-08  0:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-08  0:04 [PATCH v3 0/4] namei: fix use-after-free and adjust calling conventions Stephen Brennan
2021-09-08  0:04 ` [PATCH v3 1/4] namei: Fix use after free in kern_path_locked Stephen Brennan
2021-09-08  0:04 ` [PATCH v3 2/4] namei: Rename __filename_parentat() Stephen Brennan
2021-09-08  0:04 ` [PATCH v3 3/4] namei: Standardize callers of filename_lookup() Stephen Brennan
2021-09-08  0:04 ` [PATCH v3 4/4] namei: Standardize callers of filename_create() Stephen Brennan

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 NNTP newsgroup(s).