Received: by 2002:aa6:da0e:0:b029:115:a171:fe4c with SMTP id z14csp1243385lkb; Wed, 7 Jul 2021 02:21:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4rpufI0uj4Xunrwmrlj+3sp58J2fZi8dm/nlrDLu8p486iSf+AQp+e7SPqPqHlJhzNv5Y X-Received: by 2002:a02:2b27:: with SMTP id h39mr21223200jaa.62.1625649694090; Wed, 07 Jul 2021 02:21:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625649694; cv=none; d=google.com; s=arc-20160816; b=nSSQm5TMcUDzg+IXhl5l2PZoegfdrgjzeYJ2mWZqopyLDd0LBIGwM0+VYZlnrCzZlC OeG6qq0f9MdVOGetjXekot1qVRT7RKKY1Lrhxrhs2ABIPtNcJcbTilfNdSdju6DBjKzl nXdQ85RYcgYrlMgriJ2UgdD0qkmt8KVJ+KkFsVICtxLJTgurpA4mBDWLdejhp1M6K8Ey IxHs+rLjjoage1CeY6BG2/5RKWN9MDS98nJMFy9LyqvPIdYD8neoeOmKbrzZ41dirSXo 7flRlW3FZIQeev9J4OA+v+H887Xa+eyfxpdO1Hxg//nvbUAzeVbpvLbEVe3eGApuK2/2 3MQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ntF5ShiMpxZzH3NgDCu0lj/qLit/wsTznB+iv/n6Jts=; b=qxZL/l7cDlYd47rP6bgGoLkXWQV+u+4lJFyaHDfcHjHeeAgNQ7Yq53sAo9PofQb4vi 0MUsfj+k3qjLC5TMwjUsefAJBm+vSwj7M6yrFMy/t9FsEf63hjbMQgh3RkP9j+RUDHCL u2hTlteL10NWfJ5kMHDtAiOpCkAz0IybTZdPbDPm4yRF6zGAboj9s2Mmbk1Y0QM1zGxn nVfiP5HQvcWk0CzeNjElzUw1pKsD1s3hGYOvH6NQHqhjGYeYufWUawEubsWKJSKjNqxT /FNYX45YcdWnGJgPW9fA1l/kKDQP55wmGeey257iIsuTjcEqQMTsmbQ/OsF9V0yA+Ab5 r/eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=EkUktZhV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h26si18869103jav.114.2021.07.07.02.21.22; Wed, 07 Jul 2021 02:21:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=EkUktZhV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231363AbhGGJW3 (ORCPT + 99 others); Wed, 7 Jul 2021 05:22:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231357AbhGGJW2 (ORCPT ); Wed, 7 Jul 2021 05:22:28 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57C3DC061574 for ; Wed, 7 Jul 2021 02:19:47 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id i20so2189770ejw.4 for ; Wed, 07 Jul 2021 02:19:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ntF5ShiMpxZzH3NgDCu0lj/qLit/wsTznB+iv/n6Jts=; b=EkUktZhVW6Hw0D3CwFrVu6SPtBCLkJYy2M7BJM1xaa8T71w3Am8UIGnGLzZ7sZjGBy oJPZFOsWMkQsg1Eor8GYHzrS0gvtg/qEnI+kjIYCFKEPoLzQIQX6UgYFrffMXB7uW8ud DAJeTUNRxqnYoE0JTnNDRQ4iWBS+hwKVMh6CzB8D/Nd7MUwmVBFXb/1DGoN5IcQxOlxA XEcMYCGgJ6/e1b9/F4uGKBE66Lafq27VxOH+bGLgnrQlIyePfFxmfVAzA2OsUgePTZRJ T3ukDS1lDG6sIQr7dau/XyarH0KZbl27sp8FmAm/INCn+Zavbu6Ds2cG23H+ZLiJNIkK nv1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ntF5ShiMpxZzH3NgDCu0lj/qLit/wsTznB+iv/n6Jts=; b=W2gCE12emIy3Ypme+0C52MxH1hOPG3356+X8qK7q9OGMDeDyzEvj0jljnv9dnyawqq efumeLAjsLMsIr/h5TMtPEq5IsLG6Ne5lr05Fq+io7PR3BzKWtKMDKECkm98AcpNPvnv uFSXEpKlX7sL5Jq7SmqO8L5XxxbDjaiFhnMI4PDoooLdcdvJWczd8A/sjX5Hjq8aKDoE pVzXhOSD19gx+nBZUcPKYT0xcwlkuNmxqBIEq8gDFEJAwIbbGFAK0XgRkppNJOBWal2t wfixbVL+oMWXRcYCaCTFCtHBIQUWHlLUjWaowFoS2XsmfV5VRYLwZsohZmF++lmOg/Zq HEtw== X-Gm-Message-State: AOAM533gPHZeHfoOI6S1S99TN9J2LIN4GOjug6wIkhnWeQYjkSAcWhqr 6VwD+lSzGyUjEtIF2eS8EY4NeIBzkRskgHbzmOZQ X-Received: by 2002:a17:906:cb93:: with SMTP id mf19mr20870738ejb.427.1625649585892; Wed, 07 Jul 2021 02:19:45 -0700 (PDT) MIME-Version: 1.0 References: <20210615141331.407-1-xieyongji@bytedance.com> <20210615141331.407-10-xieyongji@bytedance.com> In-Reply-To: From: Yongji Xie Date: Wed, 7 Jul 2021 17:19:35 +0800 Message-ID: Subject: Re: [PATCH v8 09/10] vduse: Introduce VDUSE - vDPA Device in Userspace To: Stefan Hajnoczi Cc: "Michael S. Tsirkin" , Jason Wang , Stefano Garzarella , Parav Pandit , Christoph Hellwig , Christian Brauner , Randy Dunlap , Matthew Wilcox , Al Viro , Jens Axboe , bcrl@kvack.org, Jonathan Corbet , =?UTF-8?Q?Mika_Penttil=C3=A4?= , Dan Carpenter , joro@8bytes.org, Greg KH , songmuchun@bytedance.com, virtualization , netdev@vger.kernel.org, kvm , linux-fsdevel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 7, 2021 at 4:53 PM Stefan Hajnoczi wrote: > > On Tue, Jun 15, 2021 at 10:13:30PM +0800, Xie Yongji wrote: > > +static bool vduse_validate_config(struct vduse_dev_config *config) > > +{ > > The name field needs to be NUL terminated? > I think so. > > + case VDUSE_CREATE_DEV: { > > + struct vduse_dev_config config; > > + unsigned long size = offsetof(struct vduse_dev_config, config); > > + void *buf; > > + > > + ret = -EFAULT; > > + if (copy_from_user(&config, argp, size)) > > + break; > > + > > + ret = -EINVAL; > > + if (vduse_validate_config(&config) == false) > > + break; > > + > > + buf = vmemdup_user(argp + size, config.config_size); > > + if (IS_ERR(buf)) { > > + ret = PTR_ERR(buf); > > + break; > > + } > > + ret = vduse_create_dev(&config, buf, control->api_version); > > + break; > > + } > > + case VDUSE_DESTROY_DEV: { > > + char name[VDUSE_NAME_MAX]; > > + > > + ret = -EFAULT; > > + if (copy_from_user(name, argp, VDUSE_NAME_MAX)) > > + break; > > Is this missing a NUL terminator? Oh, yes. Looks like I need to set '\0' to name[VDUSE_VDUSE_NAME_MAX - 1] here. Thanks, Yongji