apparmor: reset pos on failure to unpack for various functions
authorMike Salvatore <mike.salvatore@canonical.com>
Wed, 12 Jun 2019 21:55:14 +0000 (14:55 -0700)
committerJohn Johansen <john.johansen@canonical.com>
Tue, 18 Jun 2019 23:04:16 +0000 (16:04 -0700)
commit156e42996bd84eccb6acf319f19ce0cb140d00e3
treefe4ffed9e345169f3003ef1f898c4bfe7be3729f
parent8404d7a674c49278607d19726e0acc0cae299357
apparmor: reset pos on failure to unpack for various functions

Each function that manipulates the aa_ext struct should reset it's "pos"
member on failure. This ensures that, on failure, no changes are made to
the state of the aa_ext struct.

There are paths were elements are optional and the error path is
used to indicate the optional element is not present. This means
instead of just aborting on error the unpack stream can become
unsynchronized on optional elements, if using one of the affected
functions.

Cc: stable@vger.kernel.org
Fixes: 736ec752d95e ("AppArmor: policy routines for loading and unpacking policy")
Signed-off-by: Mike Salvatore <mike.salvatore@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/policy_unpack.c