Message ID | 20220607204557.658541-8-richard.henderson@linaro.org |
---|---|
State | Accepted |
Commit | 3d5e2b4f26e077e9a8fd94659a1ce2dd49c134b7 |
Headers | show
Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5558077max; Tue, 7 Jun 2022 15:14:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwA66lDhZXQD9u2E1w/T+i6Xblr6+EiedbhGn0iqsKiFF3leBFkOtbj/OVQWEjFB5JHnRLd X-Received: by 2002:ac8:5752:0:b0:304:c7db:2cde with SMTP id 18-20020ac85752000000b00304c7db2cdemr24239181qtx.291.1654640058234; Tue, 07 Jun 2022 15:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654640058; cv=none; d=google.com; s=arc-20160816; b=ySyjxxHzVUPneXgTqPrAa37gPYpfFWL2aetURGQg64NGwnlhgk7T2OCEcbb+gItg7C zhHr5Vd1t9Z2JJ7f9Atn4IYdiZavClVqxWmNiYhuJIkQIQKpUTiPP6vjJhpQ3E//b8SX Es7SakkC13FxeWHT/8/ssvGnWKeMdnl19vr6LSptLP7XoUmdgagEDAiEwuXGHnRXzxSS ZpMq8djHXy1QKCGH/BxTHvsL2+ov8hTPHsd4IXTf5Y/5chE2pvLjsG48NtVuU/USVfYh OieIzK5iYMlxyB+7arFnN37MomQOd+gkT11objHHLiy8sAFc2KqlYwhanoGFxt2tvnzP G85Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=/8kHpTuA8EYvqEwEVmTpwAp8qVVL2ZJoscaVrRBS+xo=; b=t6+fg/1tyt+AtBEIG6qheLX2FAIkm4dK2cgF9f6pYjwI2p48B/7+ycd8L5rmJRR2wP rXp3HtQ41KfjxENnzrx9N5ND3ufi4UhRd7sUGMVV0qGna6ZIkVA6VkdoVFfBEvw2XLQW nLJIWRlFmcIUPXtkxXdlOGqup16uWBvYQkKfB9+4IxMwbms20y1u3V+Wp4qAxFTU+omM OoUvyJSSHZHRVnXsYWMhFLN9pY3//s2kgcOztSEA7JBhwbsKvvAmMnwJyAWx1N44fR6T mi9X/4/AR2EPUYqCZAONvqrDyc7kaKoWjZVuO7iFIYeFLtWNPwEo9Ca4Ldpitp2cTJR7 rLtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yqVFEj56; 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 Return-Path: <qemu-devel-bounces+patch=linaro.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l9-20020a05620a28c900b006a3015d862fsi11394882qkp.73.2022.06.07.15.14.18 for <patch@linaro.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 15:14:18 -0700 (PDT) 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=yqVFEj56; 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 Received: from localhost ([::1]:50030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces+patch=linaro.org@nongnu.org>) id 1nyhSr-00026Y-BQ for patch@linaro.org; Tue, 07 Jun 2022 18:14:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>) id 1nyg5Z-000785-Oy for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:46:09 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:43813) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>) id 1nyg5W-0001Jp-NS for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:46:09 -0400 Received: by mail-pl1-x634.google.com with SMTP id b5so15803839plx.10 for <qemu-devel@nongnu.org>; Tue, 07 Jun 2022 13:46:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/8kHpTuA8EYvqEwEVmTpwAp8qVVL2ZJoscaVrRBS+xo=; b=yqVFEj56Ji6vQbLKuRMIndv7VNpzqUqPm867XRuvxeGElqSwuxmJ5Qs2fnQabrK4bb +bvAwsB03PBKCDEiJuHj5adtdyT8TqTvd3EHYEIVQFUfbzdxR652jYyc+1hCXV0jPSoM guvuXY7UUGnDlv2bYYNI9Etb+egO9QvLyA7jvG1HVzCNQrPQGvspaHxJynVuQfvMe2ku mya7+eNfv97NfZtWzsupGBMHM/dtUz6JY9xr+gS9FTnLNyRB9QCsTk4a3UdQS/sl4Pbo muuYildYxYqZmyDIvgaFhDK//ulxRopjnniji+vqgTuOg0lOxNU13JBRVbpmdGQtav4T 1cQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/8kHpTuA8EYvqEwEVmTpwAp8qVVL2ZJoscaVrRBS+xo=; b=QB1QLmh5CfRK0ToVUQG7ADz4YhEIxUUyCowd1/Hp9hALhvUBHVsxeXYAb6rddxAK8s EGYagnpLmLq59JY09kAO4znvuKynDI9cIN4xp5FSU5SpMJrK/2KqNd2683UJrn0WVBIC N9WKvefpx2iV7nusgrNWFSuuvcxicKWXjCNMLZYrVIXwhSyolCvG9TIA5LygxdYceUnG vZjoNayuL6TXHTCLqIWwq6VxjCQg/fJT+jjaDQiO6wPVnK7U5mKBsIES3gLm7kNJcPb8 8lUhoN2s5YngOpfHjweuRFscp++nn0nH2wua8FlvYVpFWJw/shI/qkCqM8CztNejGTlA fJNQ== X-Gm-Message-State: AOAM532hpZMUfJgYFyQPNZzlr8GEekLAnL80f6Ds8iYEUaYfTN8udsnq BTVYFnessor9S9ScBOBbSiV42BSBt36/4Q== X-Received: by 2002:a17:902:cec8:b0:163:e4c1:b302 with SMTP id d8-20020a170902cec800b00163e4c1b302mr30892680plg.123.1654634765366; Tue, 07 Jun 2022 13:46:05 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:3cf2:c634:5b19:25f6]) by smtp.gmail.com with ESMTPSA id r6-20020a170902be0600b00162037fbacdsm12971279pls.187.2022.06.07.13.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 13:46:04 -0700 (PDT) From: Richard Henderson <richard.henderson@linaro.org> To: qemu-devel@nongnu.org Cc: Peter Maydell <peter.maydell@linaro.org> Subject: [PATCH v4 07/53] semihosting: Simplify softmmu_lock_user_string Date: Tue, 7 Jun 2022 13:45:11 -0700 Message-Id: <20220607204557.658541-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220607204557.658541-1-richard.henderson@linaro.org> References: <20220607204557.658541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+patch=linaro.org@nongnu.org> |
Series |
semihosting cleanup
|
expand
|
Richard Henderson <richard.henderson@linaro.org> writes: > We are not currently bounding the search to the 1024 bytes > that we allocated, possibly overrunning the buffer. > Use softmmu_strlen_user to find the length and allocate the > correct size from the beginning. > > Reviewed-by: Peter Maydell <peter.maydell@linaro.org> > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
diff --git a/semihosting/uaccess.c b/semihosting/uaccess.c index d6997e3c65..8018828069 100644 --- a/semihosting/uaccess.c +++ b/semihosting/uaccess.c @@ -74,20 +74,11 @@ ssize_t softmmu_strlen_user(CPUArchState *env, target_ulong addr) char *softmmu_lock_user_string(CPUArchState *env, target_ulong addr) { - /* TODO: Make this something that isn't fixed size. */ - char *s = malloc(1024); - size_t len = 0; - - if (!s) { + ssize_t len = softmmu_strlen_user(env, addr); + if (len < 0) { return NULL; } - do { - if (cpu_memory_rw_debug(env_cpu(env), addr++, s + len, 1, 0)) { - free(s); - return NULL; - } - } while (s[len++]); - return s; + return softmmu_lock_user(env, addr, len + 1, true); } void softmmu_unlock_user(CPUArchState *env, void *p,