Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp297436ybi; Wed, 29 May 2019 21:41:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9HI5JvoBhdHeAW7gcK0iI9DjSjlGq8nenFXSnW6xhoMamOuM+ycVYc1KhpehpNM+Fexuv X-Received: by 2002:a17:90a:8982:: with SMTP id v2mr1634077pjn.138.1559191305792; Wed, 29 May 2019 21:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559191305; cv=none; d=google.com; s=arc-20160816; b=aH+bpWDI7di5iX/5UCUTvKIwjdE75SXoyX8x6CcvOqUfIJGV9pIfQKhrINU7MOBAja kBwsW75wfYfuSnFJu4cpYGkRE3lzeYNh4J9HfU5VoA37AGY2P/4O2ezKE/z/urlyuD5C Qt8FGgwcUPdMz3WPKtEEYdukURSBvhSklHcnzZEYAQE0ByIqDXt1natCufxNFUVRY2Xy JNS5HQ5M/CIXJxDgzsep1T3I2Opu/UcErU1U1TUWlmr7lt1OVlcqr++dtckKbASb+Vwq a4lMKVUxPUqmeT+iadzSgsCxmUmtTML5C71L9GfxQnM50pUvALQ9CXjwUQEQuI5GY2Ck /o7A== 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:dkim-signature; bh=qPfbRdCKDeTcfRBkgrMRhnVVc+q1ciJjBXfKb7kwiQs=; b=Y10y9JD4DCCfUALc/Uc6i3uMQOdYxqxjCdxATkTLeuYpTyGTUdPCYgsZXe5j7rtj95 CkoGnVg7z7blPwGB/b2Jt+c5VrzKgEAxrHQeQYJllXN0PvWhairaweX9dEbiG2CxmZyM gffosEngv40r2SF61zBvDNYYCCwJyMOMIAGWYLQtMpj+CcUh7cXxrusQ4wv55Ncnp7tx oaGLAov91PVWo1wrABkG2cxHpOeecuPFWiYl6lP43p8bxvAufUhHKpWO/j5dLqxKpQmu vpoS1Y/m06Sj8hTx9wRuEla79vpcwcjKGK9cTHxGgs2XaD6iZti8QLCuvkK/FsOMN/Vr PWCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ul7xklMZ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6si2349203pfe.21.2019.05.29.21.41.30; Wed, 29 May 2019 21:41:45 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ul7xklMZ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388293AbfE3EkH (ORCPT + 99 others); Thu, 30 May 2019 00:40:07 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:39676 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729318AbfE3EkD (ORCPT ); Thu, 30 May 2019 00:40:03 -0400 Received: by mail-oi1-f193.google.com with SMTP id v2so3955093oie.6; Wed, 29 May 2019 21:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qPfbRdCKDeTcfRBkgrMRhnVVc+q1ciJjBXfKb7kwiQs=; b=Ul7xklMZhWPYwNAtnEbULBCgIl5thKdpnRCERtn3kf/K6d/oAD9cIet+dzpjupV/ti NsdwP7dQCRwFSq1MxyPekjGTpvB1+2A2SRo96msAFWSm50IpQvUrvPHAdTYDRZb2betQ hMGO0nHnWE4Z1g8Q0GtXYceBhClVPBWvZ1psp+BtLLC0qzaHml92XM0Cp8MfNqi/an5e shzeX/ZZf4fcL0gs4uTxTIbSPXBNkHET2Cy7JMCu9NZVSYld8MGb6n8QXRyBQ0bAc02Q UKeQHJHtKznfk/34npkRvilz3Gtlc7ygWa8Qi5awEQMUo/VulosxyhQEm23N1P28XgUF +sSA== 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=qPfbRdCKDeTcfRBkgrMRhnVVc+q1ciJjBXfKb7kwiQs=; b=P/LCjTKQPSZ0lbU+sOj7s89OC4zRGhl1XjGnwhcaZgGmgoUH3ELCwMsHcJHI1TDLJH 3O6H1NyezMUcnZoy8FbUzUTdKKxV99aC2lbe1Shn8cSxGvpk4bbZ5FQjA+tTvrTPp/X1 2h+PL7jN4ER4mtIdx09r/LH8f+SMX5iFK+u3a49FKjf8+6HnImlZ282+lCknbZegloaF /eobR5Pzk31cgiJgjWvEJAbA6MIIwQANqjIm6RrVKZaZBdyBzIJUnLrsM9aHNMf8kVLO v61ztBwajlXPDL6gJEIWv01HmT5GUNBoXNY3lTUzJiN7qsbGx7UVdHr7mTI1rb4b5z5+ PYDg== X-Gm-Message-State: APjAAAWQABycLcTSXSc3M4yhtLTqsCIvWO+QFhct86ZbJewlGAOWy7Hh FEAFl0PGkH7HKP+a5nWwY45yptW7eeNR18NYNkg= X-Received: by 2002:aca:3fc6:: with SMTP id m189mr1166957oia.124.1559191202295; Wed, 29 May 2019 21:40:02 -0700 (PDT) MIME-Version: 1.0 References: <20190530035310.GA9127@zhanggen-UX430UQ> In-Reply-To: <20190530035310.GA9127@zhanggen-UX430UQ> From: William Roberts Date: Wed, 29 May 2019 21:39:50 -0700 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@vger.kernel.org, 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 Wed, May 29, 2019 at 8:55 PM 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 > --- > 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; The routine seems to return 0 on success, why would it return 0 on ENOMEM? > } > rc = selinux_add_opt(token, arg, mnt_opts); > if (unlikely(rc)) {