Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11231743imu; Mon, 31 Dec 2018 16:45:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/V45Je3NhRIIZDbWGJgj7IHe7dL1cNq6znU95dlSuzVASE80mJW/gZGhxXHzpSbSwNbFxzt X-Received: by 2002:a62:5301:: with SMTP id h1mr39357370pfb.17.1546303524425; Mon, 31 Dec 2018 16:45:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546303524; cv=none; d=google.com; s=arc-20160816; b=MlneVcJRZK74MNJwp3Tn+s10LqIZ6XgBUBKUhsJDif4gnQ3jUTvMbo9412HZT4Q1wP 59Dck+Z2TsRVVXzuGR0cJH8m3ftP+95TssN0z/L8EN3aelmBKhGvl0o+GdnExymDDgBY l6GHAXqc3kgcjc8v4dF6F/SHrV1D/aLTOXpZBdLxKkuHxYpHERHtHS2fWWVwL4tTcY9S GpvesPBE8h24DnSc5E2AAduOyCUFex402fe90x9jpZLfJXLEAXiv/xIAIWlQg/EzfqaE VsSgkelN7icbDkStkiKW1ZfIxr5+7HynwpsrTOdCFMSrK0wey5dRKlciUrkmkU1u87BZ y7Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=HziHZoAIupHsPeSyzZzTMdLTn1sDxV3w65YjHD7wktk=; b=Z7CarW9kRDzeGAbiSS/V9KPmwJBOKab7fQEFR3rxLl0UCw9XzCh0uYu/2Y20rCzzmH OW5jEVS6thQACiaV/rQSF8kCB91XE5H1r0qaMxzBAHmFF2MVp+/ObSxYnRqkTPOWoRQg oGR08ZBla9A/HiQ9LXPVrij4bam9UxSuL+MW89hcDnDKtHyLTAAsg0p48U4uHw+aCJFi kKv22gM9EL/BW3CcH8ZEQ2kTYnjhfGJ1TCGw1hEAOf+tux75bxtw4KML8uXU0a6TCuj4 IFSeUmHvzf//+/FkJeauk9ZA5RvA8Eld4r+zPGrEJtEiIXVz9fb/zaDQO32ieKkUGwK7 CNVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LGlTin3L; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5si26930198pgq.82.2018.12.31.16.44.47; Mon, 31 Dec 2018 16:45:24 -0800 (PST) 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=@kernel.org header.s=default header.b=LGlTin3L; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728108AbeLaWpg (ORCPT + 99 others); Mon, 31 Dec 2018 17:45:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:37536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728049AbeLaWpg (ORCPT ); Mon, 31 Dec 2018 17:45:36 -0500 Received: from zzz.localdomain (h184-61-154-48.mdsnwi.dsl.dynamic.tds.net [184.61.154.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3134621019; Mon, 31 Dec 2018 22:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546296335; bh=K0f2TV4mk9Hwn6iw+w10KgqmpadwSQ60ON7zVh6vN8Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LGlTin3LD+bBgIYfuY8hFzElOjpmFIQs0bpc3jUL3kn8i3qfm1NT9eEm7zL8+3Mvy BFs61DNBH3J6lowQ8JcSnHgqHizDN/eptcaSv4IiOqaOuh4HDmjWMbjLzV1j/KQfKE UbDcQaYxytjENW0T6Kv9an97bEAiQJs9s0atkv/M= Date: Mon, 31 Dec 2018 16:45:31 -0600 From: Eric Biggers To: David Howells , Linus Torvalds Cc: James Bottomley , James Morris , Mimi Zohar , Jarkko Sakkinen , Peter Huewe , keyrings@vger.kernel.org, Linux List Kernel Mailing , syzkaller-bugs@googlegroups.com Subject: Re: [PATCH RESEND] KEYS: fix parsing invalid pkey info string Message-ID: <20181231224530.GA12425@zzz.localdomain> References: <20181128232019.GC131170@gmail.com> <20181217181244.220052-1-ebiggers@kernel.org> <1545076260.2878.15.camel@HansenPartnership.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi David and Linus, On Mon, Dec 17, 2018 at 12:02:01PM -0800, Linus Torvalds wrote: > On Mon, Dec 17, 2018 at 11:51 AM James Bottomley > wrote: > > > > If this is to replace Eric's patch, didn't you want to set token_mask > > to (1< > No, let's not add any extra code that is trying to be subtle. Subtle > interactions was where the bug came from. > > The code already checks the actual Opt_xyz for errors in a switch > statement. The token_mask should be _purely_ about duplicate options > (or conflicting ones). > > Talking about the conflicting ones: Opt_hash checks that > Opt_policydigest isn't set. But Opt_policydigest doesn't check that > Opt_hash isn't set, so you can mix the two if you just do it in the > right order. > > But that's a separate bug, and doesn't seem to be a huge deal. > > But it *is* an example of how bogus all of this stuff is. Clearly > people weren't really paying attention when writing any of this code. > > Linus KEYCTL_PKEY_QUERY is still failing basic fuzzing even after Linus' fix that changed Opt_err from -1 to 0. The crash is still in keyctl_pkey_params_parse(): token = match_token(p, param_keys, args); if (__test_and_set_bit(token, &token_mask)) return -EINVAL; q = args[0].from; if (!q[0]) return -EINVAL; Now it crashes on '!q[0]' because 'args[0].from' is uninitialized when token == Opt_err. args[0] is only initialized when the parsed token had a pattern that set it. David, where are the tests for these new keyctls? - Eric