From patchwork Mon Nov 27 07:18:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10075975 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AF93C6028E for ; Mon, 27 Nov 2017 07:19:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A14A528D7A for ; Mon, 27 Nov 2017 07:19:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9559B28D7B; Mon, 27 Nov 2017 07:19:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C21928D82 for ; Mon, 27 Nov 2017 07:19:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751197AbdK0HTh (ORCPT ); Mon, 27 Nov 2017 02:19:37 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:33880 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750838AbdK0HTg (ORCPT ); Mon, 27 Nov 2017 02:19:36 -0500 Received: by mail-pg0-f65.google.com with SMTP id 4so18305566pge.1; Sun, 26 Nov 2017 23:19:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=sEj5IgBlBxQm2yE176zphgXU+Bv9SXkRBZCquc+hOt8=; b=lmoeqTmGQ8EiSIpt5M68brvwxt6LzQ0UnEhRBY6mFQ5fvv7mAG10rWZ5m4Wr46Ctii dzOAnDBhtP8DqwN++DdS0m8qiFqY4ETqmxp2oUa9wDDee2zv38B7q2GROGNsZJtqFQ16 hzD+tYHP3C5/TmxEJ18Q7WlgwW6DVnTejrP2dkRKm5XhT9fz6hxPsIydz4/KQ4E4EJL3 2GQ/NG0TrIqvlbC+ODoIlhC6URwPCp3chout3EtdEFMPexI3b08U50V4yxppCSak9glA GtpoNfhfJKzwehD6nfJI6BiCrsybgsF8XdTeJCJG8ZMJ3eQyerMmE5qVLsfdOmSsyxj4 xJpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=sEj5IgBlBxQm2yE176zphgXU+Bv9SXkRBZCquc+hOt8=; b=LtkmD4K0LfA8wo+fQjRSbA/Sd9nWfdZn/EaPDCBMvLCyT6ecPf3i7D0UnWx9JXvt2t jul0Ow5ZLwohP8B7+Wu+Ujd//Rp43mh6L+PFj0ZWXx816z/AHYTanQGuNEjEvGiYdu3U auhlnoTb9GwoEL/ZNI0CxihldwNpOpg4j+qtp5XTUEMUD+Ib+NR46AWrm6+CfZIX/Qfk uNpRGL85bgGO2Qb6R1rHHWQTHzF/JlPQMcg9AJRLUIXfDFux17Q6rHEUo7ZnEP77SeQe LOy5hQrefxPCbsbFJE0iRkoGFkBWlPPeafG6Y9MebXVLdB1b0dZx3k9pBvExBwvO8l4K f8Iw== X-Gm-Message-State: AJaThX7HoPxcsgmDIu9ue+xqfZ7KcPh386+rsS64csUfiYvs7fLRa9c1 XP55mpaitbB9DZoMnVcjRDV51yub X-Google-Smtp-Source: AGs4zMbiC59e/bJx+UiwiUEqDhBISUxxdm7TGNlwxT7YD7e3lxAco0RG/1XiiJnCRYCxz2AcoQBwaw== X-Received: by 10.98.87.13 with SMTP id l13mr36290580pfb.193.1511767175902; Sun, 26 Nov 2017 23:19:35 -0800 (PST) Received: from zzz.localdomain (c-67-185-97-198.hsd1.wa.comcast.net. [67.185.97.198]) by smtp.gmail.com with ESMTPSA id r11sm24920856pgf.79.2017.11.26.23.19.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Nov 2017 23:19:35 -0800 (PST) From: Eric Biggers To: keyrings@vger.kernel.org, David Howells Cc: linux-crypto@vger.kernel.org, Eric Biggers Subject: [PATCH] pkcs7: return correct error code if pkcs7_check_authattrs() fails Date: Sun, 26 Nov 2017 23:18:44 -0800 Message-Id: <20171127071844.26106-1-ebiggers3@gmail.com> X-Mailer: git-send-email 2.15.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers If pkcs7_check_authattrs() returns an error code, we should pass that error code on, rather than using ENOMEM. Fixes: 99db44350672 ("PKCS#7: Appropriately restrict authenticated attributes and content type") Signed-off-by: Eric Biggers Reviewed-by: James Morris --- crypto/asymmetric_keys/pkcs7_parser.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crypto/asymmetric_keys/pkcs7_parser.c b/crypto/asymmetric_keys/pkcs7_parser.c index c1ca1e86f5c4..a6dcaa659aa8 100644 --- a/crypto/asymmetric_keys/pkcs7_parser.c +++ b/crypto/asymmetric_keys/pkcs7_parser.c @@ -148,8 +148,10 @@ struct pkcs7_message *pkcs7_parse_message(const void *data, size_t datalen) } ret = pkcs7_check_authattrs(ctx->msg); - if (ret < 0) + if (ret < 0) { + msg = ERR_PTR(ret); goto out; + } msg = ctx->msg; ctx->msg = NULL;