Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp960563pxb; Wed, 3 Mar 2021 22:36:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyPevgrKrJ/uFbdC+rbJC3dMQWtzz7g4NFi6l9t2srz7rqVm5+Jfz3VstzmRKKNKgFKPdd X-Received: by 2002:a17:906:c1ca:: with SMTP id bw10mr2607309ejb.510.1614839780023; Wed, 03 Mar 2021 22:36:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614839780; cv=none; d=google.com; s=arc-20160816; b=pfdlK4PbsMycMBumQxbp43r3jHOswrMIC85ocz/6BCiVOMGnJxuPMVWKzL00KU1WfY IpVDRw43vuNrtHoNoO7VZa9ZPUphlYqed3mHGaXslD611k4l9N77w3f2+AtF9LwONzCo +AHILi5vMafAYaFGmJQbjgW6XyvhfvD/vfeNNBObGpZWEnTSoXcG0SV4SLwe9ImtZCNQ GG5uHW2w5FWII72IBICuhp/r5YjPcEXK58V7Qlb3ofdcMXUbi4wHswz92fCuCmACJecd lhk3wUEDBWR8L9/TihCy7gSqR03Q6DVzDuGQyPKLIOQGA9+NyS6RdFmsvU3gH+eeRJyG fvyg== 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=JoOi1VQKYJA6ZW+eLQKjH4JJ8KX9VGExJXoWL2AhruY=; b=yfJIbkDQ41eiZCCe/AF0NYXsw0WMY6kpkmVp9YKN+ct06r6LcsBSuFcdFR4MQwrjrR IiQmoEJOexlUbB+zB+2h7tL/BBvX8Hp3R7/b5miZlyhY63GMVBzFcMrQdBd4ol0RY55p rGAshIy7/clWPsrdVikvnTMDlUzMcV/v73ygFcgs37IZmyukzrw/ln5g8jKoTiNJa1Pu 7MOHnU243Zkdjzly93by3FBQvCOBC0NldWOIGVXLdlhanb02W+JlHyJt5Ku9W9wT4kWR Yf9zhzi0rsbMEYuLvC7s2Hb1JueL9AgVKEWsUircRBKxlY4NRmCcPJAKMAK7syMR6Kjh 5Ofg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="GYvzW/Xa"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id vr7si3272828ejb.392.2021.03.03.22.35.57; Wed, 03 Mar 2021 22:36:20 -0800 (PST) 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=@linaro.org header.s=google header.b="GYvzW/Xa"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1581252AbhCBSlk (ORCPT + 99 others); Tue, 2 Mar 2021 13:41:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1448898AbhCBPnP (ORCPT ); Tue, 2 Mar 2021 10:43:15 -0500 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4E4FC061788 for ; Tue, 2 Mar 2021 07:40:34 -0800 (PST) Received: by mail-lj1-x230.google.com with SMTP id a17so24503760ljq.2 for ; Tue, 02 Mar 2021 07:40:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JoOi1VQKYJA6ZW+eLQKjH4JJ8KX9VGExJXoWL2AhruY=; b=GYvzW/XasiKnxPmuWkbAzZbF5LKRI17d2RmV7gJqNx/LMDjfElx3+drTy5Ok9hoHwJ 0NdMg3c5pkaBawgYqv6MiudwMsaPEa17nwXwWPm67zE7MgW9sp3OGNwagru7DWgr8Z1E QKyBxi71GaLJJ5dmGVyH52upR2fhfFaHdZWOXFNUf9AXub1NrEw4nfuDMZ/E6Ubu6GE2 /bQwOW20cMAhYMK0ww++42kk2FyzfETKTs8hsjPzPJiBUlAkMz3QbkFjm4UItoI/Ztxb iWYfvthYa7VvqqgLM7olobJRHXXHIrzjUn10qclu/BiLjm9NEXk0zAYLhW6ejOR7PK3f Wr4g== 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=JoOi1VQKYJA6ZW+eLQKjH4JJ8KX9VGExJXoWL2AhruY=; b=e+K3Kvj3V1iTuuIkBwE2RbKLhukI9i/EuIrmQEk8p4ZjW+RpAeV8NWnn3A3dVg7/re U57+9hVLGAENN5khJV9UlAsdcXQ9nxWSIhapXrKBLV/5eV3nZ5ilgDxZ9jhVfXtwTmGM j9tXL1b+2mNFkkME4gIwB7+eYIpXm8S0G5roMhfGG3de/cWzo7g1sj8K3foRMKsVtv/2 1Lw/jCp2lG2ogxh917cY+6H/46QfZH7Wi4sLit7gVu9KEbDimfnknjjI0EmXx1NbGw2X D13aLUafFZpd34DyJadAs1V3opyT872KTQzxt+cumn6Ny8Zs43VjCROuA/HbuJAywfU6 ZWHg== X-Gm-Message-State: AOAM531+Er6Qo3rdcTjIPq6b9BMacFVpvJv3oKrsO4OHi6gK+rFoLF48 LJtE5E0A1jNrred1ux5LMpJrNnYIrYp80s+nvU2aLQ== X-Received: by 2002:a2e:700a:: with SMTP id l10mr12521528ljc.368.1614699633208; Tue, 02 Mar 2021 07:40:33 -0800 (PST) MIME-Version: 1.0 References: <20210301090519.26192-1-johan@kernel.org> <20210301090519.26192-2-johan@kernel.org> In-Reply-To: <20210301090519.26192-2-johan@kernel.org> From: Linus Walleij Date: Tue, 2 Mar 2021 16:40:22 +0100 Message-ID: Subject: Re: [PATCH v2 1/2] gpio: fix NULL-deref-on-deregistration regression To: Johan Hovold Cc: Bartosz Golaszewski , Greg Kroah-Hartman , Saravana Kannan , "open list:GPIO SUBSYSTEM" , "linux-kernel@vger.kernel.org" , syzbot+d27b4c8adbbff70fbfde@syzkaller.appspotmail.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 1, 2021 at 10:05 AM Johan Hovold wrote: > Fix a NULL-pointer deference when deregistering the gpio character > device that was introduced by the recent stub-driver hack. When the new > "driver" is unbound as part of deregistration, driver core clears the > driver-data pointer which is used to retrieve the struct gpio_device in > its release callback. > > Fix this by using container_of() in the release callback as should have > been done all along. > > Fixes: 4731210c09f5 ("gpiolib: Bind gpio_device to a driver to enable fw_devlink=on by default") > Cc: Saravana Kannan > Cc: Greg Kroah-Hartman > Reported-by: syzbot+d27b4c8adbbff70fbfde@syzkaller.appspotmail.com > Signed-off-by: Johan Hovold Oh nice catch! Reviewed-by: Linus Walleij Yours, Linus Walleij