Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4046627imm; Tue, 25 Sep 2018 10:24:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV61xu8xOjwwE5bWti6U0aPs/fKPJmWQIJ33hRgYXiI6QVHR7APydg7DusZk+0d06cCtIXElX X-Received: by 2002:a62:ce83:: with SMTP id y125-v6mr2086654pfg.201.1537896253943; Tue, 25 Sep 2018 10:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537896253; cv=none; d=google.com; s=arc-20160816; b=wplzcpCSJEGmcaz/+8wJTtBusiXvqrixzm6723EQcXwTiZpAzskTkx07LjrsvMmbeC 7g1TBZyKXoIvYV51ZFRM3j0ab47wZZFQybejcauR0SguQRnpnEDVgCZdoteZXHRXQ5R6 5ITAepi7dwF3P4S4YSKs/+fcQKKboWOZ5E6Y76maopdBSAZbKt1vpZr/Y9WIcK2eFHeO r3vlN4AwmPFaXdbh4E9ZW7VurwisH/BqHiFwDAJcaF2H5P48dcj/wG26yf7RwSOBloY1 UAdNNYmNP7fwMXOcbMkH7vFYAGuilshvMYgl+WzLzQek+G/zkL/MZoesAm+b5qmnGHXL 5g2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=MCW0baKYvvIhFuAyH5M6200iBGENP0X2GXDwli/f644=; b=vGx0Ty9HYUE1W5RfcYBppNYUfCmEslid/wmVhLbdp6DBEe23Rk0PyLh8l+XOaSkBa8 sglaJq1d5oEiTpSPsbPjWl1AHWjuAVR4N77/PWnpufKcLcn2/lieLuJg9l0NdTj9wHGV K52lYpIKhKa5omsjFrZF7/4OgTr8/5teELgnQN56aGSWrv+VBl2Cdzly2FfsMGzy11Ac vs6O9IHdIxD6Uvc0K+IOCoOTAHbhqS07duUb6sVWVi5GpVJL6RUAX4s0ek8We3DDRHS1 KRAlStHsJ93LLA7j301tL/c7V2543PUUtm9JeyVMS2g/3GqgkDolmNwfTBXwuN8iKsSS Mzbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R5UJZGIa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i31-v6si2807229pgb.29.2018.09.25.10.23.57; Tue, 25 Sep 2018 10:24:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R5UJZGIa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727420AbeIYXbz (ORCPT + 99 others); Tue, 25 Sep 2018 19:31:55 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:38704 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727187AbeIYXbz (ORCPT ); Tue, 25 Sep 2018 19:31:55 -0400 Received: by mail-yb1-f195.google.com with SMTP id e190-v6so10103886ybb.5 for ; Tue, 25 Sep 2018 10:23:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=MCW0baKYvvIhFuAyH5M6200iBGENP0X2GXDwli/f644=; b=R5UJZGIaGUjUzgkL5g7WUONTVvWKZ5pJjCQRJAZ5HeoLa7vTTrtoY05Km0sdVpa2nF FrSdU2Gp14R10kGdH5T7tRL9LFSb8Jfee8WyBL7H6ikMOLww/UwGGPB9OthC5hSPKyvA kkGkwsvVVQB/uWsl6vmR6/efzTgJ+8S5tb2ws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=MCW0baKYvvIhFuAyH5M6200iBGENP0X2GXDwli/f644=; b=QhL6yGnGt1t93fvH7JzWjc6oxJHyCpkrqobzsyefQ5OVuLRADlFMjKc2RajZRc8T1Q szpxvurshfkGoJbAvnIP6ERPsuTQZJyQ0F6IABNl8NzYmSobY2bwGYssFrcEinYd9HVQ zzVjg7PyP3SpXsCiJykOu4zimKso+8S6zB1JjhfYEvWfkD4OY61cJEc63JfXQNGQE+wU 7IFK8dyySNGTJJ7h4E4Fyl3ZdPjPZCOSpbkXRE/pLEZmkPNAnD/B9J8kCFo4umnPKBlz 8kLGnIkfkQT1moEXD2bu7i0+DSn/lVs9CK7zo5VkU67Cg78Nne+zSfgplZ4RrbjS5mOf 9pLQ== X-Gm-Message-State: ABuFfogUEwAOVxjw9F4hDpu+DYmq6yaJRib1q3xwgmi5pxOgqAom6DE9 PL36soZjlO3qLYSU/WnfGBZY7yreshs= X-Received: by 2002:a25:3602:: with SMTP id d2-v6mr1175039yba.377.1537896204832; Tue, 25 Sep 2018 10:23:24 -0700 (PDT) Received: from mail-yw1-f52.google.com (mail-yw1-f52.google.com. [209.85.161.52]) by smtp.gmail.com with ESMTPSA id f194-v6sm3587310ywb.31.2018.09.25.10.23.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Sep 2018 10:23:22 -0700 (PDT) Received: by mail-yw1-f52.google.com with SMTP id k66-v6so4050656ywa.10 for ; Tue, 25 Sep 2018 10:23:21 -0700 (PDT) X-Received: by 2002:a0d:fec6:: with SMTP id o189-v6mr484181ywf.237.1537896201570; Tue, 25 Sep 2018 10:23:21 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:5f04:0:0:0:0:0 with HTTP; Tue, 25 Sep 2018 10:23:20 -0700 (PDT) In-Reply-To: References: <20180823024051.GC13343@shao2-debian> <20180823041434.GC3677@linux-r8p5> <20180824030920.GD3677@linux-r8p5> From: Kees Cook Date: Tue, 25 Sep 2018 10:23:20 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] ipc/shm: properly return EIDRM in shm_lock() To: Arnd Bergmann Cc: Davidlohr Bueso , kernel test robot , Stephen Rothwell , dbueso@suse.de, Manfred Spraul , Dmitry Vyukov , Herbert Xu , Michael Kerrisk , Michal Hocko , Andrew Morton , Linux Kernel Mailing List , LKP , ltp@lists.linux.it Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 25, 2018 at 5:00 AM, Arnd Bergmann wrote: > On Fri, Aug 24, 2018 at 5:09 AM Davidlohr Bueso wrote: >> >> When getting rid of the general ipc_lock(), this was missed >> furthermore, making the comment around the ipc object validity >> check bogus. Under EIDRM conditions, callers will in turn not >> see the error and continue with the operation. >> >> Fixes: 82061c57ce9 (ipc: drop ipc_lock()) >> Signed-off-by: Davidlohr Bueso >> --- > > Oddly, this change introduces a gcc warning in some configurations > (i.e. with randstruct enabled): > > ipc/shm.c: In function 'shm_lock': > ipc/shm.c:209:9: note: randstruct: casting between randomized > structure pointer types (ssa): 'struct shmid_kernel' and 'struct > kern_ipc_perm' > return (void *)ipcp; > ^~~~~~~~~~~~ > > Not sure why we didn't see that warning before, probably > it ended up making its own thing when the return code > was uninitialized. The fix is already queued up in mmotm: https://www.ozlabs.org/~akpm/mmotm/broken-out/ipc-shm-use-err_cast-for-shm_lock-error-return.patch randstruct stays quiet about ERR_PTR-family casts since they're not "real" casts to a functional struct. -Kees -Kees -- Kees Cook Pixel Security