Re: Kernel panic at Ubuntu: IMA + Apparmor

Mimi Zohar
2014-04-29T13:01:10Z

My apologies for those receiving this post a 2nd time. The original
post never made it the mailing lists ...

On Fri, 2014-04-25 at 15:25 -0700, Eric W. Biederman wrote:
> Al Viro <viro@ZenIV.linux.org.uk> writes:
>
> > On Fri, Apr 25, 2014 at 02:43:42PM -0700, Eric W. Biederman wrote:
> >
> >> ssize_t __vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
> >> {
> >> ssize_t ret;
> >>
> >> if (!(file->f_mode & FMODE_READ))
> >> return -EBADF;
> >> if (!file->f_op->read && !file->f_op->aio_read)
> >> return -EINVAL;
> >> if (unlikely(!access_ok(VERIFY_WRITE, buf, count)))
> >> return -EFAULT;
> >>
> >> if (ret >= 0) {
> >> count = ret;
> >> if (file->f_op->read)
> >> ret = file->f_op->read(file, buf, count, pos);
> >> else
> >> ret = do_sync_read(file, buf, count, pos);
> >> }
> >>
> >> return ret;
> >> }
> >
> > ... which lacks the f_pos wraparound, etc. checks done by rw_verify_area().
> > IOW, it's one more place to grep through while verifying that ->read()
> > et.al. do not get called with such arguments.
>
> Agreed it must be done more delicately than my sketch. I am not
> familiar with how much value such sanity checks add. Especially when
> the read is not coming from a potentially hostile userspace.

Sorry for the delay in commenting, imap problems. This sounds like a
plausible solution, similar to __vfs_setxattr_noperm() vs.
__vfs_setxattr().

> > fanotify probably could be skipped - ask the security circus crowd about
> > that one, it's their bast^Wbaby.
>
> When the point is having a factor of read that skips the security circus
> I think it makes sense to skip this too. At least as a starting
> position.

Right, fsnotify*() is meant for userspace access, not kernel access.
CC'ing Eric Paris for comment.

> > add_rchar() and inc_syscr()... depends on
> > whether you want those reads hidden from accounting.
>
> I doubt it matters in practice, the code is cheap.
>
> Still it feels wrong to account reads to a task that did not ask for
> them. It feels more correct to account that kind of read into a
> different bucket. Say the reads performed by the kernel for mysterious
> kernel activities.

Ok. So who are the interested parties that need to be included in this
discussion?

thanks,

Mimi