Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932155AbZKMPQd (ORCPT ); Fri, 13 Nov 2009 10:16:33 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756586AbZKMPQ2 (ORCPT ); Fri, 13 Nov 2009 10:16:28 -0500 Received: from mtagate4.de.ibm.com ([195.212.17.164]:36448 "EHLO mtagate4.de.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755993AbZKMPJE (ORCPT ); Fri, 13 Nov 2009 10:09:04 -0500 Message-Id: <20091113150911.952456594@de.ibm.com> User-Agent: quilt/0.48-1 Date: Fri, 13 Nov 2009 16:08:39 +0100 From: Martin Schwidefsky To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Cc: Heiko Carstens , Felix Beck , Ralph Wuerthner , Martin Schwidefsky Subject: [patch 15/52] [PATCH] zcrypt: initialize ap_messages for cex3 exploitation References: <20091113150824.351347652@de.ibm.com> Content-Disposition: inline; filename=114-cex3-init-msg.diff Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4882 Lines: 150 From: Felix Beck AP messages need to be initialized, before they will be used. Values will be zeroized. This will be needed later when introducing support for the special commands. Signed-off-by: Felix Beck Signed-off-by: Ralph Wuerthner Signed-off-by: Martin Schwidefsky --- drivers/s390/crypto/ap_bus.h | 11 +++++++++++ drivers/s390/crypto/zcrypt_cex2a.c | 2 ++ drivers/s390/crypto/zcrypt_pcica.c | 2 ++ drivers/s390/crypto/zcrypt_pcicc.c | 2 ++ drivers/s390/crypto/zcrypt_pcixcc.c | 5 +++++ 5 files changed, 22 insertions(+) Index: quilt-2.6/drivers/s390/crypto/ap_bus.h =================================================================== --- quilt-2.6.orig/drivers/s390/crypto/ap_bus.h 2009-11-13 15:48:33.000000000 +0100 +++ quilt-2.6/drivers/s390/crypto/ap_bus.h 2009-11-13 16:08:15.000000000 +0100 @@ -167,6 +167,17 @@ .dev_type=(dt), \ .match_flags=AP_DEVICE_ID_MATCH_DEVICE_TYPE, +/** + * ap_init_message() - Initialize ap_message. + * Initialize a message before using. Otherwise this might result in + * unexpected behaviour. + */ +extern inline void ap_init_message(struct ap_message *ap_msg) +{ + ap_msg->psmid = 0; + ap_msg->length = 0; +} + /* * Note: don't use ap_send/ap_recv after using ap_queue_message * for the first time. Otherwise the ap message queue will get Index: quilt-2.6/drivers/s390/crypto/zcrypt_cex2a.c =================================================================== --- quilt-2.6.orig/drivers/s390/crypto/zcrypt_cex2a.c 2009-11-13 15:48:33.000000000 +0100 +++ quilt-2.6/drivers/s390/crypto/zcrypt_cex2a.c 2009-11-13 16:08:15.000000000 +0100 @@ -298,6 +298,7 @@ struct completion work; int rc; + ap_init_message(&ap_msg); ap_msg.message = kmalloc(CEX2A_MAX_MESSAGE_SIZE, GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; @@ -335,6 +336,7 @@ struct completion work; int rc; + ap_init_message(&ap_msg); ap_msg.message = kmalloc(CEX2A_MAX_MESSAGE_SIZE, GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; Index: quilt-2.6/drivers/s390/crypto/zcrypt_pcica.c =================================================================== --- quilt-2.6.orig/drivers/s390/crypto/zcrypt_pcica.c 2009-11-13 15:48:33.000000000 +0100 +++ quilt-2.6/drivers/s390/crypto/zcrypt_pcica.c 2009-11-13 16:08:15.000000000 +0100 @@ -281,6 +281,7 @@ struct completion work; int rc; + ap_init_message(&ap_msg); ap_msg.message = kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; @@ -318,6 +319,7 @@ struct completion work; int rc; + ap_init_message(&ap_msg); ap_msg.message = kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; Index: quilt-2.6/drivers/s390/crypto/zcrypt_pcicc.c =================================================================== --- quilt-2.6.orig/drivers/s390/crypto/zcrypt_pcicc.c 2009-11-13 15:48:33.000000000 +0100 +++ quilt-2.6/drivers/s390/crypto/zcrypt_pcicc.c 2009-11-13 16:08:15.000000000 +0100 @@ -483,6 +483,7 @@ struct completion work; int rc; + ap_init_message(&ap_msg); ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; @@ -521,6 +522,7 @@ struct completion work; int rc; + ap_init_message(&ap_msg); ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; Index: quilt-2.6/drivers/s390/crypto/zcrypt_pcixcc.c =================================================================== --- quilt-2.6.orig/drivers/s390/crypto/zcrypt_pcixcc.c 2009-11-13 15:48:33.000000000 +0100 +++ quilt-2.6/drivers/s390/crypto/zcrypt_pcixcc.c 2009-11-13 16:08:15.000000000 +0100 @@ -688,6 +688,7 @@ }; int rc; + ap_init_message(&ap_msg); ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; @@ -727,6 +728,7 @@ }; int rc; + ap_init_message(&ap_msg); ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; @@ -766,6 +768,7 @@ }; int rc; + ap_init_message(&ap_msg); ap_msg.message = kmalloc(PCIXCC_MAX_XCRB_MESSAGE_SIZE, GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; @@ -805,6 +808,7 @@ }; int rc; + ap_init_message(&ap_msg); ap_msg.message = kmalloc(PCIXCC_MAX_XCRB_MESSAGE_SIZE, GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; @@ -972,6 +976,7 @@ } __attribute__((packed)) *reply; int rc, i; + ap_init_message(&ap_msg); ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/