Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1577639
| From | David Laight <David.Laight@ACULAB.COM> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | RE: [PATCH] block: sed-opal: reduce stack size of ioctl handler |
| Date | 2017-02-09 15:30 +0100 |
| Message-ID | <t8XTr-7gc-11@gated-at.bofh.it> (permalink) |
| References | <t8HOG-5t6-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Arnd Bergmann
> Sent: 08 February 2017 21:15
>
> When CONFIG_KASAN is in use, the sed_ioctl function uses unusually large stack,
> as each possible ioctl argument gets its own stack area plus redzone:
Why not do a single copy_from_user() at the top of sed_ioctl() based on
the _IOC_DIR() and __IOC_SIZE() values?
Something like:
int sed_ioctl(..., unsigned int cmd, void __user *arg)
{
u64 buf[??]; /* or a union */
unsigned int cmd_sz = _IOC_SIZE(cmd);
if (_IOC_DIR(cmd) & (_IOC_WRITE | _IOC_READ) && cmd_sz > sizeof buf)
return -EINVAL;
if (_IOC_DIR(cmd) & _IOC_WRITE) {
if (copy_from_user(buf, arg, cmd_sz))
return -EFAULT;
} else {
if (IOC_DIR(cmd) & _IOC_READ))
memzero(buf, cmd_sz);
}
switch (cmd) {
...
rval = ...
...
}
if (rval >= 0 && (_IOC_DIR(cmd) & _IOC_READ)
&& copy_to_user(arg, buf, cmd_sz));
return -EFAULT;
return rval;
}
David
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] block: sed-opal: reduce stack size of ioctl handler Arnd Bergmann <arnd@arndb.de> - 2017-02-08 22:20 +0100
Re: [PATCH] block: sed-opal: reduce stack size of ioctl handler Scott Bauer <scott.bauer@intel.com> - 2017-02-08 23:30 +0100
Re: [PATCH] block: sed-opal: reduce stack size of ioctl handler Arnd Bergmann <arnd@arndb.de> - 2017-02-09 16:00 +0100
Re: [PATCH] block: sed-opal: reduce stack size of ioctl handler Scott Bauer <scott.bauer@intel.com> - 2017-02-08 23:40 +0100
RE: [PATCH] block: sed-opal: reduce stack size of ioctl handler David Laight <David.Laight@ACULAB.COM> - 2017-02-09 15:30 +0100
csiph-web