From patchwork Wed Aug 9 17:50:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 711934 Delivered-To: patch@linaro.org Received: by 2002:a05:6359:baf:b0:129:c516:61db with SMTP id gf47csp135607rwb; Wed, 9 Aug 2023 10:51:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqZx9h8MDEhslPjLeLwu7Oiv2CV8+g9BHAsredNXpBgvMdpSV1LcmU7/bs+GBPfswi3KRg X-Received: by 2002:a05:622a:34e:b0:403:1c7a:6c70 with SMTP id r14-20020a05622a034e00b004031c7a6c70mr3815qtw.38.1691603483193; Wed, 09 Aug 2023 10:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691603483; cv=none; d=google.com; s=arc-20160816; b=wTLGW5Yw1tND9E0ozHtCRmtK1BszdwKU4IlUhCBTypQf9Hl6vo5S57br/7psGmUxEz wbHah/fVmoSsSSTR28RjjP/pFlSmhkVqS29NRv47PvxRF74Y4d4Jy2bqI/wotAKtD1NG qhx+tcniQzUiDEwO34uOPfFJZCjFQLVP7sbJr+2Lhis8YGcev0RcNVVvqJpgF0IEAx/6 5ZFWYzt9m/oY8ncmed/uR00Lzg73Qe6uHAceVpin+0aYJupxgR66IHLDkPQWquDQftDm TKwuzSrnG13av5TkBBbRJZ77rl1V0ipBPR8Caf/t37RseZsBz5CmaGbLye+mgCgyNscG Tuhw== 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=jv2rFQy8ox3PX4o5HcVDJ943M2bxOe2uVjR6ZEkXsuQ=; fh=JlK1pa20GwzzNp50CN29wjg9rx9SVZ0Bc99vphlFFiA=; b=KhLf5mDDR2U9qJX8zz/b3TT3TwW/Ih8k6sE0AwngQGgQ53dhcQQe6rZ6ZSa9lU2JEJ j7abXYfRngvxX2au1mONgSU85kIHT3TeD32Xkv/7430m+kI6/THsAdVP7lvcPH7wXIN9 Y3srRoDSHIrKlMx0knkgeV6y9W15tC7X1WHv55JMgFa6yMcgvFreWdTnjHTtBH36O6df a+x9jDwr0I57UtTqr1CrW85QGZRvyZ2FO9z0vJsfm2cQFwdK/uwiTviowCvkRrhK7IvF UV1D5cr8SYgsC2H6ymNlUOtmY9S7DGrEYD1H6LtW8zRO9GxSe2wMJK/bVjF4NPxANf5p LTPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OR4mZc1P; 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: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c8-20020a05622a024800b0040f854a0f5esi8152957qtx.646.2023.08.09.10.51.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Aug 2023 10:51:23 -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=OR4mZc1P; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTnK4-0000PG-Dl; Wed, 09 Aug 2023 13:50:16 -0400 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 1qTnJz-0000NA-LP for qemu-devel@nongnu.org; Wed, 09 Aug 2023 13:50:11 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qTnJy-0005eE-0L for qemu-devel@nongnu.org; Wed, 09 Aug 2023 13:50:11 -0400 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-26834a73b8dso24308a91.2 for ; Wed, 09 Aug 2023 10:50:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691603408; x=1692208208; 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=jv2rFQy8ox3PX4o5HcVDJ943M2bxOe2uVjR6ZEkXsuQ=; b=OR4mZc1Pc0zGjoBELSZoM+eVnA4MttDG+51/ZIgdp4d+nvUAZsbYIKi1ltLPGREefQ MZbI/hC9daAnhSq0UnnPS5oqQTwLyS3lSI6eYJUqTUpI4sWH8OrBUpiq6vDq7r1q3Bx7 KTCw90+1aiy+UsrrxxQJxEM5XJydmS3fPT3CMZ3dmZNjAsvxRqV/WFS5eIZCzZDLK1Q4 e0KChBTRHrHKCjQGYpY/bRVBTJzhJg1V0KcfGEAel2TjMogD0DaVSxhJb2BgCul/l/Tf 5UxOrJtkVyAIF913kDx+nadVcJSATPVcIPU5SWSU60KKq7GfTmCRlPs6P7dWqg8Dj9dq pKsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691603408; x=1692208208; 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=jv2rFQy8ox3PX4o5HcVDJ943M2bxOe2uVjR6ZEkXsuQ=; b=LwIlLb44rv7uH99AssiImt/bfbZwy8oIqTPvpnCkhlZmol9erJTwCL0QoR8cUuhsyE XoPaKvnNfjqq24TrRAuyQafKxHChXk5r0wQO6KyvCxsK+fxi+483epoCvr3kc5tXmpjQ BcOKAq1ZNP1v8TMkB95UoSgu+OV3geNot6tLmXgywB5vUAhEjfP91G60reY7PJP9jpXN az21kxf+aC6Gb/NUEmDKWUCF9uovxwfhGVQ3yJeEeQDm1ROdXFOdD4Werbesxy7IZG5R R5Vs4HRylCwF0ylfjZpOobgU0i6H/2gvy792UJfBGEaAAUJtvE2vNs0r1IcEP38EMkKi lpHg== X-Gm-Message-State: AOJu0YwN3iOlDN6WDFWKziKRRY3DfSZhLE+9cYlEJ1KLq+FJm/A0Coyg pbtRmrpmdK+NcS7SMdfX/tZs2UWZ3NpXam/6/40= X-Received: by 2002:a17:90a:8982:b0:256:8dbd:74fa with SMTP id v2-20020a17090a898200b002568dbd74famr5198pjn.22.1691603408564; Wed, 09 Aug 2023 10:50:08 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:6bf0:9674:6ac4:f74c]) by smtp.gmail.com with ESMTPSA id y7-20020a17090a2b4700b0025dc5749b4csm1753710pjc.21.2023.08.09.10.50.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 10:50:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Akihiko Odaki , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 1/6] qemu/osdep: Remove fallback for MAP_FIXED_NOREPLACE Date: Wed, 9 Aug 2023 10:50:01 -0700 Message-Id: <20230809175006.242479-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230809175006.242479-1-richard.henderson@linaro.org> References: <20230809175006.242479-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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=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: 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 In order for our emulation of MAP_FIXED_NOREPLACE to succeed within linux-user target_mmap, we require a non-zero value. This does not require host kernel support, merely the bit being defined. MAP_FIXED_NOREPLACE was added with glibc 2.28. From repology.org: Fedora 36: 2.35 CentOS 8 (RHEL-8): 2.28 Debian 11: 2.31 OpenSUSE Leap 15.4: 2.31 Ubuntu LTS 20.04: 2.31 Reported-by: Akihiko Odaki Reviewed-by: Akihiko Odaki Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20230808164418.69989-1-richard.henderson@linaro.org> --- include/qemu/osdep.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index cc61b00ba9..21ef8f1699 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -289,9 +289,6 @@ void QEMU_ERROR("code path is reachable") #ifndef MAP_ANONYMOUS #define MAP_ANONYMOUS MAP_ANON #endif -#ifndef MAP_FIXED_NOREPLACE -#define MAP_FIXED_NOREPLACE 0 -#endif #ifndef MAP_NORESERVE #define MAP_NORESERVE 0 #endif From patchwork Wed Aug 9 17:50:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 711936 Delivered-To: patch@linaro.org Received: by 2002:a05:6359:baf:b0:129:c516:61db with SMTP id gf47csp135792rwb; Wed, 9 Aug 2023 10:51:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7MmaH49SSF7svTCPLLAqV7SQgyqn88ZgThlWtYZEJLzET/322BuPjWv2YUWEz+GdAM+R7 X-Received: by 2002:a05:620a:3729:b0:76c:e566:2dab with SMTP id de41-20020a05620a372900b0076ce5662dabmr104435qkb.33.1691603507854; Wed, 09 Aug 2023 10:51:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691603507; cv=none; d=google.com; s=arc-20160816; b=xYJgi2DhoSDM8XJIu3a1OTafwxPGBkafztDVhykGABeuwAOYuJOrLMUdkVbj00U4RS 7/Ei8FNlUF0ZiV+zWlsfn1Qeb4tibq06eRUZPK8Ye3HMiXBB0hFD6ZoUEK4ECTZUadm5 K4dEAOFV2ryRuh7j1H9s2JKmLlkXbPymUJ2Hb9AIIF1hxB3xUw8b+B+7hahiafSu6A61 vejtDia5vHbB8/PHvZpbpD/w6ZAkSG4S7bT60zKfanFrHM1lFLszHZv3MaK0MnQIPbMf 94Qe0a3I+C7u1L1O+Q+6T72qmpyeAmM/OaZuRrRPcAtXdJ3znkmtY+Z8s1ReIHFJq/4y OZuQ== 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=nhNF3NyHA/myxtoiTxBoO60EtQZnT1Z9BPdTCvWzf8U=; fh=ZuLSLtzpwbOj79Lm6HQkAzCl7AYBeBRT4Q/1zeFcrQg=; b=Y9eNQ6w93k+MP17OGEkk/ph+VPgywAiwoR6IfRLUMpEJNTHtFqcyzjd3pz7ezxSN6z 0MiCXXTiGj/UeptYsGdDg+SZd9B9qRNvCwAFw2Ga6pvNfTx84HIx0SlZpMIg394zzaXo /alVMqEJPei4he1YFPArZrd6xzNw08xltpLhJhpne0q5EUPZUYINWYPpVJGblp1XyQ+E ndBZyumrH5qpRuq/TUmz1AO24Op81bxg982VSeDXq8tr9jL42xAEMczUassTufFvTDcd oIOa8ZivYafvupy8EyOgE6cxLxC98Mn2ljgFs5Ma1OYziFd+OT+5b6Kw5M6Np7E5SIGr EDGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zWUgX+fh; 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: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q14-20020a05620a024e00b0076d1ef165easi1803636qkn.709.2023.08.09.10.51.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Aug 2023 10:51:47 -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=zWUgX+fh; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTnK4-0000Pl-P3; Wed, 09 Aug 2023 13:50:16 -0400 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 1qTnK1-0000Nl-Gq for qemu-devel@nongnu.org; Wed, 09 Aug 2023 13:50:13 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qTnJz-0005eQ-O6 for qemu-devel@nongnu.org; Wed, 09 Aug 2023 13:50:13 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-52cb8e5e9f5so56240a12.0 for ; Wed, 09 Aug 2023 10:50:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691603409; x=1692208209; 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=nhNF3NyHA/myxtoiTxBoO60EtQZnT1Z9BPdTCvWzf8U=; b=zWUgX+fhUvdee5k0J+N9Z0FPmZYymCZcYG5MB7TsadQkoVAf7h1beinLTIwFrYXWjI 6eLHGpyrfbkc1N6iGmulcF1Ema2C3BPbDg7DfxpR3xnbi9QAhrSr331kbFO0zbMypDrr XvMTwXvKVxiZezr2MPfpmNkd7Pnb3fQ/4OADuCi1ptHoLlaXOJzcYQVPoTdRq+csnMMZ emcqnzJuWpqMFAFV5vA+IrPrcVb30I3zv/AUOrTTylCvJDVy2vGosIUKq3YyyvzystZr kizMJDt+quygb0SVWlekOhcfzjYmXg2w8cImZ3F69FnUHFKjBsB/7IFX6J4lTMoey6X1 yX8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691603409; x=1692208209; 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=nhNF3NyHA/myxtoiTxBoO60EtQZnT1Z9BPdTCvWzf8U=; b=N03POJZwgz35q6URt/yJBaA7iKPGMQo7Z/+i0tSQh31IQ5IlW7MY6LwI8wXxgVzdIv rV0bgtlrKerPDHrk5zj/RB3Jzj3jSghlCpEkgn9wxzgSCpb3d3ryszKDItBzEd2U0azd heozeHqubcp4q7ZLy1ZeeXj9Zg4yLb7O9Q1PZeEupe7VFxPh41skdEbsOHWUlMTSlUaf GHwN4QpZxE6Mv4Tyr4vHJFPRkFrttl1712zQydKHot/96ySF4v9V6nd+VBqDCf3BSNgn gqy2L5r6+9yDNv63JHe1PPNUNHYLzBQXf/tHVnRypPDLHBsRlbyHUPsK4TH2r/XYlpEK VxKg== X-Gm-Message-State: AOJu0YxZgyEVns5WjH7FPjuvF2GadJEOBPygaL6k1T58b6orZEAT22ql dIojq4s1AWdARqa7VIJpw6Jo99FEJ6M/MtXpkEk= X-Received: by 2002:a17:90b:370b:b0:267:f1d7:ed68 with SMTP id mg11-20020a17090b370b00b00267f1d7ed68mr97142pjb.14.1691603409441; Wed, 09 Aug 2023 10:50:09 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:6bf0:9674:6ac4:f74c]) by smtp.gmail.com with ESMTPSA id y7-20020a17090a2b4700b0025dc5749b4csm1753710pjc.21.2023.08.09.10.50.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 10:50:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 2/6] linux-user: Split out do_mmap Date: Wed, 9 Aug 2023 10:50:02 -0700 Message-Id: <20230809175006.242479-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230809175006.242479-1-richard.henderson@linaro.org> References: <20230809175006.242479-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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=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: 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 New function that rejects unsupported map types and flags. In 4b840f96 we should not have accepted MAP_SHARED_VALIDATE without actually validating the rest of the flags. Fixes: 4b840f96 ("linux-user: Populate more bits in mmap_flags_tbl") Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- linux-user/syscall.c | 90 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 73 insertions(+), 17 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a15bce2be2..34deff0723 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5985,10 +5985,6 @@ static const StructEntry struct_termios_def = { #endif static const bitmask_transtbl mmap_flags_tbl[] = { - { TARGET_MAP_TYPE, TARGET_MAP_SHARED, MAP_TYPE, MAP_SHARED }, - { TARGET_MAP_TYPE, TARGET_MAP_PRIVATE, MAP_TYPE, MAP_PRIVATE }, - { TARGET_MAP_TYPE, TARGET_MAP_SHARED_VALIDATE, - MAP_TYPE, MAP_SHARED_VALIDATE }, { TARGET_MAP_FIXED, TARGET_MAP_FIXED, MAP_FIXED, MAP_FIXED }, { TARGET_MAP_ANONYMOUS, TARGET_MAP_ANONYMOUS, MAP_ANONYMOUS, MAP_ANONYMOUS }, @@ -6006,7 +6002,6 @@ static const bitmask_transtbl mmap_flags_tbl[] = { Recognize it for the target insofar as we do not want to pass it through to the host. */ { TARGET_MAP_STACK, TARGET_MAP_STACK, 0, 0 }, - { TARGET_MAP_SYNC, TARGET_MAP_SYNC, MAP_SYNC, MAP_SYNC }, { TARGET_MAP_NONBLOCK, TARGET_MAP_NONBLOCK, MAP_NONBLOCK, MAP_NONBLOCK }, { TARGET_MAP_POPULATE, TARGET_MAP_POPULATE, MAP_POPULATE, MAP_POPULATE }, { TARGET_MAP_FIXED_NOREPLACE, TARGET_MAP_FIXED_NOREPLACE, @@ -6016,6 +6011,75 @@ static const bitmask_transtbl mmap_flags_tbl[] = { { 0, 0, 0, 0 } }; +/* + * Arrange for legacy / undefined architecture specific flags to be + * ignored by mmap handling code. + */ +#ifndef TARGET_MAP_32BIT +#define TARGET_MAP_32BIT 0 +#endif +#ifndef TARGET_MAP_HUGE_2MB +#define TARGET_MAP_HUGE_2MB 0 +#endif +#ifndef TARGET_MAP_HUGE_1GB +#define TARGET_MAP_HUGE_1GB 0 +#endif + +static abi_long do_mmap(abi_ulong addr, abi_ulong len, int prot, + int target_flags, int fd, off_t offset) +{ + /* + * The historical set of flags that all mmap types implicitly support. + */ + enum { + TARGET_LEGACY_MAP_MASK = TARGET_MAP_SHARED + | TARGET_MAP_PRIVATE + | TARGET_MAP_FIXED + | TARGET_MAP_ANONYMOUS + | TARGET_MAP_DENYWRITE + | TARGET_MAP_EXECUTABLE + | TARGET_MAP_UNINITIALIZED + | TARGET_MAP_GROWSDOWN + | TARGET_MAP_LOCKED + | TARGET_MAP_NORESERVE + | TARGET_MAP_POPULATE + | TARGET_MAP_NONBLOCK + | TARGET_MAP_STACK + | TARGET_MAP_HUGETLB + | TARGET_MAP_32BIT + | TARGET_MAP_HUGE_2MB + | TARGET_MAP_HUGE_1GB + }; + int host_flags; + + switch (target_flags & TARGET_MAP_TYPE) { + case TARGET_MAP_PRIVATE: + host_flags = MAP_PRIVATE; + break; + case TARGET_MAP_SHARED: + host_flags = MAP_SHARED; + break; + case TARGET_MAP_SHARED_VALIDATE: + /* + * MAP_SYNC is only supported for MAP_SHARED_VALIDATE, and is + * therefore omitted from mmap_flags_tbl and TARGET_LEGACY_MAP_MASK. + */ + if (target_flags & ~(TARGET_LEGACY_MAP_MASK | TARGET_MAP_SYNC)) { + return -TARGET_EOPNOTSUPP; + } + host_flags = MAP_SHARED_VALIDATE; + if (target_flags & TARGET_MAP_SYNC) { + host_flags |= MAP_SYNC; + } + break; + default: + return -TARGET_EINVAL; + } + host_flags |= target_to_host_bitmask(target_flags, mmap_flags_tbl); + + return get_errno(target_mmap(addr, len, prot, host_flags, fd, offset)); +} + /* * NOTE: TARGET_ABI32 is defined for TARGET_I386 (but not for TARGET_X86_64) * TARGET_I386 is defined if TARGET_X86_64 is defined @@ -10536,28 +10600,20 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, v5 = tswapal(v[4]); v6 = tswapal(v[5]); unlock_user(v, arg1, 0); - ret = get_errno(target_mmap(v1, v2, v3, - target_to_host_bitmask(v4, mmap_flags_tbl), - v5, v6)); + return do_mmap(v1, v2, v3, v4, v5, v6); } #else /* mmap pointers are always untagged */ - ret = get_errno(target_mmap(arg1, arg2, arg3, - target_to_host_bitmask(arg4, mmap_flags_tbl), - arg5, - arg6)); + return do_mmap(arg1, arg2, arg3, arg4, arg5, arg6); #endif - return ret; #endif #ifdef TARGET_NR_mmap2 case TARGET_NR_mmap2: #ifndef MMAP_SHIFT #define MMAP_SHIFT 12 #endif - ret = target_mmap(arg1, arg2, arg3, - target_to_host_bitmask(arg4, mmap_flags_tbl), - arg5, (off_t)(abi_ulong)arg6 << MMAP_SHIFT); - return get_errno(ret); + return do_mmap(arg1, arg2, arg3, arg4, arg5, + (off_t)(abi_ulong)arg6 << MMAP_SHIFT); #endif case TARGET_NR_munmap: arg1 = cpu_untagged_addr(cpu, arg1); From patchwork Wed Aug 9 17:50:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 711931 Delivered-To: patch@linaro.org Received: by 2002:a05:6359:baf:b0:129:c516:61db with SMTP id gf47csp135481rwb; Wed, 9 Aug 2023 10:51:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEx6yS1M0d0H2vFLTybyKBHg92aFX3HRpURNMM6tNR/+fmSdGTYYYqtEd4m1EKyH46USZW4 X-Received: by 2002:a05:622a:d2:b0:40f:f45c:742a with SMTP id p18-20020a05622a00d200b0040ff45c742amr22681qtw.56.1691603469414; Wed, 09 Aug 2023 10:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691603469; cv=none; d=google.com; s=arc-20160816; b=MYna6Z9PXHDqMslBC7I/kcrmUtvFwfLjOL07zydS0T53cbxuzZkqXIJrv0qjXlbQlc HbULRob8AdUUTCiwYODW5PTH5KokPbk/DniBOq94oR+r+s90UqCPVRzJDD8r5UNA0POj INLCEbWmnWTrJQdjC18tXaNgLJgpCbzOp5loWfK9AdLcfnaAbpaVkQKlwVYs6ky/Fmuh QX+0EsoXlNgZE+t/GpXBKRFdmQ2ofOKVCQasjcIQPOZWWsFmn1ZFiMJqUFdhsQmuOMmM vi63AZcD8ucurbPKSqvPAsJdLxKheMseNTQvJyF4Qwr+RHSzOOhj//lUPhR9nt+0i6ZI 9Mcg== 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=8ruCO9g4FxvWKS5aunRaaaf+G4BXGwigkv65s5BXgQ4=; fh=ZuLSLtzpwbOj79Lm6HQkAzCl7AYBeBRT4Q/1zeFcrQg=; b=ZubNgobZaQoSOdlL/bQ0CjScZcIEOIBAoNvJyJ3jzk07/PVcgJPHWOqVQialIbr+zP YvbQXRdR3c7Ms7R0nHdVffJ8gUOlQiGF1K15jkE3vwmz9ES2LpEMDZgLjVx6t78hTRl6 V336NqYM4D5FIN3DwpfD5TKlafBoaggvapKUOnFHiGurDV1+q1LbiiVCFGuNmoWv/CU9 mb5xY2xJCqWRy7uVohyJI7Q/43KVj3fI4VyHvNaq4ofxNFZq8r+1VMSVoyBjIuiFeBhm JCwp/mzi6ZBpvJYlXPwdE5Ch/O48lZAiu6TCdF+w45EO4d4qnebmvD/544N5VkKtxY07 pTxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Rg/DZA4m"; 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: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o8-20020a05622a044800b00403e8415852si7612187qtx.567.2023.08.09.10.51.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Aug 2023 10:51:09 -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="Rg/DZA4m"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTnK2-0000OA-S5; Wed, 09 Aug 2023 13:50:14 -0400 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 1qTnK1-0000No-La for qemu-devel@nongnu.org; Wed, 09 Aug 2023 13:50:13 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qTnJz-0005ee-RW for qemu-devel@nongnu.org; Wed, 09 Aug 2023 13:50:13 -0400 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-565331f0736so113703a12.0 for ; Wed, 09 Aug 2023 10:50:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691603410; x=1692208210; 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=8ruCO9g4FxvWKS5aunRaaaf+G4BXGwigkv65s5BXgQ4=; b=Rg/DZA4mVQoJFeKsZ3+Ss9fh2orzrC1/kXVKSPgDplEos+gXYJ/Rm4WBYqcnITWGdp AN0sLx3knu6OtpwWx251K25Iz1uuEJuNKaP3KdPGzR0W6MFZ09aG4xhsqtRe2O5JU5S1 sN+GbNMvnOHAXpzLiS+csXWDaOYXpBHKmD0q5N5y9N5UhEynKuUSdLJX69ZXXdGj63GH nm6pcoUKLcZDLRi169GcEZjPWKzA/wWD3nxIKNvS+F4YOmOuGIRVTOe/ipdHwH9egAni FBc8ebaV8P0DcHPOZ91b+Twd8l8hICtKUWbrevvI4YM90J71gSouBt37FxtqqGxXX5dR CKTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691603410; x=1692208210; 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=8ruCO9g4FxvWKS5aunRaaaf+G4BXGwigkv65s5BXgQ4=; b=KubjUPaGVyFHydnMy/43HQAihiCPVtlnI+Fk6h7MqRfe8x3iSd/mP6UBoHufqPk4ng d2FxS94CNJAo6pIJdCkrAyHgSI9pjGQBvxo6WrJnk4GGzWutqx/tzB7/blt7iJrWFN0T K+evZ29afBLMHdtJMhFAKmNg2Y1PxMEWaiLSeV166gNmah8//cLHdpv43ln7ZDU76SXZ 6ISZRun1JPw9d6sAslwIEBYMPT3buLXFxkrMXkgkxI9++aaqv8jvKZ8B/4JmL5epgYQx b+A+yiw4VdH1qqQLsjWQvH/WQDkmoFqvZh2JUs59GVtn93gbBGqYChjv9Wqw45m2qC6O norQ== X-Gm-Message-State: AOJu0YxPjhMUIDYUkj7iu3+CqaD+1OJxvVDEaeMBUOgYzg5CrTJuGXlv DPYxw1WcTqzwTfN8B43vrTYXBpC78FKms8kj3Hg= X-Received: by 2002:a17:90a:7e87:b0:263:72fe:3ef7 with SMTP id j7-20020a17090a7e8700b0026372fe3ef7mr2686808pjl.42.1691603410422; Wed, 09 Aug 2023 10:50:10 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:6bf0:9674:6ac4:f74c]) by smtp.gmail.com with ESMTPSA id y7-20020a17090a2b4700b0025dc5749b4csm1753710pjc.21.2023.08.09.10.50.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 10:50:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 3/6] linux-user: Use ARRAY_SIZE with bitmask_transtbl Date: Wed, 9 Aug 2023 10:50:03 -0700 Message-Id: <20230809175006.242479-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230809175006.242479-1-richard.henderson@linaro.org> References: <20230809175006.242479-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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=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: 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 Rather than using a zero tuple to end the table, use a macro to apply ARRAY_SIZE and pass that on to the convert functions. This fixes two bugs in which the conversion functions required that both the target and host masks be non-zero in order to continue, rather than require both target and host masks be zero in order to terminate. This affected mmap_flags_tbl when the host does not support all of the flags we wish to convert (e.g. MAP_UNINITIALIZED). Mapping these flags to zero is good enough, and matches how the kernel ignores bits that are unknown. Fixes: 4b840f96 ("linux-user: Populate more bits in mmap_flags_tbl") Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- bsd-user/syscall_defs.h | 2 ++ include/exec/user/thunk.h | 15 +++++++++++---- linux-user/syscall.c | 6 ------ linux-user/thunk.c | 24 ++++++++++++------------ 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h index b6d113d24a..aedfbf2d7d 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -227,7 +227,9 @@ type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ } /* So far all target and host bitmasks are the same */ +#undef target_to_host_bitmask #define target_to_host_bitmask(x, tbl) (x) +#undef host_to_target_bitmask #define host_to_target_bitmask(x, tbl) (x) #endif /* SYSCALL_DEFS_H */ diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h index 300a840d58..6eedef48d8 100644 --- a/include/exec/user/thunk.h +++ b/include/exec/user/thunk.h @@ -193,10 +193,17 @@ static inline int thunk_type_align(const argtype *type_ptr, int is_host) } } -unsigned int target_to_host_bitmask(unsigned int target_mask, - const bitmask_transtbl * trans_tbl); -unsigned int host_to_target_bitmask(unsigned int host_mask, - const bitmask_transtbl * trans_tbl); +unsigned int target_to_host_bitmask_len(unsigned int target_mask, + const bitmask_transtbl *trans_tbl, + size_t trans_len); +unsigned int host_to_target_bitmask_len(unsigned int host_mask, + const bitmask_transtbl * trans_tbl, + size_t trans_len); + +#define target_to_host_bitmask(M, T) \ + target_to_host_bitmask_len(M, T, ARRAY_SIZE(T)) +#define host_to_target_bitmask(M, T) \ + host_to_target_bitmask_len(M, T, ARRAY_SIZE(T)) void thunk_init(unsigned int max_structs); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 34deff0723..12ebc70df5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -455,7 +455,6 @@ static const bitmask_transtbl fcntl_flags_tbl[] = { #if TARGET_O_LARGEFILE != 0 || O_LARGEFILE != 0 { TARGET_O_LARGEFILE, TARGET_O_LARGEFILE, O_LARGEFILE, O_LARGEFILE, }, #endif - { 0, 0, 0, 0 } }; _syscall2(int, sys_getcwd1, char *, buf, size_t, size) @@ -5813,7 +5812,6 @@ static const bitmask_transtbl iflag_tbl[] = { { TARGET_IXOFF, TARGET_IXOFF, IXOFF, IXOFF }, { TARGET_IMAXBEL, TARGET_IMAXBEL, IMAXBEL, IMAXBEL }, { TARGET_IUTF8, TARGET_IUTF8, IUTF8, IUTF8}, - { 0, 0, 0, 0 } }; static const bitmask_transtbl oflag_tbl[] = { @@ -5841,7 +5839,6 @@ static const bitmask_transtbl oflag_tbl[] = { { TARGET_VTDLY, TARGET_VT1, VTDLY, VT1 }, { TARGET_FFDLY, TARGET_FF0, FFDLY, FF0 }, { TARGET_FFDLY, TARGET_FF1, FFDLY, FF1 }, - { 0, 0, 0, 0 } }; static const bitmask_transtbl cflag_tbl[] = { @@ -5876,7 +5873,6 @@ static const bitmask_transtbl cflag_tbl[] = { { TARGET_HUPCL, TARGET_HUPCL, HUPCL, HUPCL }, { TARGET_CLOCAL, TARGET_CLOCAL, CLOCAL, CLOCAL }, { TARGET_CRTSCTS, TARGET_CRTSCTS, CRTSCTS, CRTSCTS }, - { 0, 0, 0, 0 } }; static const bitmask_transtbl lflag_tbl[] = { @@ -5896,7 +5892,6 @@ static const bitmask_transtbl lflag_tbl[] = { { TARGET_PENDIN, TARGET_PENDIN, PENDIN, PENDIN }, { TARGET_IEXTEN, TARGET_IEXTEN, IEXTEN, IEXTEN }, { TARGET_EXTPROC, TARGET_EXTPROC, EXTPROC, EXTPROC}, - { 0, 0, 0, 0 } }; static void target_to_host_termios (void *dst, const void *src) @@ -6008,7 +6003,6 @@ static const bitmask_transtbl mmap_flags_tbl[] = { MAP_FIXED_NOREPLACE, MAP_FIXED_NOREPLACE }, { TARGET_MAP_UNINITIALIZED, TARGET_MAP_UNINITIALIZED, MAP_UNINITIALIZED, MAP_UNINITIALIZED }, - { 0, 0, 0, 0 } }; /* diff --git a/linux-user/thunk.c b/linux-user/thunk.c index dac4bf11c6..071aad4b5f 100644 --- a/linux-user/thunk.c +++ b/linux-user/thunk.c @@ -436,29 +436,29 @@ const argtype *thunk_print(void *arg, const argtype *type_ptr) /* Utility function: Table-driven functions to translate bitmasks * between host and target formats */ -unsigned int target_to_host_bitmask(unsigned int target_mask, - const bitmask_transtbl * trans_tbl) +unsigned int target_to_host_bitmask_len(unsigned int target_mask, + const bitmask_transtbl *tbl, + size_t len) { - const bitmask_transtbl *btp; unsigned int host_mask = 0; - for (btp = trans_tbl; btp->target_mask && btp->host_mask; btp++) { - if ((target_mask & btp->target_mask) == btp->target_bits) { - host_mask |= btp->host_bits; + for (size_t i = 0; i < len; ++i) { + if ((target_mask & tbl[i].target_mask) == tbl[i].target_bits) { + host_mask |= tbl[i].host_bits; } } return host_mask; } -unsigned int host_to_target_bitmask(unsigned int host_mask, - const bitmask_transtbl * trans_tbl) +unsigned int host_to_target_bitmask_len(unsigned int host_mask, + const bitmask_transtbl *tbl, + size_t len) { - const bitmask_transtbl *btp; unsigned int target_mask = 0; - for (btp = trans_tbl; btp->target_mask && btp->host_mask; btp++) { - if ((host_mask & btp->host_mask) == btp->host_bits) { - target_mask |= btp->target_bits; + for (size_t i = 0; i < len; ++i) { + if ((host_mask & tbl[i].host_mask) == tbl[i].host_bits) { + target_mask |= tbl[i].target_bits; } } return target_mask; From patchwork Wed Aug 9 17:50:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 711935 Delivered-To: patch@linaro.org Received: by 2002:a05:6359:baf:b0:129:c516:61db with SMTP id gf47csp135783rwb; Wed, 9 Aug 2023 10:51:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZwBTJvFs109hCVv0emt7eF17h8XwVyogdWlF+AcSx3JEKdj/P7RT/oK6nwGq8DaN0hHUO X-Received: by 2002:ac8:5a84:0:b0:400:a9a4:8514 with SMTP id c4-20020ac85a84000000b00400a9a48514mr63896qtc.22.1691603505440; Wed, 09 Aug 2023 10:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691603505; cv=none; d=google.com; s=arc-20160816; b=doSLr8tnTkwot96B8mEmC3+meepA7PF1aVvG8qKfIMAPEFCLw1l1feBpj/aXcXfEe7 NmKrqgs8AGXHW8jur/4WprGy6yCPgnEoY5uHA5RNInHynPMjhIzDNRTrbJi6SdkZWQ+5 /NreQHlvjtLdYYafsZUrnLxkGSiUCeaOhLZd54Xqt9Fr9UfrnFI++U2ZxE8CnYQGRzgI PkGSHYXOIoMseXEYoJahKW1x8kQaAqF8wEQCk7ueGk7c05Wylnbu0mcEkxY2V2+tn0Sp ezR6J/uHi2WgivTLc4Ay3YvBDJJ0POgK+Gw0uYdFg5kGeeC+zMw98SDMCmXcOXoZ9Weu XFuw== 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=Xcj9HS+1RTdAlktW4alp8Kdowh1zi8Bxa6GJVKLdPCg=; fh=F9+CNiVJwRFefBQuaFQguBFal8jOUM389V8ndcNesT0=; b=Fw3g9PeAotVGjwmMIK5i/uqKYlPX8fYNElL8lBufnxoxo1/BsRkySoW37mxZIkG6ne cUZH+WT2Mj7EH2EfqoTwvDYWYhPEBaDVlc6BPwLyk0wQs9HO47+t9FhGQgAAIQWexCCq RfTZje46suf6gpYuVTjg6y7f0E7hAVRkrzX8yzPxhocjM30ZkJL03Abu8xgJOd/T4l69 sORc4Y2zhEOy0/Tls+Wf1J549OXFaX9HjSRYpvymMw0e53GKo8MbrdSnOzJV6VtOZ4/8 42oOK8FLtgbIUWcB/4Hj/N5hQ6pB6fdBAWMxq0RAcMU8DnNjnMaZQvh6wpvSNJYfQ/6U rK8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MvaYNLo6; 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: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a22-20020a05622a02d600b004039ef1cdd9si7718491qtx.443.2023.08.09.10.51.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Aug 2023 10:51:45 -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=MvaYNLo6; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTnK4-0000PA-Cq; Wed, 09 Aug 2023 13:50:16 -0400 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 1qTnK2-0000OB-Sm for qemu-devel@nongnu.org; Wed, 09 Aug 2023 13:50:14 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qTnK0-0005ex-Ct for qemu-devel@nongnu.org; Wed, 09 Aug 2023 13:50:14 -0400 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-269304c135aso27705a91.3 for ; Wed, 09 Aug 2023 10:50:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691603411; x=1692208211; 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=Xcj9HS+1RTdAlktW4alp8Kdowh1zi8Bxa6GJVKLdPCg=; b=MvaYNLo62LXDxaLB/bW2TAJbhKLyo8tVqtTaPLfpB/58cKtPp9A/e0dH3o2qbwAZZ1 jLtUHXxlAIF9WCZrhDqoX82OD2ykYZ6QCy4OdS9e9Wj0GmscIeDToMlzVJ8Z3X0G4lLc rfzjMbiuB+C/lyWRye0RzDLg02uyTjfPdRQR7row4P6TGI1aA+mFGIgZ6FBjaQiHHZg1 J5HUkq93IqsttOocCxXUWtbfEbCD8VFfmBV02o7OcGCsbAtMcK1jV+OefUxgquzAdnSS VrRtVmrfzC6euAQTBrim5aU0n4uXRRVH1GBNnt5ssbiyRUA1iWMzObWZ6fPRCRBCjr9Q Euig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691603411; x=1692208211; 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=Xcj9HS+1RTdAlktW4alp8Kdowh1zi8Bxa6GJVKLdPCg=; b=au1MFe37GWVX4P1gnSRfDN0bKgGAm+K4XeU6TSTnl8aGgW8lMMOMmvsIEIvqreiJ2E 8Py5BZg8PZL2mdDiUfcFjPfyQcmRxG1TpN0v0jSwf5yzfKkGxB26Nie4Aepeu3CREQ1l DJka74khDxyLge1fFBgnl4th/abyTtf6Qoz92pe+MayyBEuqpAJToQSOM0Nc1Wl9nr4J 8xRzbYvB/2nlJUEn6SlHbNEA4GlqV9CUOV0i3VBz5gzUbEr+gXbPJiizjpNHyCnpOEaK 30dEacKGX3TUaRk2Mz/zjYjM0zvOZ0J+oF8RyRYDXUBKM3A9wfa+/+uCvemLt3IDZZJg S2MQ== X-Gm-Message-State: AOJu0Yyj3V+49zluSKyQCsNXlhrqoz9oo4O6PEoN6EYx68A9tO0XI2Qp 9u5kC83LQ/2Zi9+/gtIbzWLj1/BnKokJy88Tp24= X-Received: by 2002:a17:90a:5b18:b0:268:2523:652c with SMTP id o24-20020a17090a5b1800b002682523652cmr2946945pji.31.1691603411150; Wed, 09 Aug 2023 10:50:11 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:6bf0:9674:6ac4:f74c]) by smtp.gmail.com with ESMTPSA id y7-20020a17090a2b4700b0025dc5749b4csm1753710pjc.21.2023.08.09.10.50.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 10:50:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich Subject: [PULL 4/6] tests/tcg: Disable filename test for info proc mappings Date: Wed, 9 Aug 2023 10:50:04 -0700 Message-Id: <20230809175006.242479-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230809175006.242479-1-richard.henderson@linaro.org> References: <20230809175006.242479-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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=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: 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 This test fails when host page size != guest page size, because qemu may not be able to directly map the file. Fixes: a6341482695 ("tests/tcg: Add a test for info proc mappings") Acked-by: Ilya Leoshkevich Signed-off-by: Richard Henderson --- tests/tcg/multiarch/gdbstub/test-proc-mappings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/tcg/multiarch/gdbstub/test-proc-mappings.py b/tests/tcg/multiarch/gdbstub/test-proc-mappings.py index 7b596ac21b..5e3e5a2fb7 100644 --- a/tests/tcg/multiarch/gdbstub/test-proc-mappings.py +++ b/tests/tcg/multiarch/gdbstub/test-proc-mappings.py @@ -33,7 +33,8 @@ def run_test(): return raise report(isinstance(mappings, str), "Fetched the mappings from the inferior") - report("/sha1" in mappings, "Found the test binary name in the mappings") + # Broken with host page size > guest page size + # report("/sha1" in mappings, "Found the test binary name in the mappings") def main(): From patchwork Wed Aug 9 17:50:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 711933 Delivered-To: patch@linaro.org Received: by 2002:a05:6359:baf:b0:129:c516:61db with SMTP id gf47csp135613rwb; Wed, 9 Aug 2023 10:51:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGn7yeUZcmbzA/CpFElIxHblGOhEJvCjvtQvfMAze022RfU7GI1AorKjUuu4sVn9bECLGsF X-Received: by 2002:a05:6358:94a1:b0:134:e63f:a891 with SMTP id i33-20020a05635894a100b00134e63fa891mr76439rwb.29.1691603484019; Wed, 09 Aug 2023 10:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691603483; cv=none; d=google.com; s=arc-20160816; b=naFI7O+Qm9WG4wHGNbecWmDXB7kR3oKdaGB4wTeQEBafkBdz+nJ7DrvAoPdZgrZZw8 EqIvysTml6H0um5zI9k5qtTPPRlVxCAOaJ947ZgSjIW+ruXa1wM6hhVOwCWybVKKuMsM aF6qGRsH9kSuRqjFmrgTLNTmKo99DhYNauro0poY9cbyIjjPmAFw/kZjF5Pn+ECyYUUX 9E9z9C59S8r3u8YgYFOXlYPLRLWe/PRY1XOuKl/nKv95LxyEj8YHrjjdm36U3PhNalOq mMOnQTUr9sFl/zUhpz68CWUDMQ+ej3PQCk5LSX9DPpCdNuoMC/Wj0j2zbx0To+rai7DL H8dA== 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=ljQLvXBY81ZagAz+vbBgSRpeNzKthjrbvj4TtE4JxtM=; fh=nKwyeXx8rt8hF214OSFP+HjBpDto8utNxLoZSNqK/Bc=; b=QC1oRkk9tSnU7c664V/mgWasYdlj8s0SHqrugWRJbaca8JchToWUBQtstkRfFXfq7f 6hSTQC0xRQziCSs9kJf7HRRlZFqrup+Ic0iCzkczc74lWfubiA5ZjPspBu0elMympfn3 8iFYogtKBoFYzy3dsqH3S0PAKfOF4m1EtC31GtcoEzm71G+mhInr9jGGib3za6gaSbo1 TY036kih0vivz4zNtSBRWE5+2hONYrhT0huimJXa6lfbi82IDgS8wf9mj8g803NtTDMu kI+G5O+k1JGnzYtH1knCHhaVsyvQFY5kJvt2XuJtDW4UD09/FPaT5oCg8OEJPmyYkaAT 5UpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BewAU9F8; 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: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o4-20020ac87c44000000b00403ed87043fsi8230976qtv.697.2023.08.09.10.51.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Aug 2023 10:51:23 -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=BewAU9F8; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTnK5-0000Po-Ag; Wed, 09 Aug 2023 13:50:17 -0400 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 1qTnK3-0000OO-0i for qemu-devel@nongnu.org; Wed, 09 Aug 2023 13:50:15 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qTnK1-0005fC-4b for qemu-devel@nongnu.org; Wed, 09 Aug 2023 13:50:14 -0400 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-269304c135aso27716a91.3 for ; Wed, 09 Aug 2023 10:50:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691603412; x=1692208212; 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=ljQLvXBY81ZagAz+vbBgSRpeNzKthjrbvj4TtE4JxtM=; b=BewAU9F8uxcXcjMSwnG7vSFog8x6+0b77+Zl8kth06lQlqkv7O11O2S+xMxcViMWlp UVRh70LQPc3CwtfRBmLSt9cIRjvrH6CtwwmuKnMOV43whuzaIpB5Fi0sctaSRY23SIOR +/c76Ck9O5RnYIncBjJosgfQsjPIfvwv1JQlt982/IXaFvEBW5ITbFJehZ7gCTpelu+J jlESAX5baX+zxb3j01/iIxDbaYSz5wzbGojA4symALLSw3kv9I5nDbAkMZNxuC8JEwZ3 F4cNjXMC2LbJCErLR1I+JOUAbJ9EaRaeLZmusIl6ShSY4BUWJ95KXN7e3WH5oXgbWBwx C24w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691603412; x=1692208212; 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=ljQLvXBY81ZagAz+vbBgSRpeNzKthjrbvj4TtE4JxtM=; b=fYDTCK62d61UNvoNyCOK/t5Xb1QrMLpl5abZrtL3rUPhdkcgeG/BhNP5cjSfrChRvM efF+Fq/wV2b/1ynvsDuqM8UVJFbf5/kqID46hHLJ8VUVU0RSKauSEnCeDN6miCIWm0Gs 8fAzQQsIbSFQv4ohhYn4cCqMaHUJpBb0CrrGg8/D53DeLN4gETrM77Y1xRWG4rIX34xy OlagJ9SjJ7EIo3v2eGUeOVTLyLaluOgB0EIv0IccAKEyDTWlwPMW4E7iztxeUOtip7hx nk2VcRpoXuNogWaPGUFc/TlHCJmsrcNSO+sdVROfsCxJf1HheRb/EzqxwoVSNUNqkXtx Dz2Q== X-Gm-Message-State: AOJu0YyfEM6f8wgJKBygbvq23gb0aMTPCWnofyk/MLqRJ3a0/ogOsMBr xwqbBXMAt38TWnKvSnz7KXoYTRIoIdyEMPCON94= X-Received: by 2002:a17:90b:20b:b0:268:14a0:f8a with SMTP id fy11-20020a17090b020b00b0026814a00f8amr2794757pjb.39.1691603411859; Wed, 09 Aug 2023 10:50:11 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:6bf0:9674:6ac4:f74c]) by smtp.gmail.com with ESMTPSA id y7-20020a17090a2b4700b0025dc5749b4csm1753710pjc.21.2023.08.09.10.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 10:50:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Helge Deller Subject: [PULL 5/6] util/interval-tree: Check root for null in interval_tree_iter_first Date: Wed, 9 Aug 2023 10:50:05 -0700 Message-Id: <20230809175006.242479-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230809175006.242479-1-richard.henderson@linaro.org> References: <20230809175006.242479-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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=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: 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 From: Helge Deller Fix a crash in qemu-user when running cat /proc/self/maps in a chroot, where /proc isn't mounted. The problem was introduced by commit 3ce3dd8ca965 ("util/selfmap: Rewrite using qemu/interval-tree.h") where in open_self_maps_1() the function read_self_maps() is called and which returns NULL if it can't read the hosts /proc/self/maps file. Afterwards that NULL is fed into interval_tree_iter_first() which doesn't check if the root node is NULL. Fix it by adding a check if root is NULL and return NULL in that case. Signed-off-by: Helge Deller Fixes: 3ce3dd8ca965 ("util/selfmap: Rewrite using qemu/interval-tree.h") Message-Id: Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- util/interval-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/interval-tree.c b/util/interval-tree.c index f2866aa7d3..53465182e6 100644 --- a/util/interval-tree.c +++ b/util/interval-tree.c @@ -797,7 +797,7 @@ IntervalTreeNode *interval_tree_iter_first(IntervalTreeRoot *root, { IntervalTreeNode *node, *leftmost; - if (!root->rb_root.rb_node) { + if (!root || !root->rb_root.rb_node) { return NULL; } From patchwork Wed Aug 9 17:50:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 711930 Delivered-To: patch@linaro.org Received: by 2002:a05:6359:baf:b0:129:c516:61db with SMTP id gf47csp135483rwb; Wed, 9 Aug 2023 10:51:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6YEG9HG3XhJPIYh4P7nuwTYwdbl5wJL2Bc8EPPLWtMhg5WmaLHR+1Azy59jyqcy1oyuKE X-Received: by 2002:a05:620a:4110:b0:76c:bfeb:97d0 with SMTP id j16-20020a05620a411000b0076cbfeb97d0mr4314229qko.58.1691603469428; Wed, 09 Aug 2023 10:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691603469; cv=none; d=google.com; s=arc-20160816; b=s3vTVvYcHIRkjgH5BXUCdInMXbTsyY2v1IxyilFWChXrNJdZ5frZdem1rx4348c5Te R0igqk00qJNUUUycBLL9Kk+os4YowB0HJf9f/lXR7Noa3CFL9iQSMpw6c/hTM4kBpgc6 nB9KM1vGE7X1u57KRH76upzB2vFi0heF2+F2tIH04AzXjqX71TSDXOZq4HilS1Gero+s bUjj9bk2dqt9S+YQux3gtbVJVhad8FUSv6Uo4wfGVzeH293pQkBsqO+xc+UufBLIhNfF c+iYFmlheV3nW+ezbi+aSOOdZWsPmjIOXgbl7NalRaPP5RXcpIDjmRSE0SpH5vFhIlt0 tzmw== 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=hIJbV1+QSy586PHNn48HKMsvhOSunQxnQqr0K94zk5U=; fh=LqDr+k4kYq5gdxxYNR+AXeflmVPlfwJowKBh4V3WpJ0=; b=C80O+6H7/xgKprfapGTQcHX2RSFuHPrZ7IKGve/+GnEBmz3miObG6bT+PP+fO2uuEH QutGJcHisg2n/YOGuXtxr5fRU2f4V06vvLc3bPfoUC0AYCBpBlMC/5/gWi2GKz8JFgHq FwKOV26U3fex0q/bWdTptmv0Bm+nRUJOsbOA4A2vsDM9bUWuach5xh4LFi/Ug1FBNP3X SiqdIlG7PhvT2WK25XxrZDLULnjMrr0ViAxoqpC2IwaLeCeJXFYZQciRkq7yigPuRV8C /42Mne7kgTaCwywx4lXx7H8XbrPm3KuWLBOAH7SWIcX/s4i3K8fYxm/Aw5irxRhvhKBs MLtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ld3vbphY; 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: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x29-20020a05620a0b5d00b007681446a032si8102680qkg.269.2023.08.09.10.51.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Aug 2023 10:51:09 -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=Ld3vbphY; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTnK5-0000Q4-SN; Wed, 09 Aug 2023 13:50:17 -0400 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 1qTnK4-0000Ov-78 for qemu-devel@nongnu.org; Wed, 09 Aug 2023 13:50:16 -0400 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qTnK2-0005g0-Ep for qemu-devel@nongnu.org; Wed, 09 Aug 2023 13:50:15 -0400 Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6bc8d1878a0so54818a34.1 for ; Wed, 09 Aug 2023 10:50:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691603413; x=1692208213; 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=hIJbV1+QSy586PHNn48HKMsvhOSunQxnQqr0K94zk5U=; b=Ld3vbphY4vL9PDzXs1ZSC+0g/pDzUI71ZYemHpH+T0FZK6o8iIjo0EwvzNHPLBAfEE WXSRBmubQBBXF+t4Bp1edacF3IIwbk+MNz2i7ZmEIfl6U0EqmFO36rbN1FcJuSzHtYXD j9aW5p7q/J8R9XOIarXqpIuf0t12RgsICnTc+neikFsi+a9gKml/o5JGbH+E/9nDJdvS +SS4Lw7P6D5nxETBFKWhL6EC+sU0RxVnyt0mWZPWoyRRRif+LFPhTpVetthPXS7rh9ji gzpkVMpA19+XlclJRBCMizuXEh2d3E0aTQTIgq90gnvo33yhMW4TVWTXZNUE6aB33bxy 5ETQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691603413; x=1692208213; 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=hIJbV1+QSy586PHNn48HKMsvhOSunQxnQqr0K94zk5U=; b=Yra75fGETBgTtVH+GdtrjAtZ5BF1IEaMNlwSbnHEOeElwhdNXn5oVjcjFR9Q8mh5yj S1PtHCjW0rB5rGoALYp1iItvUlnrCkLutvxucHPLH0mllBT0PrAKU0XcSjczKbw4x7X5 GcSsHRZGFOfhD+7rF530Z7revem7ld84hfH+6VDOh/1DtsckuxLiKNZg1GH4K901cfG2 LC2HxjOX/VkoLQuKVVdtgXwQu+S1Hi6GG5vNGWEHF8g1sGtYDoH8O5AB16p756Uxfxav wwP1qz4M/tq2AYCgCdOjbxYmo+Iw+dJunXT/vejb4pnctYbrv59H07X1tXnb5XqI5FU/ BjjQ== X-Gm-Message-State: AOJu0YzJYdPdTVjiDG9p+fpIVPLVkxhn3PzLXSgS0koGoMFoD2R9DO8q tHf8kIp1sMbCdyFRVXhn++KGAQGPH0U/i9ZSvls= X-Received: by 2002:a05:6808:2092:b0:3a3:613b:2787 with SMTP id s18-20020a056808209200b003a3613b2787mr41229oiw.32.1691603412805; Wed, 09 Aug 2023 10:50:12 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:6bf0:9674:6ac4:f74c]) by smtp.gmail.com with ESMTPSA id y7-20020a17090a2b4700b0025dc5749b4csm1753710pjc.21.2023.08.09.10.50.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 10:50:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Helge Deller , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= Subject: [PULL 6/6] linux-user: Fix openat() emulation to correctly detect accesses to /proc Date: Wed, 9 Aug 2023 10:50:06 -0700 Message-Id: <20230809175006.242479-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230809175006.242479-1-richard.henderson@linaro.org> References: <20230809175006.242479-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::331; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x331.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=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: 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 From: Helge Deller In qemu we catch accesses to files like /proc/cpuinfo or /proc/net/route and return to the guest contents which would be visible on a real system (instead what the host would show). This patch fixes a bug, where for example the accesses cat /proc////cpuinfo or cd /proc && cat cpuinfo will not be recognized by qemu and where qemu will wrongly show the contents of the host's /proc/cpuinfo file. Signed-off-by: Helge Deller Reviewed-by: Daniel P. Berrangé Message-Id: <20230803214450.647040-2-deller@gmx.de> Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- linux-user/syscall.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 12ebc70df5..9353268cc1 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8557,9 +8557,12 @@ static int open_hardware(CPUArchState *cpu_env, int fd) } #endif -int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, + +int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *fname, int flags, mode_t mode, bool safe) { + g_autofree char *proc_name = NULL; + const char *pathname; struct fake_open { const char *filename; int (*fill)(CPUArchState *cpu_env, int fd); @@ -8585,6 +8588,14 @@ int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, { NULL, NULL, NULL } }; + /* if this is a file from /proc/ filesystem, expand full name */ + proc_name = realpath(fname, NULL); + if (proc_name && strncmp(proc_name, "/proc/", 6) == 0) { + pathname = proc_name; + } else { + pathname = fname; + } + if (is_proc_myself(pathname, "exe")) { if (safe) { return safe_openat(dirfd, exec_path, flags, mode);