Date: Fri, 30 Aug 2019 12:47:48 -0700 From: Kees Cook <keescook@...omium.org> To: Dave Chinner <david@...morbit.com> Cc: Jason Yan <yanaijie@...wei.com>, kernel-hardening@...ts.openwall.com, linux-fsdevel@...r.kernel.org Subject: Re: CONFIG_HARDENED_USERCOPY On Fri, Aug 30, 2019 at 02:29:58PM +1000, Dave Chinner wrote: > On Thu, Aug 29, 2019 at 09:15:36AM -0700, Kees Cook wrote: > > On Thu, Aug 29, 2019 at 08:42:30PM +0800, Jason Yan wrote: > > > We found an issue of kernel bug related to HARDENED_USERCOPY. > > > When copying an IO buffer to userspace, HARDENED_USERCOPY thought it is > > > illegal to copy this buffer. Actually this is because this IO buffer was > > > merged from two bio vectors, and the two bio vectors buffer was allocated > > > with kmalloc() in the filesystem layer. > > > > Ew. I thought the FS layer was always using page_alloc? > > No, they don't. It's perfectly legal to use heap memory for bio > buffers - we've been doing it since, at least, XFS got merged all > those years ago. Okay, so I have some observations/thoughts about this: - This "cross allocation merging" is going to continue being a problem in the future when we have hardware-backed allocation tagging (like ARM's MTE). It'll be exactly the same kind of detection: a tagged pointer crossed into a separately allocated region and access through it will be rejected. - I don't think using _copy_to_user() unconditionally is correct here unless we can be absolutely sure that the size calculation really was correct. (i.e. is the merge close enough to the copy that the non-merge paths don't lose the validation?) - If this has gone until now to get noticed (hardened usercopy was introduced in v4.8), is this optimization (and, frankly, layering violation) actually useful? - We could just turn off allocation merging in the face of having hardened usercopy or allocation tagging enabled... -- Kees Cook
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.