From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E29CEC742A6 for ; Fri, 12 Jul 2019 02:22:46 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 7129E21019 for ; Fri, 12 Jul 2019 02:22:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YyZBVKZD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7129E21019 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7F9EC322C; Fri, 12 Jul 2019 04:22:45 +0200 (CEST) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id 3FFFB2C6A; Fri, 12 Jul 2019 04:22:44 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id q10so3595532pff.9; Thu, 11 Jul 2019 19:22:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=7vcaPFDJ1Ghfnxg4XkY5XVPk+FhoBph2Ld4bjRLEJI4=; b=YyZBVKZD1ViPvdFuYJcNkOgVherS7GPSsa34g1NW1GshdiFj7lOnv29r0RjcnnksuP ZZH1ke+X9jfO/xgPWyUikqpmC1ClYXmFUGMobTAjCPJjsQdTnQUnQufx/38bg0AgsEnj xE4hIIC8+/zrUfNAfFPD6Wv0xr2jHwR1Ra5yonP90egNd2UcA0dHIVL2rJTRop8/U+Gg /OulvqTLGlU7hhHHj6ZKD9YmgY3j64kxpfCBv/IT7/Cl5e6kFBOzseKzl4VMAcm7Jxp7 Vc+tVoHtXLsNWa0TO88jTIjbIb7xj4KpNv52XVTQJOXV2j0gxP/KnM1notcndhkyicGi KNEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=7vcaPFDJ1Ghfnxg4XkY5XVPk+FhoBph2Ld4bjRLEJI4=; b=t5JVrZy4X8GxIKisiOGUFu2NIjKsQUMbtKFYW0DOG2fE0Wng6zVtSH73kPbD3HKKsX TtShKyOPMgH1P+ad0sHod5MGOq3FYEsxawk1CTouzrdSAy0pw372rXG2AqlaBn+VguGG BfhOZw7/Kq99fskQblO/Xf3xsXxwkAgyLkfrcsFNoBru+b15OQLi2cKpZGM9CUCmg+3F FFaYS6ITcwqIWLSd1P7gGECSoCFs2vcD/Z/dZj70YVbyz1tLbuf50+IMHmIx09K93Vzs v5Mhkx/XCohiMYHK1w8JLOOrlYuG9PUxQ200PVysDNtrXJHajbxjxorcVyh9UH+VK6mH AoTQ== X-Gm-Message-State: APjAAAXAuK/Xz2dWp9X2L4GciHQg87F86KtEEixAxZ6WFwvjABKhrHZH li4W6DQFJmd9FQ8qBq/lXBs= X-Google-Smtp-Source: APXvYqxrJg43ZHFPYTGGRWn5VQODNk/SQmW9belvZr5xBsF5Bzy2D9F6U6rgHKTSbvfqlXFV2FyG/g== X-Received: by 2002:a63:89c7:: with SMTP id v190mr7554615pgd.299.1562898163507; Thu, 11 Jul 2019 19:22:43 -0700 (PDT) Received: from mugwort.local ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id cx22sm5737013pjb.25.2019.07.11.19.22.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2019 19:22:42 -0700 (PDT) To: "Burakov, Anatoly" , david.marchand@redhat.com Cc: dev@dpdk.org, stable@dpdk.org, Yasufumi Ogawa References: <1555379952-23517-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> <20190711103148.9187-1-yasufum.o@gmail.com> <20190711103148.9187-2-yasufum.o@gmail.com> From: Yasufumi Ogawa Message-ID: <99d2853d-f6f9-59f2-f853-0f9222e8cb5d@gmail.com> Date: Fri, 12 Jul 2019 11:22:37 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v3 1/1] fbarray: get fbarrays from containerized secondary X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 2019/07/11 22:14, Burakov, Anatoly wrote: > On 11-Jul-19 12:57 PM, Yasufumi Ogawa wrote: >> On 2019/07/11 19:53, Burakov, Anatoly wrote: >>> On 11-Jul-19 11:31 AM, yasufum.o@gmail.com wrote: >>>> From: Yasufumi Ogawa >>>> >>> <...> >>> >>>> +    if (getpid() == 1) { >>>> +        FILE *hn_fp; >>>> +        hn_fp = fopen("/etc/hostname", "r"); >>>> +        if (hn_fp == NULL) { >>>> +            RTE_LOG(ERR, EAL, >>>> +                "Cannot open '/etc/hostname' for secondary\n"); >>>> +            return -1; >>>> +        } >>>> + >>>> +        /* with docker, /etc/hostname just has one entry of >>>> hostname */ >>>> +        if (fscanf(hn_fp, "%s", proc_id) == EOF) { >>> >>> Apologies for not pointing this out earlier, but do i understand >>> correctly that there's no bounds checking here, and fscanf() will >>> write however many bytes it wants? >> I understand "%s" is not appropriate. hostname is 12 bytes char and I >> thought proc_id[16] is enough, but it is unsafe. In addition, hostname >> can be defined by user with docker's option, so it should be enough >> for user defined name. >> >> How do you think expecting max 32 chars of hostname and set boundary >> "%32s" as following? >> >>      proc_id[33];  /* define proc id from hostname less than 33 bytes. */ >>      ... >>      if (fscanf(hn_fp, "%32s", proc_id) == EOF) { >> > > As long as it takes NULL-termination into account as well, it should be > OK. I can't recall off the top of my head if %32s includes NULL > terminator (probably not?). Do you agree if initialize with NULL chars to ensure proc_id is NULL-terminated? As tested on my environment, "%Ns" sets next of Nth char as NULL, but it seems more reliable. proc_id[33] = { 0 }; Yasufumi