Skip to content

Commit

Permalink
[SECURITY] secmark: nul-terminate secdata
Browse files Browse the repository at this point in the history
The patch below fixes a problem in the iptables SECMARK target, where
the user-supplied 'selctx' string may not be nul-terminated.

From initial analysis, it seems that the strlen() called from
selinux_string_to_sid() could run until it arbitrarily finds a zero,
and possibly cause a kernel oops before then.

The impact of this appears limited because the operation requires
CAP_NET_ADMIN, which is essentially always root.  Also, the module is
not yet in wide use.

Signed-off-by: James Morris <jmorris@namei.org>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
James Morris authored and David S. Miller committed Aug 2, 2006
1 parent e795d09 commit a280b89
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/netfilter/xt_SECMARK.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ static int checkentry_selinux(struct xt_secmark_target_info *info)
{
int err;
struct xt_secmark_target_selinux_info *sel = &info->u.sel;

sel->selctx[SECMARK_SELCTX_MAX - 1] = '\0';

err = selinux_string_to_sid(sel->selctx, &sel->selsid);
if (err) {
Expand Down

0 comments on commit a280b89

Please sign in to comment.