8 ms·
The maintainer's patch is better. 1. It doesn't lose the fpidx < (PT_FPSCR - PT_FPR0) test from the 32 bit case. 2. In the put function, it doesn't lose the *
by kazinator 3y ago
The maintainer's patch is better.
1. It doesn't lose the fpidx < (PT_FPSCR - PT_FPR0) test from the 32 bit case.
2. In the put function, it doesn't lose the *data = child->thread.fp_state.fpscr; fallback assignment, which is taken when fpidx is out of bounds.
3. It avoids the pointless FPRINDEX macro which reduces to identity if TS_FPRWIDTH is 1. The original patch's commit message says "On PPC32 it's ok to assume that TS_FPRWIDTH is 1", but then includes this anyway:
#define FPRNUMBER(i) (((i) - PT_FPR0) >> 1)
#define FPRHALF(i) (((i) - PT_FPR0) & 1)
#define FPRINDEX(i) TS_FPRWIDTH * FPRNUMBER(i) * 2 + FPRHALF(i)
Sorry, just because you found this trivially fixable array mismatch doesn't mean your buggy patch has to be accepted the way it is.
The maintainer should, however, acknowledge that Miculas didn't simply report the problem, but that Miculas investigated identified the root cause, and had his own version of almost the same simple fix.
"Reported-By" lacks the precision to express that it was thoroughly investigated by that party, and root-caused.
- bhouston 3y agoI agree that the maintainers work is better. But he could have just done this as a code review on the patch and ask for an update. That happens constantly for new contributors to a project and it is the proper way to do things - it teaches people and brings them up to speed. If you just redo their work, you are discouraging them from contributing while also not allowing for a teachable moment.
- jacquesm 3y agoNot on a security related list though. That's entirely the wrong expectation.
- varispeed 3y agoSecurity through obscurity? Oh...
- Arnavion 3y agolinuxppc-dev is not a security list.
- jacquesm 3y agoIt was cc-'d to the security list.
- deleted 3y ago[deleted]
- Arnavion 3y agoOn the first patch that Miculas submitted with their gmail address that was not looked at by any of the parties involved in the rest of the story. The subsequent mails to linuxppc-dev where Leroy and Ellerman were involved were not cross-posted AFAICT.
- jacquesm 3y agoYes, that's correct. But the OP didn't have to CC the security mailing list in the first place and that changed the dynamic considerably. Note that the degree to which this has blown up is disproportional and that besides the fact that Michael Ellerman could have handled this more gracefully the OP did not seek to resolve this out of band, misrepresented the interaction and ignored an olive branch that would have given him exactly what he wanted. The bit where I am in strict disagreement with how Michael Ellerman handled this is actually the reverse of what happened: if the original patch wasn't properly signed off on and the OP was responsive they actually put themselves at risk by re-using the code without proper attribution. This - and that's speculative - probably was because the code identified the essence of the fix but introduced a couple of new problems and because it was so small he may have felt that fixing it and adding a 'Reported-by' tag plus the LKML archive would be sufficient cover for that. But from a strict reading of the LKML guidelines that was the wrong thing to do. And the LKML guidelines themselves should be made clearer with respect to how the various levels of contribution are dealt with because that seems to matter a lot to some people and they need to spell out more clearly that submitting a patch may result in your code ending up in the kernel with LKML as the only visible proof that this is the case. Because the OP may not realize it but that is the essential part: that their submission to LKML ended with a bug in the Linux kernel fixed and there is ample proof to document that and I'm pretty sure that nobody would claim otherwise.
- fsdjkflsjfsoij 3y agoA lot of these maintainers are already overworked and don't have time to tutor every single person that wants to put kernel contributor on their resume. A lot of people have this extremely idealistic view of open source but the reality is that the vast majority of patches you receive will be atrocious and you shouldn't have to tutor every single "potential" contributor. This case is even worse since this issue was posted to a security mailing list which means time to resolution is important.
- ChildOfEru 3y agoWho knows how long this would have been unaddressed without Ariel Miculas initial input. Part of the job of a maintainer is to curate and foster input so the project has a robust community in the future. The maintainer in this case did a miserable job of that.
- a_t48 3y agoOn the other hand, to dig yourself out of the hole of “I’m too busy and there’s nobody around to help”, you have to slow down and do this, sometimes.
- bhouston 3y ago> to dig yourself out of the hole of “I’m too busy and there’s nobody around to help”, you have to slow down and do this Exactly! If you treat new contributors as crap because you are overworked, you will push away potential long-term collaborators who could share the load thus ensuring you will be working alone far into the future. This is a failure state and if I had a manager doing that to those he was managing, he wouldn't be a manager for long.
- caconym_ 3y ago> A lot of these maintainers are already overworked and don't have time to tutor every single person that wants to put kernel contributor on their resume. This seems like a very cynical view of what happened here, and completely unfounded. Obviously these big open-source projects need gatekeepers, but if the gatekeepers often make aspiring contributors feel violated and humiliated rather than offering feedback to get their initial contributions across the finish line, general interest and enthusiasm for contributing are going to dry up. Maybe that's by design, but it doesn't feel sustainable in the long term.
- hnfong 3y agoI looked at the two patches, and TBH the time taken to write the final correct patch would be a fraction of the time needed to explain how to write a better patch. In a company where people are expected to stay around for a while, it may make sense to invest time to bring juniors up to speed. But I wonder whether that's true for OSS projects in general. A person randomly shows up to report and attempt fix a bug in an "obscure"(?) architecture -- this is not a junior who just joined the team, and they have no commitment to stick around to do more contributions. In this case, from a utilitarian perspective, it doesn't seem obvious the maintainer should spend the extra time coaching. This might be a minority view here, but TBH I don't think anyone should be obliged to go out of their way to spend extra time and effort to avoid offending a random person on the Internet.
- tjoff 3y agoThe time to write the patch is insignificant in this context.
- that_guy_iain 3y agoI would say that the author stated he asked for his patch to be accepted so he could be a contributor implies they weren't planning on contributing more. So it doesn't seem like a sceranio where they should spend that extra time.
- deleted 3y ago[deleted]
- kazinator 3y agoNot really. 1. Please don't drop cases from your #if CONFIG_PPC32 blocks that are handled on 64 bit. You can use if (IS_ENABLED(CONFIG_PPC32)) instead of #ifdef so the only difference is in the array access. 2. Please remove the FPRINDEX macro; as you note in your commit message, we can assume TS_FPRWIDTH is 1. The maintainer also wrote a long and detailed commit message in his own version of the patch; he had time to explain things. In this exact situation, I would possibly have made the code adjustments myself and written "patch provided by Ariel Miculas". Then send an e-mail saying that I made a few minor tweaks to your patch, here is what it looks like. "patch provided by" tells the truth: that person provided a working patch. It doesn't say that the patch they provided is precisely this one.
- arp242 3y agoWhat usually happens is that someone sends a patch with a text description of the problem, but no test case. So what I do in those cases is just quickly look at the patch and create a test case first, on the current stable version, to reproduce the bug. This is both so that a test case exists, but also so that I have a deeper understanding of the problem. When that is done, often the fix is simple, and the author's patch sometimes just ... isn't that great, often for entirely understandable reasons, so it's easier to just fix it myself "from scratch". So whose patch is it then? In some cases the patch was useful and I'm "inspired" by it, in other cases I'm not. I tend to err on the side of caution, but I've definitely merged my share of patches where the Author field was, IMHO, kind of a lie. As for code review: it's really time-consuming. And while a few "minor bug fixers" of today become "hard-core contributors" or tomorrow, realistically, most people show up to fix one bug and are never seen again. That's perfectly fine! But it does mean that "teaching" everyone who shows up quickly become an enormous time sink. There's a bit of a trade-off to be made here.
- kazinator 3y ago"This change is closely based on a well-considered patch from A. U. Thor <author@example.com>, who also originated the bug report." A. U. Thor can point to that 10 years later and say he or she fixed that; nobody cares if the maintainer changed a few things.
- deleted 3y ago[deleted]
- Arnavion 3y ago>Sorry, just because you found this trivially fixable array mismatch doesn't mean your buggy patch has to be accepted the way it is. I know reading is hard, but it's not an excuse to put words in other people's mouths. >>I told him that I would really appreciate if he could accept a patch from me, so that I could receive credit for fixing this issue and become a kernel contributor. I was also open to working with him, addressing his feedback and sending subsequent versions of patches.
- fsdjkflsjfsoij 3y agoSo the maintainer now has to tutor this guy for god knows how long until he gets it right? All three issues brought up by kazinator are reasonable grounds for ignoring the patch. Do you think that the already overworked maintainers should have to spend significant amounts of their time tutoring every potential contributor? Are you going to pay them for that?
- SeenNotHeard 3y agoIt doesn't sound like you've ever maintained an active free software project. It's not "tutoring" to perform a code review and request additional changes to the patch. That's a standard feedback mechanism in free software development. kazinator's analysis may be right, but it doesn't sound like it would have taken the maintainer more than a few minutes to explain his objections and given the contributor a chance to shore up his patch. There's plenty of examples in the history of the kernel project of much larger patches going round and round until they land. From kazinator's description, it's possible the patch could have been made ready in a single review round. > All three issues brought up by kazinator are reasonable grounds for ignoring the patch. The patch (and bug report) wasn't ignored. That's kind of the point.
- kazinator 3y agoMiculas is not dumb; he's obviously a self-starter who pulled the investigation together through gdb, and the kernel interface, plus surrounding research into the history of the problem. He got excited to close the array access problem and lost sight of the necessity to fix only that and not change anything else, like the bounds check on the index. All it needed was a nudge to put his attention to that detail.
- EB66 3y ago> Sorry, just because you found this trivially fixable array mismatch doesn't mean your buggy patch has to be accepted the way it is. That's not really what anyone is suggesting should have happened. The maintainer should've just taken the two minutes of extra time required to checkout the OP's code, make whatever changes the maintainer wanted and commit it with co-authorship. That clearly would've been the best course of action for the maintainer to follow (especially given that the OP expressed his desire to the recognized for his contribution) -- the best fix gets merged in and the work of others is acknowledged/respected. That said, I'm not surprised it didn't happen -- social niceties often seem to escape the maintainers of these sorts of repos...
- ww520 3y agoDebugging is hard, sometimes very hard. Writing a fix on a familiar code base is comparatively trivial, especially having a working version of the prior fix as the guide. Writing the second version is always easier. Saying that it’s a simple fix shows one doesn’t understanding the amount of work go into bug fixings in software development. In this case Michael even acknowledged that he could not reproduce it initially but only later had it nailed down. This speaks volume about the amount of work OP put into debugging and fixing the problem. Robbing him of his work is just not right.
- kazinator 3y agoIf you've been chasing a bug for a while and finally have a fix, you may have code blindness to ever-important issues not related to the fix. The testing you're doing is whether or not that problem went away. This is true even if you're familiar with the code base. That's why we have pair programming and code reviews. That same developer who spotted your code blindness today will exhibit that themself tomorrow. The person not involved in the feature or fix is completely free to think about nothing else but "in what ways is this change wrong"?
- xtracto 3y agoI've written countless of patches / PRs for diverse OSS . Most of the times was to scratch an itch. Most of the time as well the PR doesn't get accepted because of various reasons. I don't care. I do the PRs so that the code is out there. No I wont spent time making it "good enough " to merge into your repo. I provide it as is, and I'd someone likes it enough they can do the red tape. Some of it has been just accepted and merged. Some was slightly modified by the repo owner before merging. Good for them. I dont do open source code for the glory or to be popular, I do it because I like it . Aaah I miss the 80s and 90s.
- ariel-miculas 3y ago1. As I said in the original thread: There is already a check at the beginning of the function: if (index > PT_FPSCR) return -EIO; 2. fpscr will actually be written to by this line of code: + ((unsigned int \*)child->thread.fp_state.fpr) + [FPRINDEX(index)] = data; 3. This is a nitpick. So please tell me how my patch was buggy.
- kazinator 3y ago1. The index > PT_FPSCR test isn't good enough: int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data) { unsigned int fpidx = index - PT_FPR0; if (index > PT_FPSCR) return -EIO; flush_fp_to_thread(child); if (fpidx < (PT_FPSCR - PT_FPR0)) memcpy(data, &child->thread.TS_FPR(fpidx), sizeof(long)); else *data = child->thread.fp_state.fpscr; return 0; } It is testing the original signed value of type int, which could be negative, and therefore convert to a huge unsigned int value manifested in fpidx. (Also, the function risks integer subtraction underflow in "index - PT_FPR0". If we pass in the value INT_MIN, subtracting a positive value from it is undefined behavior.) It looks like the original author knew that the -EIO test is too weak, so the converted unsigned value is tested again. Regarding 2, accessing fpscr using fpr[32] is undefined behavior (out of bounds array access), which is probably why the original code is refraining from that, but testing for that value and separately accessing the member. However is also this bit of uncertainty (I have not fully drilled into). On 32 bit PPC, that PT_FPSCR is defined with an extra offset of 1: #define PT_FPSCR (PT_FPR0 + 2*32 + 1) I suspect that this is due to PPC being big endian; the + 1 displaces the index to the lower half of a 64 bit word. This also tells me that this fpscr register must be 32 bits on PPC32? Thus, even with the range check in place, out-of-bounds access past the array is possible if user space requests the [64] index since the range check is testing for below 65. The [64] index isn't fpscr, but the upper half of u64 fpscr. There is also the aspect that when we assign to fpscr, the whole 64 bit value is assigned, not just half of it.
- fennecfoxy 3y agoLmao, even GH does something where it's: "by ORIGINAL_AUTHOR, co-authored by MAINTAINER". Ah but the kernel is a special secret club indeed.
- epinephrinios 3y agoThe correct thing to do is to leave these comments as a code review and let the contributor fix it. No one argued in favor of accepting a buggy patch.