From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boaz Harrosh Subject: [PATCH] libosd: Fix NULL dereference BUG when target is none OSD conformant Date: Sun, 08 Feb 2009 16:03:35 +0200 Message-ID: <498EE637.3030800@panasas.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Return-path: Received: from gw-ca.panasas.com ([66.104.249.162]:9579 "EHLO laguna.int.panasas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752117AbZBHODk (ORCPT ); Sun, 8 Feb 2009 09:03:40 -0500 Sender: linux-scsi-owner@vger.kernel.org List-Id: linux-scsi@vger.kernel.org To: Fuerst Lars , James Bottomley , linux-scsi , open-osd mailing-list Very old OSC's Target had a BUG in the Get/Set attributes where it was looking in the wrong places for attribute lists length. If used with the open-osd initiator, the initiator would dereference a NULL pointer when retrieving system_information attributes. Checks are added if retrieval of each attributes was successful before accessing them. Signed-off-by: Boaz Harrosh --- drivers/scsi/osd/osd_initiator.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c index eeaec3e..1696130 100644 --- a/drivers/scsi/osd/osd_initiator.c +++ b/drivers/scsi/osd/osd_initiator.c @@ -131,7 +131,7 @@ static int _osd_print_system_info(struct osd_dev *od, void *caps) pFirst = get_attrs[a++].val_ptr; OSD_INFO("PRODUCT_REVISION_LEVEL [%u]\n", - get_unaligned_be32(pFirst)); + pFirst ? get_unaligned_be32(pFirst) : ~0U); pFirst = get_attrs[a++].val_ptr; OSD_INFO("PRODUCT_SERIAL_NUMBER [%s]\n", @@ -143,15 +143,18 @@ static int _osd_print_system_info(struct osd_dev *od, void *caps) pFirst = get_attrs[a++].val_ptr; OSD_INFO("TOTAL_CAPACITY [0x%llx]\n", - _LLU(get_unaligned_be64(pFirst))); + pFirst ? _LLU(get_unaligned_be64(pFirst)) : ~0ULL); pFirst = get_attrs[a++].val_ptr; OSD_INFO("USED_CAPACITY [0x%llx]\n", - _LLU(get_unaligned_be64(pFirst))); + pFirst ? _LLU(get_unaligned_be64(pFirst)) : ~0ULL); pFirst = get_attrs[a++].val_ptr; OSD_INFO("NUMBER_OF_PARTITIONS [%llu]\n", - _LLU(get_unaligned_be64(pFirst))); + pFirst ? _LLU(get_unaligned_be64(pFirst)) : ~0ULL); + + if (a >= nelem) + goto out; /* FIXME: Where are the time utilities */ pFirst = get_attrs[a++].val_ptr; -- 1.6.0.1