Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp474744ybi; Thu, 30 May 2019 01:30:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnnQhFdY+ODa+h6Rgm+rbvg1jGgsM17go+lzTR3ADbgoHBn6FVl0HgFabJyn1o8T3xM8hF X-Received: by 2002:a17:90a:bb82:: with SMTP id v2mr2463980pjr.73.1559205021458; Thu, 30 May 2019 01:30:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559205021; cv=none; d=google.com; s=arc-20160816; b=mP3yzc4Ib8neGJ6Um9aGwbz7ezZIsF2E6nVAd1K4hBoxvnuvtFSKTBnTchHinGI1KY 6OVY3YLicPLu+pRowOp5Q8BItVIZZ+SYwyPlhC9BLX6K0Y081UKuYj/t/WH5VhaPk2fX HzFnKarmJZj//TT0A5r2HMOBPvHTFy98I4FLQR2nVPL3e0PAC+UShOCXCOenGEvNa2Vl RHLB93ez1Nbtdcv8J1JQ+4L71Dp3pWVSzjc3SnqIx84DtqkgKa8j2OT3eBoYgLbYZlnj Pp37UI8T+6B/bklFHAH+bjTojUTW3GXmaCeegqaXHNctvo8TlN4SVle8ZyZzYtjHSoMh ZnwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=a4/V6C9EK4vY7/JLXibmWc3UiOpGTZPM0ljUbojs3aI=; b=O/Bn8vRrBjZb+tqx46h4vrTDg7SJRsYS6Kh7MIR/DOr1W1Bisxmm/OqiI1Q/EO61yk 0C/tVFnKq4O2rB9Hssvdg5iErl7KzQ3OTpT+iMurPQU/LZNkqgzyHccLxTGJGZD9NvF5 gwVAjadWdlcHmBxa/GzuU3K/jJ+leHWjmyr1dRXvY7CrYCFF55l9jFFVmsCZZRtOPw7K gQkLjn5j/XEZFYxL1qBLVn/RSxUSj8NAXt+bIpvP0tM+0y0ocT5PxRfw3scDGnXWCMgv mNHGS5SbEHC2ItbtuDUoecTuYz/AzPnOtoWyJ8QpALObhnV2+rV6/7n1C/sUbz9z7PwW zbag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d186si2425359pgc.311.2019.05.30.01.30.04; Thu, 30 May 2019 01:30:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726589AbfE3I2y (ORCPT + 99 others); Thu, 30 May 2019 04:28:54 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:42101 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726079AbfE3I2y (ORCPT ); Thu, 30 May 2019 04:28:54 -0400 Received: by mail-oi1-f196.google.com with SMTP id v25so3750963oic.9 for ; Thu, 30 May 2019 01:28:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=a4/V6C9EK4vY7/JLXibmWc3UiOpGTZPM0ljUbojs3aI=; b=uSf9qd5czeq/E4Z8ATFJgo8BGPC/lhO/Dko6Tlpu1FaSw+IKCbOU0ULNjn2rjhoXnY l5ZfhHxoe4SGAKaZmWn4sGUnb0YaIoleNM1bzlkfEbBuoRCxcpyo0QiNV5Z8F6HlPW/o qnJf2Z/u9u7lf7Mkj5RgJCVFE4je/5phDWonfjljkkRXkrGL0gsabzW5ZMecjWsbmWQj 7iw1R4Xm6LGn4e/mIreSJGOkc3gSChLRUztgxh1Lg3wMpAlTERSJHUnj3TGVKJ/FzCsq 5EkOx1+E11wl5aeCvmFJoXXSXIHhx5OafHCm8TMRfLuoRYk5g/AOu85RI2LeS3t3Q/1A 6fUw== X-Gm-Message-State: APjAAAUWdktOQDP00puNrB2Mn6megomJJTduN/ipTvguqHA/bdWbrDXG caRMIL5TllBKXSmmTG5Ma1Ued88ggwizuHqkYuoybQ== X-Received: by 2002:aca:e146:: with SMTP id y67mr1244852oig.127.1559204933231; Thu, 30 May 2019 01:28:53 -0700 (PDT) MIME-Version: 1.0 References: <20190530035310.GA9127@zhanggen-UX430UQ> In-Reply-To: <20190530035310.GA9127@zhanggen-UX430UQ> From: Ondrej Mosnacek Date: Thu, 30 May 2019 10:28:46 +0200 Message-ID: Subject: Re: [PATCH] hooks: fix a missing-check bug in selinux_sb_eat_lsm_opts() To: Gen Zhang Cc: Paul Moore , tony.luck@intel.com, Stephen Smalley , Eric Paris , selinux@vger.kernel.org, Linux kernel mailing list , bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 30, 2019 at 5:53 AM Gen Zhang wrote: > In selinux_sb_eat_lsm_opts(), 'arg' is allocated by kmemdup_nul(). It > returns NULL when fails. So 'arg' should be checked. > > Signed-off-by: Gen Zhang Since it looks like you are going to respin this patch, please add: Fixes: 99dbbb593fe6 ("selinux: rewrite selinux_sb_eat_lsm_opts()") to the commit message so that there is a record of which commit introduced the issue (then it can be picked up automatically for backport into the relevant stable kernels). Thanks for spotting the issue and sending the patch(es)! > --- > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > index 3ec702c..5a9e959 100644 > --- a/security/selinux/hooks.c > +++ b/security/selinux/hooks.c > @@ -2635,6 +2635,8 @@ static int selinux_sb_eat_lsm_opts(char *options, void **mnt_opts) > *q++ = c; > } > arg = kmemdup_nul(arg, q - arg, GFP_KERNEL); > + if (!arg) > + return 0; > } > rc = selinux_add_opt(token, arg, mnt_opts); > if (unlikely(rc)) { -- Ondrej Mosnacek Software Engineer, Security Technologies Red Hat, Inc.