From patchwork Wed Nov 20 08:52:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 844513 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:8b:b0:382:43a8:7b94 with SMTP id m11csp1596447wrx; Wed, 20 Nov 2024 00:54:11 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU+08zBbRAbfomittKOBheO4GxovcDHH6lu6ugmOZL5zy+/WdLS6JinmzUcTuhnJGd7vN83OA==@linaro.org X-Google-Smtp-Source: AGHT+IHciMvzuBg8pzFLPLIRf3+qAsFy+nhimmivWUDMnLX+n1NvxF2T8pXIBmGduRr4M5Uy0RyE X-Received: by 2002:a05:690c:638a:b0:6ee:b803:552 with SMTP id 00721157ae682-6eebd12d7f6mr22732667b3.23.1732092851376; Wed, 20 Nov 2024 00:54:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732092851; cv=none; d=google.com; s=arc-20240605; b=JaygGPKe8+tY1rtYrz7yYqfH1jEtaOV6SwuxAWHY+sGCPPL97E71U6kYYA7fNhmLLu qRy/Pbqi4vvXH5mFiBhBK1TeIDuwwnWu9BXEyGJqaa9WUdmCFqHkurA1H3JHQugD56mZ U1p8E192t0LARF1gCNRlhY5nv25dBfftXdKjpYMZOxZb+Yk+wQ4lgFo5edl4NAzGDc9Z wmSLIZqQAnTa5qtbRth0hLhWJOqi+A7ELUGNR8hqaD9GUGVEstDG9wJ8zcA5ZYBzrvcm zATHUWjim4t+Ffth/ZGQCulTLmxwTrgGcz67h9ffjg9q52ZSlOuNS6Vfa+mOu/ZRMEFc bRBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Vk1t/53BIyz7NwFEHJ20Vl04uwLXRm6KfCax7gzeCvM=; fh=JRsHzxK01eLxlrW9CdJaXAIZWt4OVEECApBliHEub6o=; b=D8RvJI4Rhepe0SJwyi9vio8KOqp3Oe1VnFsivGpq9bqdG4LefIcZMbigUFuS1erCC9 mDW6YLtzOhlKacfRNC2qBLlpAYWmPd20xWXQ3Nkznpq9cA/cKRkmtdSWbM19JVFg3ETH 80OkIw4pxYngFhd44su5dN5IfOH8AbQg5KDulXFtbEUm0Inr3sbWVmj8qUE1T6mF3GRX LTcBkWrIUW0qK64RSBemgNtv01O8LsecpHgT8FOh2BAw7dnCEZrbqpLlTmpmKLHFGFYj yMa44G6yt5+NPOQOm+n++G0stEEtD5qx/CHultzqkLvQctzxQscWBKoUKjp6oBmx8Ow+ hLew==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YMYi9VMh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6d4380b2591si12663406d6.52.2024.11.20.00.54.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Nov 2024 00:54:11 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YMYi9VMh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDgSj-00007Z-Sc; Wed, 20 Nov 2024 03:53:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDgSZ-00005r-HV for qemu-devel@nongnu.org; Wed, 20 Nov 2024 03:53:16 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tDgSX-0004sB-4j for qemu-devel@nongnu.org; Wed, 20 Nov 2024 03:53:15 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-43169902057so54450925e9.0 for ; Wed, 20 Nov 2024 00:53:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732092790; x=1732697590; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vk1t/53BIyz7NwFEHJ20Vl04uwLXRm6KfCax7gzeCvM=; b=YMYi9VMhcBf00EeS/iw807KtpFo4FkW8H0O2R2uxWKdV/5POgFXuRLTrxE2+3JiaB7 15uM1jZFQz87nrLOWe6nVUzEOd/qOlzFI8/42Xy6lRkJ9OeAb/yErxvC/wzpEleKf8n6 52JygQij730ACPmW0CcxUqUl/0vIns7+2pokP+iwwg76E3tul3Lk7FVchr70o2ZxY6N0 nJqj2HwY2TTICDPEBi/t1TNnNsfgxFM4xuc3xoN4ueI2YCVi2BshcqBbxFDnxDxaM8vZ fUN3eRikVtuV7pQ/wkwT+o3G8qrHnC0u0k/4Fr9bC89yIqpHSj35JSNbd7a5BnDCJE0+ kc0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732092790; x=1732697590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vk1t/53BIyz7NwFEHJ20Vl04uwLXRm6KfCax7gzeCvM=; b=A5TkqshaXw92aXVKt1Ah8kIgV4GNHrdwDkB9JdfrvI0ZKJBXpFMum0Bc3gdmiTX5XT TKdfCkx2IhYfE7H6wgwvQ/dHQq26YN0jnibg6/0zsfgwEqyH/dH7qaUNwDZty0uUYE+e y4X0ta0r0DOQr8mIByFZp22UHOiSZ8RPeJ0SRI3oU6NzsiHFdRi8FuMI+4jhvVPI5Spr LKU5tPk05hs4XADOiJhkqBXGr2XrHhHY/+Zt2HbPXs+UDUci80NFgtFUeH3h5xkUlvfb lXhwpxl4Gpt9DfVcxCMOujsScdMb5AyNlZ8gVNW0cmYhlWXrjBCFYQyzDZvs3fCUH5H1 LQRw== X-Gm-Message-State: AOJu0YyYIK6CCeCNF55haKBT299/aPsrnbA8X/lJWOAS1csKWWXHl1Lg UX+3fGJs/uaH/aVKrSn0Z6Oz6FiCdoCG32UfcNMrtVWjEHL1Gshy2vHx4JRz50rpO1THMmSdjZC QlOQ= X-Received: by 2002:a05:600c:444f:b0:431:58cd:b260 with SMTP id 5b1f17b1804b1-4334f01815emr14901355e9.25.1732092789828; Wed, 20 Nov 2024 00:53:09 -0800 (PST) Received: from localhost.localdomain ([176.187.208.27]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-433b463b0d1sm11287495e9.42.2024.11.20.00.53.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 20 Nov 2024 00:53:09 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, David Hildenbrand , Halil Pasic , Christian Borntraeger , Eric Farman , Thomas Huth , Jared Rossi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1/2] hw/s390x: Declare loadparm as char[LOADPARM_LEN] Date: Wed, 20 Nov 2024 09:52:59 +0100 Message-ID: <20241120085300.49866-2-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241120085300.49866-1-philmd@linaro.org> References: <20241120085300.49866-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org "hw/s390x/ipl/qipl.h" defines loadparm[] length as LOADPARM_LEN, use that instead of the magic '8' value. Use a char type for char buffer. Signed-off-by: Philippe Mathieu-Daudé --- hw/s390x/ccw-device.h | 5 +++-- hw/s390x/ipl.h | 2 +- include/hw/qdev-properties-system.h | 2 +- include/hw/s390x/s390-virtio-ccw.h | 3 ++- hw/core/qdev-properties-system.c | 8 +++++--- hw/s390x/ipl.c | 6 +++--- hw/scsi/scsi-disk.c | 2 +- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/hw/s390x/ccw-device.h b/hw/s390x/ccw-device.h index 4439feb140..94a9b35714 100644 --- a/hw/s390x/ccw-device.h +++ b/hw/s390x/ccw-device.h @@ -15,6 +15,7 @@ #include "hw/qdev-core.h" #include "hw/s390x/css.h" #include "hw/s390x/css-bridge.h" +#include "hw/s390x/ipl/qipl.h" struct CcwDevice { DeviceState parent_obj; @@ -27,7 +28,7 @@ struct CcwDevice { /* The actual busid of the virtual subchannel. */ CssDevId subch_id; /* If set, use this loadparm value when device is boot target */ - uint8_t loadparm[8]; + char loadparm[LOADPARM_LEN]; }; typedef struct CcwDevice CcwDevice; @@ -54,6 +55,6 @@ OBJECT_DECLARE_TYPE(CcwDevice, CCWDeviceClass, CCW_DEVICE) extern const PropertyInfo ccw_loadparm; #define DEFINE_PROP_CCW_LOADPARM(_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, ccw_loadparm, typeof(uint8_t[8])) + DEFINE_PROP(_n, _s, _f, ccw_loadparm, typeof(char[LOADPARM_LEN])) #endif diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h index d7d0b7bfd2..014b530ad2 100644 --- a/hw/s390x/ipl.h +++ b/hw/s390x/ipl.h @@ -23,7 +23,7 @@ #define MAX_BOOT_DEVS 8 /* Max number of devices that may have a bootindex */ void s390_ipl_convert_loadparm(char *ascii_lp, uint8_t *ebcdic_lp); -void s390_ipl_fmt_loadparm(uint8_t *loadparm, char *str, Error **errp); +void s390_ipl_fmt_loadparm(char *loadparm, char *str, Error **errp); void s390_rebuild_iplb(uint16_t index, IplParameterBlock *iplb); void s390_ipl_update_diag308(IplParameterBlock *iplb); int s390_ipl_prepare_pv_header(Error **errp); diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properties-system.h index 7ec37f6316..844af7a200 100644 --- a/include/hw/qdev-properties-system.h +++ b/include/hw/qdev-properties-system.h @@ -3,7 +3,7 @@ #include "hw/qdev-properties.h" -bool qdev_prop_sanitize_s390x_loadparm(uint8_t *loadparm, const char *str, +bool qdev_prop_sanitize_s390x_loadparm(char *loadparm, const char *str, Error **errp); extern const PropertyInfo qdev_prop_chr; diff --git a/include/hw/s390x/s390-virtio-ccw.h b/include/hw/s390x/s390-virtio-ccw.h index 996864a34e..9d4e00b0c7 100644 --- a/include/hw/s390x/s390-virtio-ccw.h +++ b/include/hw/s390x/s390-virtio-ccw.h @@ -14,6 +14,7 @@ #include "hw/boards.h" #include "qom/object.h" #include "hw/s390x/sclp.h" +#include "hw/s390x/ipl/qipl.h" #define TYPE_S390_CCW_MACHINE "s390-ccw-machine" @@ -28,7 +29,7 @@ struct S390CcwMachineState { bool aes_key_wrap; bool dea_key_wrap; bool pv; - uint8_t loadparm[8]; + char loadparm[LOADPARM_LEN]; SCLPDevice *sclp; }; diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index a61c5ee6dd..e8e9cd8e04 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -35,6 +35,7 @@ #include "hw/pci/pci.h" #include "hw/pci/pcie.h" #include "hw/i386/x86.h" +#include "hw/s390x/ipl/qipl.h" #include "util/block-helpers.h" static bool check_prop_still_unset(Object *obj, const char *name, @@ -58,14 +59,15 @@ static bool check_prop_still_unset(Object *obj, const char *name, return false; } -bool qdev_prop_sanitize_s390x_loadparm(uint8_t *loadparm, const char *str, +bool qdev_prop_sanitize_s390x_loadparm(char *loadparm, const char *str, Error **errp) { int i, len; len = strlen(str); - if (len > 8) { - error_setg(errp, "'loadparm' can only contain up to 8 characters"); + if (len > LOADPARM_LEN) { + error_setg(errp, "'loadparm' can only contain up to %u characters", + LOADPARM_LEN); return false; } diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 30734661ad..6fd3774c7d 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -416,7 +416,7 @@ static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain) return chain_addr; } -void s390_ipl_fmt_loadparm(uint8_t *loadparm, char *str, Error **errp) +void s390_ipl_fmt_loadparm(char *loadparm, char *str, Error **errp) { /* Initialize the loadparm with spaces */ memset(loadparm, ' ', LOADPARM_LEN); @@ -439,8 +439,8 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb) CcwDevice *ccw_dev = NULL; SCSIDevice *sd; int devtype; - uint8_t *lp; - g_autofree void *scsi_lp = NULL; + char *lp; + g_autofree char *scsi_lp = NULL; /* * Currently allow IPL only from CCW devices. diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 8e553487d5..96a09fe170 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -3145,7 +3145,7 @@ static char *scsi_property_get_loadparm(Object *obj, Error **errp) static void scsi_property_set_loadparm(Object *obj, const char *value, Error **errp) { - void *lp_str; + char *lp_str; if (object_property_get_int(obj, "bootindex", NULL) < 0) { error_setg(errp, "'loadparm' is only valid for boot devices"); From patchwork Wed Nov 20 08:53:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 844512 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:8b:b0:382:43a8:7b94 with SMTP id m11csp1596445wrx; Wed, 20 Nov 2024 00:54:11 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW+e8Bm1ZTJeJFrU0gfsXBUC6WvAcPMROyYDN3DSv4SnI91crdqA+p3eZJcev5yY1yDLzj1Sw==@linaro.org X-Google-Smtp-Source: AGHT+IFaWmoFofBpWBZb3VGOf05G5lvGVtHXGVot5Wu0W3Fg13kUg0G/N4TA2Bq4aLtJuwlDLrYT X-Received: by 2002:a05:620a:46aa:b0:7a9:aba6:d012 with SMTP id af79cd13be357-7b4232a13a9mr235519385a.22.1732092851332; Wed, 20 Nov 2024 00:54:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732092851; cv=none; d=google.com; s=arc-20240605; b=CcB1eKhUiqqE30Ooky0QMszhjobj6DhDrBt14DKps5VtxmuxaWAEW04FpJxwdRySEY vWcikt19usrScVzPTt+UrOtXB9bB4wX8C8Sys8OxjNNjzQ7DnSdz7uqiT/kSBjczXhzj WuZSKpO/ZmRVqo/lzYxD5s2UXN7pBqEa6k7CrE31ZPc9wMDHiJxSK22T/tx7p+SK4/Mj y8aWonLAnDKwEP97o5Uz4Qta3/+rMT6IkVug0cok/KJJW/WTg8jz2iSpSIr5E1TOCza1 jfzTOfaxLMBlWMgqb2mvhEqfnCMZvESZlJh/rdpHE86TPfTYTEkWGE4AJkEZj6GzWDMK GuwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iN/AqNy/hKljQubEThCY6fG1Ip1/THaEqT2SsGhQViM=; fh=JRsHzxK01eLxlrW9CdJaXAIZWt4OVEECApBliHEub6o=; b=X/51+uLrWsk1lauf7lq9ss2pvs2En/R+pTDhPHTNFKjrhFNQBN6YMCr7rjpTvJoIxK 3X7pmKfVCdUeqdpnIRXpBFbI70RmwYTd2G3VRlkHzVhzKICqruLwkubyf7bPCo10Gg8+ 0+kpxl2FzRe1OaDNzmpEflLAw0Uf0lDEhSQRqd/lWP7yKU03E9gLnLHI4MMWhVU1xnlP 4CuOy2yYk8ttfUvoNuodX7ZWrQpckGvqlYFbPfVStZkK7XJwSJSqdZC/+lcbuoudCXcb +nR+FMLURbq1ae0ZAVOhW3iBQHyooY50gn4Fp9OZEiUNPgQuW4AvfLYizhXQVryrnx05 P9yA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g+D6trgU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b48529293fsi119933785a.298.2024.11.20.00.54.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Nov 2024 00:54:11 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g+D6trgU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDgSl-00008P-CH; Wed, 20 Nov 2024 03:53:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDgSg-000070-9A for qemu-devel@nongnu.org; Wed, 20 Nov 2024 03:53:22 -0500 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tDgSd-00053H-BC for qemu-devel@nongnu.org; Wed, 20 Nov 2024 03:53:20 -0500 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-53c779ef19cso6546185e87.3 for ; Wed, 20 Nov 2024 00:53:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732092797; x=1732697597; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iN/AqNy/hKljQubEThCY6fG1Ip1/THaEqT2SsGhQViM=; b=g+D6trgUFFMXJ3XudxFedLF0n6je+FR/19zH/SZD3s4H0BKHuTGFOtujz9L7rLGpRF WxcczAbjiMckweif30xH9fecj7bpuoQbubcmCYUHhjfSJPuvSbQLuPVYmu9ilxP1tUNN 5TXENSJx+LNgCJWb4Lo+Ludd/5A1NY93mc/1FVOAuDyfGoT9FWPC5JdEKnpTt96PQCUo FFljDT55zMpkZpUNru6ZMS4+Wul5qR9C93l2m6UeAnMSPSxYETCH/Z6Z9A1uhr8AiGKK 9EQ8EtUltGBW+VxDQuyFgbtRklrYpKhVy5kl3vaWgL7qMBthY6vEJQYIjZS9hYeQgDr6 bSTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732092797; x=1732697597; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iN/AqNy/hKljQubEThCY6fG1Ip1/THaEqT2SsGhQViM=; b=LZdc16u+xiarZNGpQCcq3mutZdCqvWyxlwB2Cuj/F/bIVot7SoEx0suIWn1WNhzT+X 2fDX954m5zoY6Nu5AXKkFG5V4KerpYQFPMY4DVHTp8hurVda4HHw2lWNI5fAbbUisxFf BZMowshanTebvu2ZBoGZtvmKG/6vNAolBNU0eYTzBsB2FTEuGBiuSpHyGYVUm2oOoz9S qILJW8t+WEBeZ5IcQT50NfK+kVYDxrSXfpjj4CdJ5CpPiYSD7omQ00EXE4YPKzybAJkb bNs0kbb3z9W5yeIFncaLFARdfPXz+Alteyewp12fWl6CO9QMpnBN5I37Q1HrJudY7U7j 2U1A== X-Gm-Message-State: AOJu0YxJrJFmNJApaFDS+a1OUprpr3w645sUBAAJ9fM6YI65ZpygyFyR txma4joiRQqF1u8jPezIhlGpSgZMc20NmtCRfyzuXeug+BxfSCjMm+5+GSPd3DwL6KHFSRfvmN4 V7Mc= X-Received: by 2002:a05:6512:b0b:b0:539:ea49:d163 with SMTP id 2adb3069b0e04-53dc132e21fmr605456e87.21.1732092796868; Wed, 20 Nov 2024 00:53:16 -0800 (PST) Received: from localhost.localdomain ([176.187.208.27]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-433b0139b22sm11956555e9.0.2024.11.20.00.53.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 20 Nov 2024 00:53:16 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, David Hildenbrand , Halil Pasic , Christian Borntraeger , Eric Farman , Thomas Huth , Jared Rossi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 2/2] hw/scsi/scsi-disk: Avoid buffer overrun parsing 'loadparam' Date: Wed, 20 Nov 2024 09:53:00 +0100 Message-ID: <20241120085300.49866-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241120085300.49866-1-philmd@linaro.org> References: <20241120085300.49866-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=philmd@linaro.org; helo=mail-lf1-x134.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Coverity reported a 1 byte overrun in scsi_property_set_loadparm (CID 15657462). Since loadparam[] length is known, simply directly allocate it in the device state. Fixes: 429442e52d ("hw: Add 'loadparm' property to scsi disk devices") Signed-off-by: Philippe Mathieu-Daudé --- hw/scsi/scsi-disk.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 96a09fe170..f6d6b7c1ea 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -38,6 +38,7 @@ #include "hw/block/block.h" #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" +#include "hw/s390x/ipl/qipl.h" #include "sysemu/dma.h" #include "sysemu/sysemu.h" #include "qemu/cutils.h" @@ -112,7 +113,7 @@ struct SCSIDiskState { char *vendor; char *product; char *device_id; - char *loadparm; /* only for s390x */ + char loadparm[LOADPARM_LEN]; /* only for s390x */ bool tray_open; bool tray_locked; /* @@ -3145,19 +3146,12 @@ static char *scsi_property_get_loadparm(Object *obj, Error **errp) static void scsi_property_set_loadparm(Object *obj, const char *value, Error **errp) { - char *lp_str; - if (object_property_get_int(obj, "bootindex", NULL) < 0) { error_setg(errp, "'loadparm' is only valid for boot devices"); return; } - lp_str = g_malloc0(strlen(value)); - if (!qdev_prop_sanitize_s390x_loadparm(lp_str, value, errp)) { - g_free(lp_str); - return; - } - SCSI_DISK_BASE(obj)->loadparm = lp_str; + qdev_prop_sanitize_s390x_loadparm(SCSI_DISK_BASE(obj)->loadparm, value, errp); } static void scsi_property_add_specifics(DeviceClass *dc)