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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3EB6C433F5 for ; Fri, 15 Apr 2022 00:56:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 266BF6B0071; Thu, 14 Apr 2022 20:56:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2183C6B0073; Thu, 14 Apr 2022 20:56:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 068CE6B0074; Thu, 14 Apr 2022 20:56:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id EB61D6B0071 for ; Thu, 14 Apr 2022 20:56:45 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CDED527ED3 for ; Fri, 15 Apr 2022 00:56:45 +0000 (UTC) X-FDA: 79357298370.25.D307EE6 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by imf30.hostedemail.com (Postfix) with ESMTP id C605080005 for ; Fri, 15 Apr 2022 00:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1649984204; x=1681520204; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=PIIeXs/XKpoxh4Ro8M+e5fsOaqPWnqNURWijGAB3loc=; b=qS0fjq3AUcl79iL7Ik4qk7om4BsdpN+p+UuPRI2jCqL0VDVQ2mt0aICT wpE3snN6EI3Atmj2DqVv/fDVsQ42uW69ZEam5YepWve1Lnmxv/+x3uz1j VGc0alNgur/JdVVJ8CGNh9AUfmB02UncgaJOrvNJWzYN2jJy3nL0IxHtD xZOBPtYcJoEds5Npf3xaPpodHnuEq7ELiX9hegYtwGTLM+tMwVp+3nLFF yPqQDJ2iSAYvJwTfOCviU6EeULbubKK95wghsgplreihaCBpg2bD800Ok /sqtn20KW3qmyxiojpfWdqBePmnE5v8OcUGiXC14/kv6Wh9vaRZK3ljpP w==; X-IronPort-AV: E=Sophos;i="5.90,261,1643644800"; d="scan'208";a="196819805" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 15 Apr 2022 08:56:43 +0800 IronPort-SDR: c4XTc4e9/4AKF82DX/RqTBajkhZa/nU96un1nspDXtZnLp2kD2hFdbHrOuoUasP5/YlisqOhK4 INy3TM5op4rGM/rR4lBmU9kyneaKW0mNTEC6zxUTc3j3NzkrXPAh+kjVLLKabQcgtpRMQoGY4M qdyiSW77qj8zZSKISug7HnfdKKPKFURYvICKPP9HNt3ps1uYoZqGrfj/p+0fPeOuUZFTU0qo3U Z7oAsqJ3iVJBOsDJZzxkYrqsT4w5tvyic4CNuFGnTb1SJDzxNQA7gapBMo2zCFAlWa37PcntJ5 iUiQJah71qI0IMkqwTF6tst3 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 14 Apr 2022 17:27:08 -0700 IronPort-SDR: DAWOA4AReWBHFCdhUVtlaWeeUBdBlCFWHKpOV6qcNxGs1rXipqklEVaOsGgtCFwAaqvDo1teZs ByXfjC2W2VgLwhqm/hbbrS+s2FL5Vxbk9eZirE14y27ibYtDPAWyb97lJPqntD6r49JC1ZdZGd Z6VLaexyGpjlGPxSLi5fZlj0868AisDCFcJZMtvp/Y+SdELjrMXZIthUbRMsSkkQlo14kc2Ogn 2PMl9b2lGZyKNjMEXdJE4dKdj9UgQCHy0zzc56WjzjKpvzj1G5bj8oGc0EJbaaNZQyuoZB4b3b jps= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 14 Apr 2022 17:56:44 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4KfdFR1g7Tz1SVp2 for ; Thu, 14 Apr 2022 17:56:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :in-reply-to:organization:from:references:to:content-language :subject:user-agent:mime-version:date:message-id; s=dkim; t= 1649984202; x=1652576203; bh=PIIeXs/XKpoxh4Ro8M+e5fsOaqPWnqNURWi jGAB3loc=; b=XsjOMN5cgk+Kag0RPwLITFO6mtYll1ywbvEhTEODj6B8KE8+QHB o/EsbPvhp4pzGPjsGk7lsKF75i+2DyXnmOimROm+EMZ58U7iaZSbo3XnUFFH3J+8 h6BOGtc9P8l1OUuht0bbSxMXiEYoqRLMuoVfhSA+8u/Ik4A9zm3wmrg7aCqlKel3 RYrNwv8AVsAS0YhJz0yyRCvlFT8miCTracpnS7T3xrstVEq0nJKLCq0c7dsruYZc yfoUdW0hM1MUnspPBPc/3KOUqP1AEtfKnaifOtCPf56rVbqTfvmtAmle9LXVBFCP 7uNRRC/d2OnpsPpR7Ts5TJxu/6MlLIsAIQQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id A37We7j3pYDm for ; Thu, 14 Apr 2022 17:56:42 -0700 (PDT) Received: from [10.225.163.9] (unknown [10.225.163.9]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4KfdFN0s2vz1Rvlx; Thu, 14 Apr 2022 17:56:39 -0700 (PDT) Message-ID: <6ee62ced-7a49-be56-442d-ba012782b8e2@opensource.wdc.com> Date: Fri, 15 Apr 2022 09:56:38 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v2] binfmt_flat: do not stop relocating GOT entries prematurely on riscv Content-Language: en-US To: Niklas Cassel Cc: Alexander Viro , Eric Biederman , Kees Cook , Paul Walmsley , Palmer Dabbelt , Albert Ou , Greg Ungerer , Mike Frysinger , "stable@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "linux-riscv@lists.infradead.org" References: <20220414091018.896737-1-niklas.cassel@wdc.com> From: Damien Le Moal Organization: Western Digital Research In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: C605080005 X-Stat-Signature: wypi7ei63uyi9bbyan17tumfwed7dp7d Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=qS0fjq3A; dkim=pass header.d=opensource.wdc.com header.s=dkim header.b=XsjOMN5c; spf=pass (imf30.hostedemail.com: domain of "prvs=0972008b0=damien.lemoal@opensource.wdc.com" designates 216.71.154.42 as permitted sender) smtp.mailfrom="prvs=0972008b0=damien.lemoal@opensource.wdc.com"; dmarc=pass (policy=quarantine) header.from=opensource.wdc.com X-HE-Tag: 1649984204-958770 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 4/15/22 09:30, Niklas Cassel wrote: > On Fri, Apr 15, 2022 at 08:51:27AM +0900, Damien Le Moal wrote: >> On 4/14/22 18:10, Niklas Cassel wrote: > > (snip) > >> This looks good to me. But thinking more about it, do we really need to >> check what the content of the header is ? Why not simply replace this >> entire hunk with: >> >> return rp + sizeof(unsigned long) * 2; >> >> to ignore the 16B (or 8B for 32-bits arch) header regardless of what the >> header word values are ? Are there any case where the header is *not* >> present ? > > Considering that I haven't been able to find any real specification that > describes the bFLT format. (No, the elf2flt source is no specification.) > This whole format seems kind of fragile. > > I realize that checking the first one or two entries after data start is > not the most robust thing, but I still prefer it over skipping blindly. > > Especially considering that only m68k seems to support shared libraries > with bFLT. So even while this header is reserved for ld.so, it will most > likely only be used on m68k bFLT binaries.. so perhaps elf2flt some day > decides to strip away this header on all bFLT binaries except for m68k? > > bFLT seems to currently be at version 4, perhaps such a change would > require a version bump.. Or not? (Now, if there only was a spec.. :P) The header skip is only for riscv since you have that "if (IS_ENABLED(CONFIG_RISCV)) {". So whatever you do under that if will not affect other architectures. The patch will be a nop for them. So if we are sure that we can just skip the first 16B/8B for riscv, I would not bother checking the header content. But as mentioned, the current code is fine too. Both approaches are fine with me but I prefer the simpler one :) > > > Kind regards, > Niklas > >> >>> + } >>> + return rp; >>> +} >>> + >>> static int load_flat_file(struct linux_binprm *bprm, >>> struct lib_info *libinfo, int id, unsigned long *extra_stack) >>> { >>> @@ -789,7 +813,8 @@ static int load_flat_file(struct linux_binprm *bprm, >>> * image. >>> */ >>> if (flags & FLAT_FLAG_GOTPIC) { >>> - for (rp = (u32 __user *)datapos; ; rp++) { >>> + rp = skip_got_header((u32 * __user) datapos); >>> + for (; ; rp++) { >>> u32 addr, rp_val; >>> if (get_user(rp_val, rp)) >>> return -EFAULT; >> >> Regardless of the above nit, feel free to add: >> >> Reviewed-by: Damien Le Moal >> >> >> -- >> Damien Le Moal >> Western Digital Research -- Damien Le Moal Western Digital Research