Skip to content

Commit

Permalink
ANDROID: check dir value of xfrm_userpolicy_id
Browse files Browse the repository at this point in the history
Check user provided dir value to prevent out-of-bound access
which may occur if dir is not less than XFRM_POLICY_MAX.

(url: http://seclists.org/bugtraq/2017/Jul/30)

Bug: 64257838
Signed-off-by: Suren Baghdasaryan <[email protected]>
Change-Id: I5bbdf95e14a61bdf5207977d9a5a4465bc848da0
Signed-off-by: Francisco Franco <[email protected]>
  • Loading branch information
surenbaghdasaryan authored and franciscofranco committed Dec 9, 2017
1 parent 1018630 commit 14bf23b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions net/xfrm/xfrm_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,10 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb,
struct sk_buff *skb;
int err;

err = verify_policy_dir(dir);
if (err)
return ERR_PTR(err);

skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!skb)
return ERR_PTR(-ENOMEM);
Expand Down Expand Up @@ -2092,6 +2096,10 @@ static int xfrm_do_migrate(struct sk_buff *skb, struct nlmsghdr *nlh,
int err;
int n = 0;

err = verify_policy_dir(pi->dir);
if (err)
return err;

if (attrs[XFRMA_MIGRATE] == NULL)
return -EINVAL;

Expand Down Expand Up @@ -2202,6 +2210,11 @@ static int xfrm_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
{
struct net *net = &init_net;
struct sk_buff *skb;
int err;

err = verify_policy_dir(dir);
if (err)
return err;

skb = nlmsg_new(xfrm_migrate_msgsize(num_migrate, !!k), GFP_ATOMIC);
if (skb == NULL)
Expand Down Expand Up @@ -2827,6 +2840,11 @@ static int xfrm_notify_policy_flush(const struct km_event *c)

static int xfrm_send_policy_notify(struct xfrm_policy *xp, int dir, const struct km_event *c)
{
int err;

err = verify_policy_dir(dir);
if (err)
return err;

switch (c->event) {
case XFRM_MSG_NEWPOLICY:
Expand Down

0 comments on commit 14bf23b

Please sign in to comment.