From patchwork Sat Sep 4 21:37:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 507017 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp2132377jai; Sat, 4 Sep 2021 14:44:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyksJcTE4rtYDK9ND49EMO7HGomATNdBs40hQKpZ1mMojOwAD/5j60/iZKDZE0UR5zzZdqy X-Received: by 2002:a25:a20a:: with SMTP id b10mr6998348ybi.478.1630791845376; Sat, 04 Sep 2021 14:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630791845; cv=none; d=google.com; s=arc-20160816; b=wNvIkAtI5mqSpP4ZAhQLbgdGdv7xASGa7bv6Qb1jAw0SmSCKhgjc4HJLnfsolpRipN x1VI74I6E9ymN5UdwqnvPDfhiWBeVOm3bf0A2Phf683JqwiZXtho+LtzM/OdmwHNnJ0A C0CTNr6pipBrMLHeaIPiLjFxB4i/sYjp7f8WxwtNUly6ZKCtfwGi1v9bA75NEuXGf7q5 PY/yx3yqJYqE+ZWgnoNLVz5QnCrAOj4/PHbRjW5IOPMeI63GSJJnrECsZPq6Uysau7FS EQ25wsB6L7ml2KGNYU3cfSMk7f1RbhIbO21hh0z2J/99eRpjHydh0D2xR0tOn2gCAzsx tzXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :content-disposition:in-reply-to:mime-version:references:message-id :subject:to:from:date:dkim-signature; bh=h9J1SZK6q/IrdiaUC0UN5jQCNpILg+MnT95UcKmm0bk=; b=0b6oFD+Ziy1q29yDJbNHZoMiQ/BFV3nwZAN41EkvTO2B0+AHMCq8ws6psLIKdjhFhS ZZr93wiSwbGMjhf96l1jt4E++37vYuZPW+Gnadfpu99YRCK8UfN5tidNjn5vLzE0Ih6+ eUQwWL/yi0oQAfh+Ndjr2vdP9mkz8CYHblO7UT6mabPG0i6KPm8cW+ac6FZeAfmb0bFS 2KJHkFQH8z5KD39qw98XE1HYVqqVG82mShV+r5zGPpiN636kWuMg1hRzg4RrXqtz0lQt U8CWhdPXKPCPZyjNjAOZVPzRLDNL4Ojxe3mko4hxNDzU5wRs4u81nn0uDkVYLy76Sdy4 xy4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=NF99i+cK; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w4si3819095ybp.289.2021.09.04.14.44.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 04 Sep 2021 14:44:05 -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=fail header.i=@redhat.com header.s=mimecast20190719 header.b=NF99i+cK; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:59236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMdSG-0006Nc-TJ for patch@linaro.org; Sat, 04 Sep 2021 17:44:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMdLd-00060W-Fd for qemu-devel@nongnu.org; Sat, 04 Sep 2021 17:37:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45408) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMdLc-0001SL-2P for qemu-devel@nongnu.org; Sat, 04 Sep 2021 17:37:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630791431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h9J1SZK6q/IrdiaUC0UN5jQCNpILg+MnT95UcKmm0bk=; b=NF99i+cKptmZqQThrPNyT+laIOwtlosZDKFrMYTP9BvgF1a/X6frNKr7tpsy4uoU+FuNxP Vj9zPLQ6dOa44F02bHkoWLXwjEdrDw3+oV0m3sX7n0/OZfAxxkbKCLIM1lW3SHHgumd0iX AbTHoiUUAPlfOaCeIW1L5t74nJAMHDw= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-276-GCXaoOhoNDeklMCMGR409A-1; Sat, 04 Sep 2021 17:37:10 -0400 X-MC-Unique: GCXaoOhoNDeklMCMGR409A-1 Received: by mail-ed1-f69.google.com with SMTP id u2-20020aa7d982000000b003cda80fa659so250872eds.14 for ; Sat, 04 Sep 2021 14:37:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=h9J1SZK6q/IrdiaUC0UN5jQCNpILg+MnT95UcKmm0bk=; b=iBkn/jVdRprHyuxoItEr/+7FNFd7alh+u2AlbkGhU5Efd81Mj+hz9yD1ZViive2wJr vYyQdCSsmErol4XkquDieOyzzPHbRIGZcQwK62jHXKzsIggCCZhaEs3gEzm6BKY5Riwv TuCSV4XDzIfXIVk2zrd1e5iW/4nFAXvfhNyiQCxhNFfTAzSNmIWdSxiYAD2/f9TllDdH 79a2iulGr+dgFxVn9tFzYtSLGzwn5HQ2cEEzHaTEibiAnDjiSbNrQxQLZZAzhwA+1Uqj DpaX1ztS5Tt/0s0OORymQpqprfEYqdLvjBMuxZ7Z/AlZdb0/9G23u3/zMsaWpr726ATl i3vA== X-Gm-Message-State: AOAM531JN59mvrSHv42jh3ObdH0TuREzyBlbOYMOnD6vNgexeasYe1X2 YCxfQRFYfY8dRQDxOmx1xKCTv8T3+Awnz6sChL15zzHX/GUn48KjY7xYWMDqtD89iotg14K+srF yZvP/okdGbYwyerQKOeY0PuLBKlZlGzRqAsKO4TGAJ5T1S8hprR6Vp0ARL/WN X-Received: by 2002:a50:c905:: with SMTP id o5mr5746013edh.250.1630791428485; Sat, 04 Sep 2021 14:37:08 -0700 (PDT) X-Received: by 2002:a50:c905:: with SMTP id o5mr5746003edh.250.1630791428326; Sat, 04 Sep 2021 14:37:08 -0700 (PDT) Received: from redhat.com ([2.55.150.176]) by smtp.gmail.com with ESMTPSA id m6sm1874641edi.10.2021.09.04.14.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Sep 2021 14:37:07 -0700 (PDT) Date: Sat, 4 Sep 2021 17:37:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 23/35] tests/vhost-user-bridge.c: Sanity check socket path length Message-ID: <20210904213506.486886-24-mst@redhat.com> References: <20210904213506.486886-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210904213506.486886-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.391, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Coiby Xu , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The vhost-user-bridge binary accepts a UNIX socket path on the command line. Sanity check that this is short enough to fit into a sockaddr_un before copying it in. Fixes: Coverity CID 1432866 Signed-off-by: Peter Maydell Message-Id: <20210901152632.25511-1-peter.maydell@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marc-André Lureau --- tests/vhost-user-bridge.c | 5 +++++ 1 file changed, 5 insertions(+) -- MST diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c index 24815920b2..cb009545fa 100644 --- a/tests/vhost-user-bridge.c +++ b/tests/vhost-user-bridge.c @@ -540,6 +540,11 @@ vubr_new(const char *path, bool client) CallbackFunc cb; size_t len; + if (strlen(path) >= sizeof(un.sun_path)) { + fprintf(stderr, "unix domain socket path '%s' is too long\n", path); + exit(1); + } + /* Get a UNIX socket. */ dev->sock = socket(AF_UNIX, SOCK_STREAM, 0); if (dev->sock == -1) {